diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-06-28 13:32:54 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-06-28 13:32:54 +0000 |
commit | 86ffccf24f66032a89d70a32b3609584c0db7345 (patch) | |
tree | 2ae97fac6ea5be57cc953baf8612e8f683da0172 /usr.sbin/apmd | |
parent | ce9fea47562d4f179d45680d6aec00ede2877141 (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.sbin/apmd')
-rw-r--r-- | usr.sbin/apmd/apmd.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index 8254b791a21..ab1f2900908 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmd.c,v 1.84 2018/12/04 18:00:57 tedu Exp $ */ +/* $OpenBSD: apmd.c,v 1.85 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 1995, 1996 John T. Kohl @@ -316,7 +316,7 @@ handle_client(int sock_fd, int ctl_fd) break; } - if (sysctl(cpuspeed_mib, 2, &cpuspeed, &cpuspeed_sz, NULL, 0) < 0) + if (sysctl(cpuspeed_mib, 2, &cpuspeed, &cpuspeed_sz, NULL, 0) == -1) logmsg(LOG_INFO, "cannot read hw.cpuspeed"); reply.cpuspeed = cpuspeed; @@ -464,7 +464,7 @@ main(int argc, char *argv[]) doperf = PERF_MANUAL; if (debug == 0) { - if (daemon(0, 0) < 0) + if (daemon(0, 0) == -1) error("failed to daemonize", NULL); openlog(__progname, LOG_CONS, LOG_DAEMON); setlogmask(LOG_UPTO(LOG_NOTICE)); @@ -501,10 +501,10 @@ main(int argc, char *argv[]) EV_CLEAR, 0, 0, NULL); nchanges = 2; } - if (kevent(kq, ev, nchanges, NULL, 0, &sts) < 0) + if (kevent(kq, ev, nchanges, NULL, 0, &sts) == -1) error("kevent", NULL); - if (sysctl(ncpu_mib, 2, &ncpu, &ncpu_sz, NULL, 0) < 0) + if (sysctl(ncpu_mib, 2, &ncpu, &ncpu_sz, NULL, 0) == -1) error("cannot read hw.ncpu", NULL); for (;;) { @@ -513,7 +513,7 @@ main(int argc, char *argv[]) sts = ts; apmtimeout += 1; - if ((rv = kevent(kq, NULL, 0, ev, 1, &sts)) < 0) + if ((rv = kevent(kq, NULL, 0, ev, 1, &sts)) == -1) break; if (apmtimeout >= ts.tv_sec) { @@ -645,7 +645,8 @@ setperfpolicy(char *policy) setlo = 1; } - if (sysctl(hw_perfpol_mib, 2, oldpolicy, &oldsz, policy, strlen(policy) + 1) < 0) + if (sysctl(hw_perfpol_mib, 2, oldpolicy, &oldsz, + policy, strlen(policy) + 1) == -1) logmsg(LOG_INFO, "cannot set hw.perfpolicy"); if (setlo == 1) { @@ -653,7 +654,7 @@ setperfpolicy(char *policy) int perf; int new_perf = 0; size_t perf_sz = sizeof(perf); - if (sysctl(hw_perf_mib, 2, &perf, &perf_sz, &new_perf, perf_sz) < 0) + if (sysctl(hw_perf_mib, 2, &perf, &perf_sz, &new_perf, perf_sz) == -1) logmsg(LOG_INFO, "cannot set hw.setperf"); } } |