From 86ffccf24f66032a89d70a32b3609584c0db7345 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Fri, 28 Jun 2019 13:32:54 +0000 Subject: 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. --- sbin/savecore/savecore.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sbin/savecore') diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index b5db8daddff..515c6c6052a 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -1,4 +1,4 @@ -/* $OpenBSD: savecore.c,v 1.61 2019/02/05 02:17:32 deraadt Exp $ */ +/* $OpenBSD: savecore.c,v 1.62 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */ /*- @@ -133,7 +133,7 @@ main(int argc, char *argv[]) /* Increase our data size to the max if we can. */ if (getrlimit(RLIMIT_DATA, &rl) == 0) { rl.rlim_cur = rl.rlim_max; - if (setrlimit(RLIMIT_DATA, &rl) < 0) + if (setrlimit(RLIMIT_DATA, &rl) == -1) syslog(LOG_WARNING, "can't set rlimit data size: %m"); } @@ -538,7 +538,7 @@ err2: syslog(LOG_WARNING, exit(1); } } - if (nr < 0) { + if (nr == -1) { syslog(LOG_ERR, "%s: %s", kernel ? kernel : _PATH_UNIX, strerror(errno)); syslog(LOG_WARNING, @@ -639,12 +639,12 @@ check_space(void) int fd; tkernel = kernel ? kernel : _PATH_UNIX; - if (stat(tkernel, &st) < 0) { + if (stat(tkernel, &st) == -1) { syslog(LOG_ERR, "%s: %m", tkernel); exit(1); } kernelsize = st.st_blocks * S_BLKSIZE; - if ((fd = open(dirn, O_RDONLY, 0)) < 0 || fstatfs(fd, &fsbuf) < 0) { + if ((fd = open(dirn, O_RDONLY, 0)) == -1 || fstatfs(fd, &fsbuf) == -1) { syslog(LOG_ERR, "%s: %m", dirn); exit(1); } -- cgit v1.2.3