diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-06-28 13:35:06 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-06-28 13:35:06 +0000 |
commit | 61656abc7ff84215165af1bd464bc053b3b66158 (patch) | |
tree | c7eabb0c4fa9faa024e724e99c240c40da07ca42 /usr.bin/newsyslog | |
parent | 18603ebf99fbb890ae9666cb0c4aa9f879e7edaa (diff) |
When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.
Diffstat (limited to 'usr.bin/newsyslog')
-rw-r--r-- | usr.bin/newsyslog/newsyslog.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c index e0d6be77903..066167151ca 100644 --- a/usr.bin/newsyslog/newsyslog.c +++ b/usr.bin/newsyslog/newsyslog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newsyslog.c,v 1.111 2019/06/28 05:35:34 deraadt Exp $ */ +/* $OpenBSD: newsyslog.c,v 1.112 2019/06/28 13:35:02 deraadt Exp $ */ /* * Copyright (c) 1999, 2002, 2003 Todd C. Miller <millert@openbsd.org> @@ -922,7 +922,7 @@ compress_log(struct conf_entry *ent) return; } pid = fork(); - if (pid < 0) { + if (pid == -1) { err(1, "fork"); } else if (pid == 0) { (void)execl(COMPRESS, base, "-f", tmp, (char *)NULL); @@ -956,10 +956,10 @@ age_old_log(struct conf_entry *ent) (void)snprintf(file, sizeof(file), "%s.0", ent->log); if (ent->flags & CE_COMPACT) { if (stat_suffix(file, sizeof(file), COMPRESS_POSTFIX, &sb, - stat) < 0 && stat(file, &sb) < 0) + stat) < 0 && stat(file, &sb) == -1) return (-1); } else { - if (stat(file, &sb) < 0 && stat_suffix(file, sizeof(file), + if (stat(file, &sb) == -1 && stat_suffix(file, sizeof(file), COMPRESS_POSTFIX, &sb, stat) < 0) return (-1); } @@ -1006,7 +1006,7 @@ domonitor(struct conf_entry *ent) FILE *fp; int rd; - if (stat(ent->log, &sb) < 0) + if (stat(ent->log, &sb) == -1) return (0); if (noaction) { @@ -1027,7 +1027,7 @@ domonitor(struct conf_entry *ent) STATS_DIR, flog); /* ..if it doesn't exist, simply record the current size. */ - if ((sb.st_size == 0) || stat(fname, &tsb) < 0) + if ((sb.st_size == 0) || stat(fname, &tsb) == -1) goto update; fp = fopen(fname, "r"); |