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 | |
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')
142 files changed, 781 insertions, 781 deletions
diff --git a/usr.sbin/acme-client/http.c b/usr.sbin/acme-client/http.c index 1811d1bd684..329773907ad 100644 --- a/usr.sbin/acme-client/http.c +++ b/usr.sbin/acme-client/http.c @@ -1,4 +1,4 @@ -/* $Id: http.c,v 1.26 2019/06/07 08:07:52 florian Exp $ */ +/* $Id: http.c,v 1.27 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -72,7 +72,7 @@ dosysread(char *buf, size_t sz, const struct http *http) ssize_t rc; rc = read(http->fd, buf, sz); - if (rc < 0) + if (rc == -1) warn("%s: read", http->src.ip); return rc; } @@ -83,7 +83,7 @@ dosyswrite(const void *buf, size_t sz, const struct http *http) ssize_t rc; rc = write(http->fd, buf, sz); - if (rc < 0) + if (rc == -1) warn("%s: write", http->src.ip); return rc; } @@ -97,7 +97,7 @@ dotlsread(char *buf, size_t sz, const struct http *http) rc = tls_read(http->ctx, buf, sz); } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT); - if (rc < 0) + if (rc == -1) warnx("%s: tls_read: %s", http->src.ip, tls_error(http->ctx)); return rc; @@ -112,7 +112,7 @@ dotlswrite(const void *buf, size_t sz, const struct http *http) rc = tls_write(http->ctx, buf, sz); } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT); - if (rc < 0) + if (rc == -1) warnx("%s: tls_write: %s", http->src.ip, tls_error(http->ctx)); return rc; diff --git a/usr.sbin/acme-client/util.c b/usr.sbin/acme-client/util.c index 3fb7fa7c4e2..4da5b294163 100644 --- a/usr.sbin/acme-client/util.c +++ b/usr.sbin/acme-client/util.c @@ -1,4 +1,4 @@ -/* $Id: util.c,v 1.11 2018/03/15 18:26:47 otto Exp $ */ +/* $Id: util.c,v 1.12 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -91,7 +91,7 @@ readop(int fd, enum comm comm) long op; ssz = read(fd, &op, sizeof(long)); - if (ssz < 0) { + if (ssz == -1) { warn("read: %s", comms[comm]); return LONG_MAX; } else if (ssz && ssz != sizeof(long)) { @@ -124,7 +124,7 @@ readbuf(int fd, enum comm comm, size_t *sz) size_t rsz, lsz; char *p = NULL; - if ((ssz = read(fd, sz, sizeof(size_t))) < 0) { + if ((ssz = read(fd, sz, sizeof(size_t))) == -1) { warn("read: %s length", comms[comm]); return NULL; } else if ((size_t)ssz != sizeof(size_t)) { @@ -143,7 +143,7 @@ readbuf(int fd, enum comm comm, size_t *sz) rsz = 0; lsz = *sz; while (lsz) { - if ((ssz = read(fd, p + rsz, lsz)) < 0) { + if ((ssz = read(fd, p + rsz, lsz)) == -1) { warn("read: %s", comms[comm]); break; } else if (ssz > 0) { @@ -175,7 +175,7 @@ writeop(int fd, enum comm comm, long op) sigfp = signal(SIGPIPE, sigpipe); - if ((ssz = write(fd, &op, sizeof(long))) < 0) { + if ((ssz = write(fd, &op, sizeof(long))) == -1) { if ((er = errno) != EPIPE) warn("write: %s", comms[comm]); signal(SIGPIPE, sigfp); @@ -212,7 +212,7 @@ writebuf(int fd, enum comm comm, const void *v, size_t sz) sigfp = signal(SIGPIPE, sigpipe); - if ((ssz = write(fd, &sz, sizeof(size_t))) < 0) { + if ((ssz = write(fd, &sz, sizeof(size_t))) == -1) { if ((er = errno) != EPIPE) warn("write: %s length", comms[comm]); signal(SIGPIPE, sigfp); @@ -223,7 +223,7 @@ writebuf(int fd, enum comm comm, const void *v, size_t sz) if ((size_t)ssz != sizeof(size_t)) warnx("short write: %s length", comms[comm]); - else if ((ssz = write(fd, v, sz)) < 0) { + else if ((ssz = write(fd, v, sz)) == -1) { if (errno == EPIPE) rc = 0; else diff --git a/usr.sbin/amd/amd/amd.c b/usr.sbin/amd/amd/amd.c index 3f46c4e82df..b41ee0be9ee 100644 --- a/usr.sbin/amd/amd/amd.c +++ b/usr.sbin/amd/amd/amd.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)amd.c 8.1 (Berkeley) 6/6/93 - * $Id: amd.c,v 1.22 2015/09/11 19:03:30 millert Exp $ + * $Id: amd.c,v 1.23 2019/06/28 13:32:46 deraadt Exp $ */ /* @@ -167,11 +167,11 @@ daemon_mode(void) #ifdef TIOCNOTTY { int t = open("/dev/tty", O_RDWR); - if (t < 0) { + if (t == -1) { if (errno != ENXIO) /* not an error if already no controlling tty */ plog(XLOG_WARNING, "Could not open controlling tty: %m"); } else { - if (ioctl(t, TIOCNOTTY, 0) < 0 && errno != ENOTTY) + if (ioctl(t, TIOCNOTTY, 0) == -1 && errno != ENOTTY) plog(XLOG_WARNING, "Could not disassociate tty (TIOCNOTTY): %m"); (void) close(t); } @@ -211,7 +211,7 @@ main(int argc, char *argv[]) /* * Get local machine name */ - if (gethostname(hostname, sizeof(hostname)) < 0) { + if (gethostname(hostname, sizeof(hostname)) == -1) { plog(XLOG_FATAL, "gethostname: %m"); going_down(1); } diff --git a/usr.sbin/amd/amd/rpc_fwd.c b/usr.sbin/amd/amd/rpc_fwd.c index 442912b1d36..917cf7bc421 100644 --- a/usr.sbin/amd/amd/rpc_fwd.c +++ b/usr.sbin/amd/amd/rpc_fwd.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)rpc_fwd.c 8.1 (Berkeley) 6/6/93 - * $Id: rpc_fwd.c,v 1.10 2015/09/13 15:44:47 guenther Exp $ + * $Id: rpc_fwd.c,v 1.11 2019/06/28 13:32:46 deraadt Exp $ */ /* @@ -162,7 +162,7 @@ int fwd_init() * Create ping socket */ fwd_sock = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0); - if (fwd_sock < 0) { + if (fwd_sock == -1) { plog(XLOG_ERROR, "Unable to create RPC forwarding socket: %m"); return errno; } @@ -170,7 +170,7 @@ int fwd_init() /* * Some things we talk to require a priv port - so make one here */ - if (bind_resv_port(fwd_sock, (unsigned short *) 0) < 0) + if (bind_resv_port(fwd_sock, (unsigned short *) 0) == -1) plog(XLOG_ERROR, "can't bind privileged port"); return 0; @@ -278,7 +278,7 @@ fwd_packet(int type_id, void *pkt, int len, struct sockaddr_in *fwdto, } #endif /* DEBUG */ if (sendto(fwd_sock, (char *) pkt, len, 0, - (struct sockaddr *) fwdto, sizeof(*fwdto)) < 0) + (struct sockaddr *) fwdto, sizeof(*fwdto)) == -1) error = errno; /* @@ -316,7 +316,7 @@ fwd_reply() * Determine the length of the packet */ #ifdef DYNAMIC_BUFFERS - if (ioctl(fwd_sock, FIONREAD, &len) < 0 || len < 0) { + if (ioctl(fwd_sock, FIONREAD, &len) == -1 || len < 0) { plog(XLOG_ERROR, "Error reading packet size: %m"); return; } @@ -340,9 +340,9 @@ again: src_addr_len = sizeof(src_addr); rc = recvfrom(fwd_sock, (char *) pkt, len, 0, (struct sockaddr *) &src_addr, &src_addr_len); - if (rc < 0 || src_addr_len != sizeof(src_addr) || + if (rc == -1 || src_addr_len != sizeof(src_addr) || src_addr.sin_family != AF_INET) { - if (rc < 0 && errno == EINTR) + if (rc == -1 && errno == EINTR) goto again; plog(XLOG_ERROR, "Error reading RPC reply: %m"); goto out; diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c index a4d45ef4413..69aba9a3c8a 100644 --- a/usr.sbin/apm/apm.c +++ b/usr.sbin/apm/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.35 2019/03/01 17:21:48 tedu Exp $ */ +/* $OpenBSD: apm.c,v 1.36 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 1996 John T. Kohl @@ -158,7 +158,7 @@ main(int argc, char *argv[]) int cpuspeed_mib[] = { CTL_HW, HW_CPUSPEED }, cpuspeed; size_t cpuspeed_sz = sizeof(cpuspeed); - if (sysctl(cpuspeed_mib, 2, &cpuspeed, &cpuspeed_sz, NULL, 0) < 0) + if (sysctl(cpuspeed_mib, 2, &cpuspeed, &cpuspeed_sz, NULL, 0) == -1) err(1, "sysctl hw.cpuspeed"); while ((ch = getopt(argc, argv, "ACHLlmbvaPSzZf:")) != -1) { 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"); } } diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index f2ef04aa133..cfbbcc4b218 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arp.c,v 1.82 2019/01/22 09:25:29 krw Exp $ */ +/* $OpenBSD: arp.c,v 1.83 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: arp.c,v 1.12 1995/04/24 13:25:18 cgd Exp $ */ /* @@ -245,9 +245,9 @@ getsocket(void) if (rtsock >= 0) return; rtsock = socket(AF_ROUTE, SOCK_RAW, 0); - if (rtsock < 0) + if (rtsock == -1) err(1, "routing socket"); - if (setsockopt(rtsock, AF_ROUTE, ROUTE_TABLEFILTER, &rdomain, len) < 0) + if (setsockopt(rtsock, AF_ROUTE, ROUTE_TABLEFILTER, &rdomain, len) == -1) err(1, "ROUTE_TABLEFILTER"); if (pledge("stdio dns", NULL) == -1) @@ -664,7 +664,7 @@ doit: l = rtm->rtm_msglen; rtm->rtm_seq = ++seq; rtm->rtm_type = cmd; - if (write(rtsock, (char *)&m_rtmsg, l) < 0) + if (write(rtsock, (char *)&m_rtmsg, l) == -1) if (errno != ESRCH || cmd != RTM_DELETE) { warn("writing to routing socket"); return (-1); diff --git a/usr.sbin/authpf/authpf.c b/usr.sbin/authpf/authpf.c index f8039ab0891..97cbadd3c48 100644 --- a/usr.sbin/authpf/authpf.c +++ b/usr.sbin/authpf/authpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: authpf.c,v 1.127 2018/04/26 12:42:51 guenther Exp $ */ +/* $OpenBSD: authpf.c,v 1.128 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (C) 1998 - 2007 Bob Beck (beck@openbsd.org). @@ -641,7 +641,7 @@ remove_stale_rulesets(void) memset(&prs, 0, sizeof(prs)); strlcpy(prs.path, anchorname, sizeof(prs.path)); - if (ioctl(dev, DIOCGETRULESETS, &prs)) { + if (ioctl(dev, DIOCGETRULESETS, &prs) == -1) { if (errno == EINVAL) return (0); else @@ -654,7 +654,7 @@ remove_stale_rulesets(void) pid_t pid; prs.nr = nr - 1; - if (ioctl(dev, DIOCGETRULESET, &prs)) + if (ioctl(dev, DIOCGETRULESET, &prs) == -1) return (1); errno = 0; if ((t = strchr(prs.name, '(')) == NULL) @@ -694,8 +694,8 @@ recursive_ruleset_purge(char *an, char *rs) snprintf(t_e[0].anchor, sizeof(t_e[0].anchor), "%s/%s", an, rs); t_e[1].type = PF_TRANS_TABLE; - if ((ioctl(dev, DIOCXBEGIN, t) || - ioctl(dev, DIOCXCOMMIT, t)) && + if ((ioctl(dev, DIOCXBEGIN, t) == -1|| + ioctl(dev, DIOCXCOMMIT, t) == -1) && errno != EINVAL) goto cleanup; @@ -703,7 +703,7 @@ recursive_ruleset_purge(char *an, char *rs) if ((prs = calloc(1, sizeof(struct pfioc_ruleset))) == NULL) goto no_mem; snprintf(prs->path, sizeof(prs->path), "%s/%s", an, rs); - if (ioctl(dev, DIOCGETRULESETS, prs)) { + if (ioctl(dev, DIOCGETRULESETS, prs) == -1) { if (errno != EINVAL) goto cleanup; errno = 0; @@ -712,7 +712,7 @@ recursive_ruleset_purge(char *an, char *rs) while (nr) { prs->nr = 0; - if (ioctl(dev, DIOCGETRULESET, prs)) + if (ioctl(dev, DIOCGETRULESET, prs) == -1) goto cleanup; if (recursive_ruleset_purge(prs->path, prs->name)) @@ -870,7 +870,7 @@ change_table(int add, const char *ipsrc) return (-1); } - if (ioctl(dev, add ? DIOCRADDADDRS : DIOCRDELADDRS, &io) && + if (ioctl(dev, add ? DIOCRADDADDRS : DIOCRDELADDRS, &io) == -1 && errno != ESRCH) { syslog(LOG_ERR, "cannot %s %s from table %s: %s", add ? "add" : "remove", ipsrc, tablename, @@ -910,7 +910,7 @@ authpf_kill_states(void) sizeof(psk.psk_src.addr.v.a.addr)); memset(&psk.psk_src.addr.v.a.mask, 0xff, sizeof(psk.psk_src.addr.v.a.mask)); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (ioctl(dev, DIOCKILLSTATES, &psk) == -1) syslog(LOG_ERR, "DIOCKILLSTATES failed (%m)"); /* Kill all states to ipsrc */ @@ -919,7 +919,7 @@ authpf_kill_states(void) sizeof(psk.psk_dst.addr.v.a.addr)); memset(&psk.psk_dst.addr.v.a.mask, 0xff, sizeof(psk.psk_dst.addr.v.a.mask)); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (ioctl(dev, DIOCKILLSTATES, &psk) == -1) syslog(LOG_ERR, "DIOCKILLSTATES failed (%m)"); } diff --git a/usr.sbin/bgpd/pftable.c b/usr.sbin/bgpd/pftable.c index 418af987204..b584ae259fc 100644 --- a/usr.sbin/bgpd/pftable.c +++ b/usr.sbin/bgpd/pftable.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pftable.c,v 1.12 2018/11/25 15:31:12 deraadt Exp $ */ +/* $OpenBSD: pftable.c,v 1.13 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2004 Damien Miller <djm@openbsd.org> @@ -97,7 +97,7 @@ pftable_clear(const char *name) strlcpy(tio.pfrio_table.pfrt_name, name, sizeof(tio.pfrio_table.pfrt_name)); - if (ioctl(devpf, DIOCRCLRADDRS, &tio) != 0) { + if (ioctl(devpf, DIOCRCLRADDRS, &tio) == -1) { log_warn("pftable_clear ioctl"); return (-1); } @@ -121,7 +121,7 @@ pftable_exists(const char *name) tio.pfrio_esize = sizeof(dummy); tio.pfrio_size = 1; - if (ioctl(devpf, DIOCRGETASTATS, &tio) != 0) + if (ioctl(devpf, DIOCRGETASTATS, &tio) == -1) return (-1); return (0); diff --git a/usr.sbin/config/exec_elf.c b/usr.sbin/config/exec_elf.c index 14e020f61bf..12be811ae7a 100644 --- a/usr.sbin/config/exec_elf.c +++ b/usr.sbin/config/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.16 2017/10/29 08:45:53 mpi Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.17 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 1999 Mats O Jansson. All rights reserved. @@ -97,7 +97,7 @@ loadkernel(char *file) { int fd; - if ((fd = open(file, O_RDONLY | O_EXLOCK, 0)) < 0) + if ((fd = open(file, O_RDONLY | O_EXLOCK, 0)) == -1) err(1, "%s", file); if (read(fd, (char *)&elf_ex, sizeof(elf_ex)) != sizeof(elf_ex)) @@ -140,7 +140,7 @@ savekernel(char *outfile) { int fd; - if ((fd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0700)) < 0) + if ((fd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0700)) == -1) err(1, "%s", outfile); if (write(fd, elf_total, (size_t)elf_size) != elf_size) diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c index 411d06f3308..d03eee04dbb 100644 --- a/usr.sbin/cron/atrun.c +++ b/usr.sbin/cron/atrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atrun.c,v 1.49 2019/01/25 00:19:27 millert Exp $ */ +/* $OpenBSD: atrun.c,v 1.50 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2002-2003 Todd C. Miller <millert@openbsd.org> @@ -264,7 +264,7 @@ run_job(const atjob *job, int dfd, const char *atfile) char *nargv[2], *nenvp[1]; /* Open the file and unlink it so we don't try running it again. */ - if ((fd = openat(dfd, atfile, O_RDONLY|O_NONBLOCK|O_NOFOLLOW, 0)) < 0) { + if ((fd = openat(dfd, atfile, O_RDONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1) { syslog(LOG_ERR, "(CRON) CAN'T OPEN (%s)", atfile); return; } @@ -310,7 +310,7 @@ run_job(const atjob *job, int dfd, const char *atfile) } /* Sanity checks */ - if (fstat(fd, &sb) < 0) { + if (fstat(fd, &sb) == -1) { syslog(LOG_ERR, "(%s) FSTAT FAILED (%s)", pw->pw_name, atfile); _exit(EXIT_FAILURE); } @@ -424,7 +424,7 @@ run_job(const atjob *job, int dfd, const char *atfile) syslog(LOG_INFO, "(%s) ATJOB (%s)", pw->pw_name, atfile); /* Connect grandchild's stdin to the at job file. */ - if (lseek(fd, 0, SEEK_SET) < 0) { + if (lseek(fd, 0, SEEK_SET) == -1) { syslog(LOG_ERR, "(CRON) LSEEK (%m)"); _exit(EXIT_FAILURE); } diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index d22aae2538d..6e9933af6cc 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crontab.c,v 1.92 2016/01/11 14:23:50 millert Exp $ */ +/* $OpenBSD: crontab.c,v 1.93 2019/06/28 13:32:47 deraadt Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -199,11 +199,11 @@ parse_args(int argc, char *argv[]) * the race. */ - if (setegid(user_gid) < 0) + if (setegid(user_gid) == -1) err(EXIT_FAILURE, "setegid(user_gid)"); if (!(NewCrontab = fopen(Filename, "r"))) err(EXIT_FAILURE, "%s", Filename); - if (setegid(crontab_gid) < 0) + if (setegid(crontab_gid) == -1) err(EXIT_FAILURE, "setegid(crontab_gid)"); } } @@ -279,7 +279,7 @@ edit_cmd(void) err(EXIT_FAILURE, _PATH_DEVNULL); } - if (fstat(fileno(f), &statbuf) < 0) { + if (fstat(fileno(f), &statbuf) == -1) { warn("fstat"); goto fatal; } @@ -310,7 +310,7 @@ edit_cmd(void) copy_crontab(f, NewCrontab); fclose(f); - if (fflush(NewCrontab) < 0) + if (fflush(NewCrontab) == EOF) err(EXIT_FAILURE, "%s", Filename); if (futimens(t, ts) == -1) warn("unable to set times on %s", Filename); @@ -335,7 +335,7 @@ edit_cmd(void) goto fatal; } - if (fstat(t, &statbuf) < 0) { + if (fstat(t, &statbuf) == -1) { warn("fstat"); goto fatal; } diff --git a/usr.sbin/cron/database.c b/usr.sbin/cron/database.c index e399d74f4c4..2a38a61af94 100644 --- a/usr.sbin/cron/database.c +++ b/usr.sbin/cron/database.c @@ -1,4 +1,4 @@ -/* $OpenBSD: database.c,v 1.37 2018/02/05 03:52:37 millert Exp $ */ +/* $OpenBSD: database.c,v 1.38 2019/06/28 13:32:47 deraadt Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -58,14 +58,14 @@ load_database(cron_db **db) * so that if anything changes as of this moment (i.e., before we've * cached any of the database), we'll see the changes next time. */ - if (stat(_PATH_CRON_SPOOL, &statbuf) < 0) { + if (stat(_PATH_CRON_SPOOL, &statbuf) == -1) { syslog(LOG_ERR, "(CRON) STAT FAILED (%s)", _PATH_CRON_SPOOL); return; } /* track system crontab file */ - if (stat(_PATH_SYS_CRONTAB, &syscron_stat) < 0) + if (stat(_PATH_SYS_CRONTAB, &syscron_stat) == -1) timespecclear(&syscron_stat.st_mtim); /* hash mtime of system crontab file and crontab dir @@ -184,7 +184,7 @@ process_crontab(int dfd, const char *uname, const char *fname, } fd = openat(dfd, fname, O_RDONLY|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC); - if (fd < 0) { + if (fd == -1) { /* crontab not accessible? */ syslog(LOG_ERR, "(%s) CAN'T OPEN (%s)", uname, fname); @@ -196,7 +196,7 @@ process_crontab(int dfd, const char *uname, const char *fname, goto next_crontab; } - if (fstat(fileno(crontab_fp), statbuf) < 0) { + if (fstat(fileno(crontab_fp), statbuf) == -1) { syslog(LOG_ERR, "(%s) FSTAT FAILED (%s)", uname, fname); goto next_crontab; } diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index 12cc66cc876..c0e6c5dcc90 100644 --- a/usr.sbin/cron/do_command.c +++ b/usr.sbin/cron/do_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: do_command.c,v 1.59 2018/06/13 13:30:03 tb Exp $ */ +/* $OpenBSD: do_command.c,v 1.60 2019/06/28 13:32:47 deraadt Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -206,7 +206,7 @@ child_process(entry *e, user *u) e->pwd->pw_name); _exit(EXIT_FAILURE); } - if (setusercontext(lc, e->pwd, e->pwd->pw_uid, LOGIN_SETALL) < 0) { + if (setusercontext(lc, e->pwd, e->pwd->pw_uid, LOGIN_SETALL) == -1) { warn("setusercontext failed for %s", e->pwd->pw_name); syslog(LOG_ERR, "(%s) SETUSERCONTEXT FAILED (%m)", e->pwd->pw_name); @@ -425,7 +425,7 @@ child_process(entry *e, user *u) */ int waiter; if (jobpid > 0) { - while (waitpid(jobpid, &waiter, 0) < 0 && errno == EINTR) + while (waitpid(jobpid, &waiter, 0) == -1 && errno == EINTR) ; /* If everything went well, and -n was set, _and_ we have mail, @@ -462,7 +462,7 @@ child_process(entry *e, user *u) } if (stdinjob > 0) - while (waitpid(stdinjob, &waiter, 0) < 0 && errno == EINTR) + while (waitpid(stdinjob, &waiter, 0) == -1 && errno == EINTR) ; } diff --git a/usr.sbin/cron/popen.c b/usr.sbin/cron/popen.c index f156095d837..81da171d321 100644 --- a/usr.sbin/cron/popen.c +++ b/usr.sbin/cron/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.30 2015/11/15 23:24:24 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.31 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -75,7 +75,7 @@ cron_popen(char *program, char *type, struct passwd *pw, pid_t *pidptr) if ((*type != 'r' && *type != 'w') || type[1] != '\0') return (NULL); - if (pipe(pdes) < 0) + if (pipe(pdes) == -1) return (NULL); /* break up string into pieces */ @@ -92,7 +92,7 @@ cron_popen(char *program, char *type, struct passwd *pw, pid_t *pidptr) /* NOTREACHED */ case 0: /* child */ if (pw) { - if (setusercontext(0, pw, pw->pw_uid, LOGIN_SETALL) < 0) { + if (setusercontext(0, pw, pw->pw_uid, LOGIN_SETALL) == -1) { syslog(LOG_ERR, "(%s) SETUSERCONTEXT FAILED (%m)", pw->pw_name); @@ -145,10 +145,10 @@ cron_pclose(FILE *iop, pid_t pid) sigaddset(&sigset, SIGQUIT); sigaddset(&sigset, SIGHUP); sigprocmask(SIG_BLOCK, &sigset, &osigset); - while ((rv = waitpid(pid, &status, 0)) < 0 && errno == EINTR) + while ((rv = waitpid(pid, &status, 0)) == -1 && errno == EINTR) continue; sigprocmask(SIG_SETMASK, &osigset, NULL); - if (rv < 0) + if (rv == -1) return (rv); if (WIFEXITED(status)) return (WEXITSTATUS(status)); diff --git a/usr.sbin/dhcpd/pfutils.c b/usr.sbin/dhcpd/pfutils.c index 091f372d5f5..48db8c6faa8 100644 --- a/usr.sbin/dhcpd/pfutils.c +++ b/usr.sbin/dhcpd/pfutils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfutils.c,v 1.19 2018/12/07 12:52:47 henning Exp $ */ +/* $OpenBSD: pfutils.c,v 1.20 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2006 Chris Kuethe <ckuethe@openbsd.org> * @@ -154,7 +154,7 @@ pf_change_table(int fd, int op, struct in_addr ip, char *table) addr.pfra_af = AF_INET; addr.pfra_net = 32; - if (ioctl(fd, op ? DIOCRADDADDRS : DIOCRDELADDRS, &io) && + if (ioctl(fd, op ? DIOCRADDADDRS : DIOCRDELADDRS, &io) == -1 && errno != ESRCH) { log_warn( "DIOCR%sADDRS on table %s", op ? "ADD" : "DEL", table); @@ -178,7 +178,7 @@ pf_kill_state(int fd, struct in_addr ip) sizeof(psk.psk_src.addr.v.a.addr)); memset(&psk.psk_src.addr.v.a.mask, 0xff, sizeof(psk.psk_src.addr.v.a.mask)); - if (ioctl(fd, DIOCKILLSTATES, &psk)) { + if (ioctl(fd, DIOCKILLSTATES, &psk) == -1) { log_warn("DIOCKILLSTATES failed"); } @@ -188,7 +188,7 @@ pf_kill_state(int fd, struct in_addr ip) sizeof(psk.psk_dst.addr.v.a.addr)); memset(&psk.psk_dst.addr.v.a.mask, 0xff, sizeof(psk.psk_dst.addr.v.a.mask)); - if (ioctl(fd, DIOCKILLSTATES, &psk)) { + if (ioctl(fd, DIOCKILLSTATES, &psk) == -1) { log_warn("DIOCKILLSTATES failed"); } } diff --git a/usr.sbin/dhcpd/udpsock.c b/usr.sbin/dhcpd/udpsock.c index 6f50d4712b2..ff7e4a32bdc 100644 --- a/usr.sbin/dhcpd/udpsock.c +++ b/usr.sbin/dhcpd/udpsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udpsock.c,v 1.10 2017/02/13 22:33:39 krw Exp $ */ +/* $OpenBSD: udpsock.c,v 1.11 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2014 YASUOKA Masahiko <yasuoka@openbsd.org> @@ -58,7 +58,7 @@ udpsock_startup(struct in_addr bindaddr) fatal("could not create udpsock"); memset(&sin4, 0, sizeof(sin4)); - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) + if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) fatal("creating a socket failed for udp"); onoff = 1; @@ -115,7 +115,7 @@ udpsock_handler(struct protocol *protocol) m.msg_controllen = sizeof(cbuf); memset(&iface, 0, sizeof(iface)); - if ((len = recvmsg(udpsock->sock, &m, 0)) < 0) { + if ((len = recvmsg(udpsock->sock, &m, 0)) == -1) { log_warn("receiving a DHCP message failed"); return; } @@ -137,12 +137,12 @@ udpsock_handler(struct protocol *protocol) } if_indextoname(sdl->sdl_index, ifname); - if ((sockio = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + if ((sockio = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { log_warn("socket creation failed"); return; } strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - if (ioctl(sockio, SIOCGIFADDR, &ifr, sizeof(ifr)) != 0) { + if (ioctl(sockio, SIOCGIFADDR, &ifr, sizeof(ifr)) == -1) { log_warn("Failed to get address for %s", ifname); close(sockio); return; diff --git a/usr.sbin/dvmrpd/interface.c b/usr.sbin/dvmrpd/interface.c index 76bf469d749..33156463fa9 100644 --- a/usr.sbin/dvmrpd/interface.c +++ b/usr.sbin/dvmrpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.11 2015/09/27 17:29:46 stsp Exp $ */ +/* $OpenBSD: interface.c,v 1.12 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -182,7 +182,7 @@ if_new(struct kif *kif) /* set up ifreq */ strlcpy(ifr->ifr_name, kif->ifname, sizeof(ifr->ifr_name)); - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) err(1, "if_new: socket"); /* get type */ @@ -201,20 +201,20 @@ if_new(struct kif *kif) iface->baudrate = kif->baudrate; /* get address */ - if (ioctl(s, SIOCGIFADDR, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFADDR, (caddr_t)ifr) == -1) err(1, "if_new: cannot get address"); sain = (struct sockaddr_in *) &ifr->ifr_addr; iface->addr = sain->sin_addr; /* get mask */ - if (ioctl(s, SIOCGIFNETMASK, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFNETMASK, (caddr_t)ifr) == -1) err(1, "if_new: cannot get mask"); sain = (struct sockaddr_in *) &ifr->ifr_addr; iface->mask = sain->sin_addr; /* get p2p dst address */ if (iface->type == IF_TYPE_POINTOPOINT) { - if (ioctl(s, SIOCGIFDSTADDR, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFDSTADDR, (caddr_t)ifr) == -1) err(1, "if_new: cannot get dst addr"); sain = (struct sockaddr_in *) &ifr->ifr_addr; iface->dst = sain->sin_addr; @@ -513,7 +513,7 @@ int if_set_mcast_ttl(int fd, u_int8_t ttl) { if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, - (char *)&ttl, sizeof(ttl)) < 0) { + (char *)&ttl, sizeof(ttl)) == -1) { log_warn("if_set_mcast_ttl: error setting " "IP_MULTICAST_TTL to %d", ttl); return (-1); @@ -526,7 +526,7 @@ int if_set_tos(int fd, int tos) { if (setsockopt(fd, IPPROTO_IP, IP_TOS, - (int *)&tos, sizeof(tos)) < 0) { + (int *)&tos, sizeof(tos)) == -1) { log_warn("if_set_tos: error setting IP_TOS to 0x%x", tos); return (-1); } @@ -557,7 +557,7 @@ if_join_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = iface->addr.s_addr; if (setsockopt(iface->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, - (void *)&mreq, sizeof(mreq)) < 0) { + (void *)&mreq, sizeof(mreq)) == -1) { log_debug("if_join_group: error IP_ADD_MEMBERSHIP, " "interface %s", iface->name); return (-1); @@ -582,7 +582,7 @@ if_leave_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = iface->addr.s_addr; if (setsockopt(iface->fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, - (void *)&mreq, sizeof(mreq)) < 0) { + (void *)&mreq, sizeof(mreq)) == -1) { log_debug("if_leave_group: error IP_DROP_MEMBERSHIP, " "interface %s", iface->name); return (-1); @@ -603,7 +603,7 @@ if_set_mcast(struct iface *iface) case IF_TYPE_BROADCAST: if (setsockopt(iface->fd, IPPROTO_IP, IP_MULTICAST_IF, (char *)&iface->addr.s_addr, - sizeof(iface->addr.s_addr)) < 0) { + sizeof(iface->addr.s_addr)) == -1) { log_debug("if_set_mcast: error setting " "IP_MULTICAST_IF, interface %s", iface->name); return (-1); @@ -622,7 +622,7 @@ if_set_mcast_loop(int fd) u_int8_t loop = 0; if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, - (char *)&loop, sizeof(loop)) < 0) { + (char *)&loop, sizeof(loop)) == -1) { log_warn("if_set_mcast_loop: error setting IP_MULTICAST_LOOP"); return (-1); } diff --git a/usr.sbin/dvmrpd/kmroute.c b/usr.sbin/dvmrpd/kmroute.c index 891f630e27a..8a811ac2182 100644 --- a/usr.sbin/dvmrpd/kmroute.c +++ b/usr.sbin/dvmrpd/kmroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kmroute.c,v 1.2 2010/05/26 13:56:07 nicm Exp $ */ +/* $OpenBSD: kmroute.c,v 1.3 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> @@ -153,7 +153,7 @@ mrt_init(int fd) int flag = 1; if (setsockopt(fd, IPPROTO_IP, MRT_INIT, &flag, - sizeof(flag)) < 0) { + sizeof(flag)) == -1) { log_warn("mrt_init: error setting MRT_INIT"); return (-1); } @@ -167,7 +167,7 @@ mrt_done(int fd) int flag = 0; if (setsockopt(fd, IPPROTO_IP, MRT_DONE, &flag, - sizeof(flag)) < 0) { + sizeof(flag)) == -1) { log_warn("mrt_done: error setting MRT_DONE"); return (-1); } @@ -188,7 +188,7 @@ mrt_add_vif(int fd, struct iface *iface) vc.vifc_rmt_addr.s_addr = 0; if (setsockopt(fd, IPPROTO_IP, MRT_ADD_VIF, &vc, - sizeof(vc)) < 0) { + sizeof(vc)) == -1) { log_warn("mrt_add_vif: error adding VIF"); return (-1); } @@ -204,7 +204,7 @@ mrt_del_vif(int fd, struct iface *iface) vifi = iface->ifindex; if (setsockopt(fd, IPPROTO_IP, MRT_DEL_VIF, &vifi, - sizeof(vifi)) < 0) + sizeof(vifi)) == -1) log_warn("mrt_del_vif: error deleting VIF"); } @@ -226,7 +226,7 @@ mrt_add_mfc(int fd, struct mfc *mfc) } if (setsockopt(fd, IPPROTO_IP, MRT_ADD_MFC, &mc, sizeof(mc)) - < 0) { + == -1) { log_warnx("mrt_add_mfc: error adding group %s to interface %d", inet_ntoa(mfc->group), mfc->ifindex); return (-1); @@ -246,7 +246,7 @@ mrt_del_mfc(int fd, struct mfc *mfc) mc.mfcc_mcastgrp = mfc->group; if (setsockopt(fd, IPPROTO_IP, MRT_DEL_MFC, &mc, sizeof(mc)) - < 0) { + == -1) { log_warnx("mrt_del_mfc: error deleting group %s ", inet_ntoa(mfc->group)); return (-1); diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index 402c5511424..69ab46ecfae 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -266,9 +266,9 @@ getprivs(u_int id, int quotatype) "group %s not known, skipping %s\n", quotagroup, fs->fs_file); } - if ((fd = open(qfpathname, O_RDONLY)) < 0) { + if ((fd = open(qfpathname, O_RDONLY)) == -1) { fd = open(qfpathname, O_RDWR|O_CREAT, 0640); - if (fd < 0 && errno != ENOENT) { + if (fd == -1 && errno != ENOENT) { perror(qfpathname); free(qup); continue; @@ -327,7 +327,7 @@ putprivs(long id, int quotatype, struct quotause *quplist) for (qup = quplist; qup; qup = qup->next) { if (quotactl(qup->fsname, qcmd, id, (char *)&qup->dqblk) == 0) continue; - if ((fd = open(qup->qfname, O_WRONLY)) < 0) { + if ((fd = open(qup->qfname, O_WRONLY)) == -1) { perror(qup->qfname); } else { lseek(fd, (off_t)(id * sizeof (struct dqblk)), SEEK_SET); diff --git a/usr.sbin/eeprom/ophandlers.c b/usr.sbin/eeprom/ophandlers.c index 751fb68a294..cf695e7f6c7 100644 --- a/usr.sbin/eeprom/ophandlers.c +++ b/usr.sbin/eeprom/ophandlers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ophandlers.c,v 1.14 2015/08/20 22:39:29 deraadt Exp $ */ +/* $OpenBSD: ophandlers.c,v 1.15 2019/06/28 13:32:47 deraadt Exp $ */ /* $NetBSD: ophandlers.c,v 1.2 1996/02/28 01:13:30 thorpej Exp $ */ /*- @@ -79,7 +79,7 @@ op_handler(char *keyword, char *arg) char opio_buf[BUFSIZE]; int fd, optnode; - if ((fd = open(path_openprom, arg ? O_RDWR : O_RDONLY, 0640)) < 0) + if ((fd = open(path_openprom, arg ? O_RDWR : O_RDONLY, 0640)) == -1) BARF(path_openprom, strerror(errno)); /* Check to see if it's a special-case keyword. */ @@ -87,7 +87,7 @@ op_handler(char *keyword, char *arg) if (strcmp(ex->ex_keyword, keyword) == 0) break; - if (ioctl(fd, OPIOCGETOPTNODE, (char *)&optnode) < 0) + if (ioctl(fd, OPIOCGETOPTNODE, (char *)&optnode) == -1) BARF("OPIOCGETOPTNODE", strerror(errno)); bzero(&opio_buf[0], sizeof(opio_buf)); @@ -102,7 +102,7 @@ op_handler(char *keyword, char *arg) opio.op_buf = &opio_buf[0]; opio.op_buflen = sizeof(opio_buf); - if (ioctl(fd, OPIOCGET, (char *)&opio) < 0) + if (ioctl(fd, OPIOCGET, (char *)&opio) == -1) BARF("OPIOCGET", strerror(errno)); if (opio.op_buflen <= 0) { @@ -123,7 +123,7 @@ op_handler(char *keyword, char *arg) opio.op_buflen = strlen(arg); } - if (ioctl(fd, OPIOCSET, (char *)&opio) < 0) + if (ioctl(fd, OPIOCSET, (char *)&opio) == -1) BARF("invalid keyword", keyword); if (verbose) { @@ -136,7 +136,7 @@ op_handler(char *keyword, char *arg) } else { opio.op_buf = &opio_buf[0]; opio.op_buflen = sizeof(opio_buf); - if (ioctl(fd, OPIOCGET, (char *)&opio) < 0) + if (ioctl(fd, OPIOCGET, (char *)&opio) == -1) BARF("OPIOCGET", strerror(errno)); if (opio.op_buflen <= 0) { @@ -178,10 +178,10 @@ op_dump(void) char buf1[BUFSIZE], buf2[BUFSIZE], buf3[BUFSIZE], buf4[BUFSIZE]; int fd, optnode; - if ((fd = open(path_openprom, O_RDONLY, 0640)) < 0) + if ((fd = open(path_openprom, O_RDONLY, 0640)) == -1) err(1, "open: %s", path_openprom); - if (ioctl(fd, OPIOCGETOPTNODE, (char *)&optnode) < 0) + if (ioctl(fd, OPIOCGETOPTNODE, (char *)&optnode) == -1) err(1, "OPIOCGETOPTNODE"); bzero(&opio1, sizeof(opio1)); @@ -213,7 +213,7 @@ op_dump(void) opio1.op_namelen = strlen(opio1.op_name); opio1.op_buflen = sizeof(buf2); - if (ioctl(fd, OPIOCNEXTPROP, (char *)&opio1) < 0) + if (ioctl(fd, OPIOCNEXTPROP, (char *)&opio1) == -1) err(1, "ioctl: OPIOCNEXTPROP"); /* @@ -233,7 +233,7 @@ op_dump(void) bzero(opio2.op_buf, sizeof(buf4)); opio2.op_buflen = sizeof(buf4); - if (ioctl(fd, OPIOCGET, (char *)&opio2) < 0) + if (ioctl(fd, OPIOCGET, (char *)&opio2) == -1) err(1, "ioctl: OPIOCGET"); for (ex = opextab; ex->ex_keyword != NULL; ++ex) diff --git a/usr.sbin/eeprom/optree.c b/usr.sbin/eeprom/optree.c index 25b5c7257be..2d47123a95b 100644 --- a/usr.sbin/eeprom/optree.c +++ b/usr.sbin/eeprom/optree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: optree.c,v 1.9 2017/10/20 10:32:03 kettenis Exp $ */ +/* $OpenBSD: optree.c,v 1.10 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2007 Federico G. Schwindt <fgsch@openbsd.org> @@ -120,7 +120,7 @@ op_nodes(int fd, int node, int depth) opio.op_name = op_name; if (!node) { - if (ioctl(fd, OPIOCGETNEXT, &opio) < 0) + if (ioctl(fd, OPIOCGETNEXT, &opio) == -1) err(1, "OPIOCGETNEXT"); node = opio.op_nodeid; } else @@ -133,7 +133,7 @@ op_nodes(int fd, int node, int depth) opio.op_namelen = sizeof(op_name); /* Get the next property. */ - if (ioctl(fd, OPIOCNEXTPROP, &opio) < 0) + if (ioctl(fd, OPIOCNEXTPROP, &opio) == -1) err(1, "OPIOCNEXTPROP"); op_buf[opio.op_buflen] = '\0'; @@ -148,7 +148,7 @@ op_nodes(int fd, int node, int depth) opio.op_buflen = sizeof(op_buf); /* And its value. */ - if (ioctl(fd, OPIOCGET, &opio) < 0) { + if (ioctl(fd, OPIOCGET, &opio) == -1) { if (errno != ENOMEM) err(1, "OPIOCGET"); @@ -159,14 +159,14 @@ op_nodes(int fd, int node, int depth) } /* Get next child. */ - if (ioctl(fd, OPIOCGETCHILD, &opio) < 0) + if (ioctl(fd, OPIOCGETCHILD, &opio) == -1) err(1, "OPIOCGETCHILD"); if (opio.op_nodeid) op_nodes(fd, opio.op_nodeid, depth + 1); /* Get next node/sibling. */ opio.op_nodeid = node; - if (ioctl(fd, OPIOCGETNEXT, &opio) < 0) + if (ioctl(fd, OPIOCGETNEXT, &opio) == -1) err(1, "OPIOCGETNEXT"); if (opio.op_nodeid) op_nodes(fd, opio.op_nodeid, depth); @@ -177,7 +177,7 @@ op_tree(void) { int fd; - if ((fd = open(path_openprom, O_RDONLY, 0640)) < 0) + if ((fd = open(path_openprom, O_RDONLY, 0640)) == -1) err(1, "open: %s", path_openprom); op_nodes(fd, 0, 0); (void)close(fd); diff --git a/usr.sbin/eigrpd/interface.c b/usr.sbin/eigrpd/interface.c index 6075cc93cad..438805e2edd 100644 --- a/usr.sbin/eigrpd/interface.c +++ b/usr.sbin/eigrpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.24 2017/02/22 14:24:50 renato Exp $ */ +/* $OpenBSD: interface.c,v 1.25 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -562,7 +562,7 @@ if_join_ipv4_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = if_primary_addr(iface); if (setsockopt(global.eigrp_socket_v4, IPPROTO_IP, IP_ADD_MEMBERSHIP, - (void *)&mreq, sizeof(mreq)) < 0) { + (void *)&mreq, sizeof(mreq)) == -1) { log_warn("%s: error IP_ADD_MEMBERSHIP, interface %s address %s", __func__, iface->name, inet_ntoa(*addr)); return (-1); @@ -587,7 +587,7 @@ if_leave_ipv4_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = if_primary_addr(iface); if (setsockopt(global.eigrp_socket_v4, IPPROTO_IP, IP_DROP_MEMBERSHIP, - (void *)&mreq, sizeof(mreq)) < 0) { + (void *)&mreq, sizeof(mreq)) == -1) { log_warn("%s: error IP_DROP_MEMBERSHIP, interface %s " "address %s", iface->name, __func__, inet_ntoa(*addr)); return (-1); @@ -600,7 +600,7 @@ int if_set_ipv4_mcast_ttl(int fd, uint8_t ttl) { if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, - (char *)&ttl, sizeof(ttl)) < 0) { + (char *)&ttl, sizeof(ttl)) == -1) { log_warn("%s: error setting IP_MULTICAST_TTL to %d", __func__, ttl); return (-1); @@ -617,7 +617,7 @@ if_set_ipv4_mcast(struct iface *iface) addr = if_primary_addr(iface); if (setsockopt(global.eigrp_socket_v4, IPPROTO_IP, IP_MULTICAST_IF, - &addr, sizeof(addr)) < 0) { + &addr, sizeof(addr)) == -1) { log_warn("%s: error setting IP_MULTICAST_IF, interface %s", __func__, iface->name); return (-1); @@ -632,7 +632,7 @@ if_set_ipv4_mcast_loop(int fd) uint8_t loop = 0; if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, - (char *)&loop, sizeof(loop)) < 0) { + (char *)&loop, sizeof(loop)) == -1) { log_warn("%s: error setting IP_MULTICAST_LOOP", __func__); return (-1); } @@ -644,7 +644,7 @@ int if_set_ipv4_recvif(int fd, int enable) { if (setsockopt(fd, IPPROTO_IP, IP_RECVIF, &enable, - sizeof(enable)) < 0) { + sizeof(enable)) == -1) { log_warn("%s: error setting IP_RECVIF", __func__); return (-1); } @@ -656,7 +656,7 @@ if_set_ipv4_hdrincl(int fd) { int hincl = 1; - if (setsockopt(fd, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof(hincl)) < 0) { + if (setsockopt(fd, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof(hincl)) == -1) { log_warn("%s: error setting IP_HDRINCL", __func__); return (-1); } @@ -680,7 +680,7 @@ if_join_ipv6_group(struct iface *iface, struct in6_addr *addr) mreq.ipv6mr_interface = iface->ifindex; if (setsockopt(global.eigrp_socket_v6, IPPROTO_IPV6, IPV6_JOIN_GROUP, - &mreq, sizeof(mreq)) < 0) { + &mreq, sizeof(mreq)) == -1) { log_warn("%s: error IPV6_JOIN_GROUP, interface %s address %s", __func__, iface->name, log_in6addr(addr)); return (-1); @@ -705,7 +705,7 @@ if_leave_ipv6_group(struct iface *iface, struct in6_addr *addr) mreq.ipv6mr_interface = iface->ifindex; if (setsockopt(global.eigrp_socket_v6, IPPROTO_IPV6, IPV6_LEAVE_GROUP, - (void *)&mreq, sizeof(mreq)) < 0) { + (void *)&mreq, sizeof(mreq)) == -1) { log_warn("%s: error IPV6_LEAVE_GROUP, interface %s address %s", __func__, iface->name, log_in6addr(addr)); return (-1); @@ -718,7 +718,7 @@ int if_set_ipv6_mcast(struct iface *iface) { if (setsockopt(global.eigrp_socket_v6, IPPROTO_IPV6, IPV6_MULTICAST_IF, - &iface->ifindex, sizeof(iface->ifindex)) < 0) { + &iface->ifindex, sizeof(iface->ifindex)) == -1) { log_warn("%s: error setting IPV6_MULTICAST_IF, interface %s", __func__, iface->name); return (-1); @@ -733,7 +733,7 @@ if_set_ipv6_mcast_loop(int fd) unsigned int loop = 0; if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, - (unsigned int *)&loop, sizeof(loop)) < 0) { + (unsigned int *)&loop, sizeof(loop)) == -1) { log_warn("%s: error setting IPV6_MULTICAST_LOOP", __func__); return (-1); } @@ -745,7 +745,7 @@ int if_set_ipv6_pktinfo(int fd, int enable) { if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &enable, - sizeof(enable)) < 0) { + sizeof(enable)) == -1) { log_warn("%s: error setting IPV6_RECVPKTINFO", __func__); return (-1); } @@ -757,7 +757,7 @@ int if_set_ipv6_dscp(int fd, int dscp) { if (setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &dscp, - sizeof(dscp)) < 0) { + sizeof(dscp)) == -1) { log_warn("%s: error setting IPV6_TCLASS", __func__); return (-1); } diff --git a/usr.sbin/fdformat/fdformat.c b/usr.sbin/fdformat/fdformat.c index ebc2f7188a6..2b1603c3779 100644 --- a/usr.sbin/fdformat/fdformat.c +++ b/usr.sbin/fdformat/fdformat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdformat.c,v 1.23 2018/09/17 15:44:16 jmc Exp $ */ +/* $OpenBSD: fdformat.c,v 1.24 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden @@ -88,7 +88,7 @@ format_track(int fd, int cyl, int secs, int head, int rate, int gaplen, f.fd_formb_secno(i) = il[i+1]; f.fd_formb_secsize(i) = secsize; } - if (ioctl(fd, FD_FORM, (caddr_t)&f) < 0) + if (ioctl(fd, FD_FORM, (caddr_t)&f) == -1) err(1, "FD_FORM"); } @@ -99,7 +99,7 @@ verify_track(int fd, int track, int tracksize) static int bufsz = 0; int fdopts = -1, ofdopts, rv = 0; - if (ioctl(fd, FD_GOPTS, &fdopts) < 0) + if (ioctl(fd, FD_GOPTS, &fdopts) == -1) warn("FD_GOPTS"); else { ofdopts = fdopts; @@ -118,7 +118,7 @@ verify_track(int fd, int track, int tracksize) fprintf (stderr, "\nfdformat: out of memory\n"); exit (2); } - if (lseek (fd, (off_t) track*tracksize, SEEK_SET) < 0) + if (lseek (fd, (off_t) track*tracksize, SEEK_SET) == -1) rv = -1; /* try twice reading it, without using the normal retrier */ else if (read (fd, buf, tracksize) != tracksize @@ -243,10 +243,10 @@ main(int argc, char *argv[]) if (optind != argc - 1) usage(); - if ((fd = opendev(argv[optind], O_RDWR, OPENDEV_PART, &devname)) < 0) + if ((fd = opendev(argv[optind], O_RDWR, OPENDEV_PART, &devname)) == -1) err(1, "%s", devname); - if (ioctl(fd, FD_GTYPE, &fdt) < 0) + if (ioctl(fd, FD_GTYPE, &fdt) == -1) errx(1, "not a floppy disk: %s", devname); switch (rate) { diff --git a/usr.sbin/ftp-proxy/ftp-proxy.c b/usr.sbin/ftp-proxy/ftp-proxy.c index 611bb6b02f9..d986d27fd76 100644 --- a/usr.sbin/ftp-proxy/ftp-proxy.c +++ b/usr.sbin/ftp-proxy/ftp-proxy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp-proxy.c,v 1.36 2016/09/26 17:15:19 jca Exp $ */ +/* $OpenBSD: ftp-proxy.c,v 1.37 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl> @@ -394,7 +394,7 @@ handle_connection(const int listen_fd, short event, void *arg) */ client_sa = sstosa(&tmp_ss); len = sizeof(struct sockaddr_storage); - if ((client_fd = accept(listen_fd, client_sa, &len)) < 0) { + if ((client_fd = accept(listen_fd, client_sa, &len)) == -1) { logmsg(LOG_CRIT, "accept() failed: %s", strerror(errno)); /* @@ -444,7 +444,7 @@ handle_connection(const int listen_fd, short event, void *arg) * Find out the real server and port that the client wanted. */ len = sizeof(struct sockaddr_storage); - if (getsockname(s->client_fd, server_sa, &len) < 0) { + if (getsockname(s->client_fd, server_sa, &len) == -1) { logmsg(LOG_CRIT, "#%d getsockname failed: %s", s->id, strerror(errno)); goto fail; @@ -468,7 +468,7 @@ handle_connection(const int listen_fd, short event, void *arg) * Setup socket and connect to server. */ if ((s->server_fd = socket(server_sa->sa_family, SOCK_STREAM, - IPPROTO_TCP)) < 0) { + IPPROTO_TCP)) == -1) { logmsg(LOG_CRIT, "#%d server socket failed: %s", s->id, strerror(errno)); goto fail; @@ -487,7 +487,7 @@ handle_connection(const int listen_fd, short event, void *arg) s->id, strerror(errno)); goto fail; } - if (connect(s->server_fd, server_sa, server_sa->sa_len) < 0 && + if (connect(s->server_fd, server_sa, server_sa->sa_len) == -1 && errno != EINPROGRESS) { logmsg(LOG_CRIT, "#%d proxy cannot connect to server %s: %s", s->id, sock_ntop(server_sa), strerror(errno)); @@ -495,7 +495,7 @@ handle_connection(const int listen_fd, short event, void *arg) } len = sizeof(struct sockaddr_storage); - if ((getsockname(s->server_fd, proxy_to_server_sa, &len)) < 0) { + if ((getsockname(s->server_fd, proxy_to_server_sa, &len)) == -1) { logmsg(LOG_CRIT, "#%d getsockname failed: %s", s->id, strerror(errno)); goto fail; @@ -905,7 +905,7 @@ proxy_reply(int cmd, struct sockaddr *sa, u_int16_t port) break; } - if (r < 0 || r >= sizeof linebuf) { + if (r == -1 || r >= sizeof linebuf) { logmsg(LOG_ERR, "proxy_reply failed: %d", r); linebuf[0] = '\0'; linelen = 0; diff --git a/usr.sbin/hostapd/hostapd.c b/usr.sbin/hostapd/hostapd.c index 2808d3f57e1..49085569573 100644 --- a/usr.sbin/hostapd/hostapd.c +++ b/usr.sbin/hostapd/hostapd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hostapd.c,v 1.39 2019/05/10 01:29:31 guenther Exp $ */ +/* $OpenBSD: hostapd.c,v 1.40 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -281,7 +281,7 @@ hostapd_udp_init(struct hostapd_config *cfg) "%s: %s\n", IAPP_MCASTADDR, strerror(errno)); if (setsockopt(iapp->i_udp, IPPROTO_IP, IP_MULTICAST_TTL, - &iapp->i_ttl, sizeof(iapp->i_ttl)) < 0) + &iapp->i_ttl, sizeof(iapp->i_ttl)) == -1) hostapd_fatal("failed to set multicast ttl to " "%u: %s\n", iapp->i_ttl, strerror(errno)); diff --git a/usr.sbin/hostapd/privsep.c b/usr.sbin/hostapd/privsep.c index 5144e267cb5..83de6d8a468 100644 --- a/usr.sbin/hostapd/privsep.c +++ b/usr.sbin/hostapd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.26 2019/05/10 01:29:31 guenther Exp $ */ +/* $OpenBSD: privsep.c,v 1.27 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -107,7 +107,7 @@ hostapd_priv_init(struct hostapd_config *cfg) if (socketpair(AF_LOCAL, SOCK_STREAM, PF_UNSPEC, socks) == -1) hostapd_fatal("failed to get socket pair\n"); - if ((child_pid = fork()) < 0) + if ((child_pid = fork()) == -1) hostapd_fatal("failed to fork child process\n"); /* @@ -287,7 +287,7 @@ hostapd_priv(int fd, short sig, void *arg) SIOCS80211NODE : SIOCS80211DELNODE; /* Try to add/delete a station from the APME */ - if ((ret = ioctl(cfg->c_apme_ctl, request, &nr)) != 0) + if ((ret = ioctl(cfg->c_apme_ctl, request, &nr)) == -1) ret = errno; hostapd_must_write(fd, &ret, sizeof(int)); diff --git a/usr.sbin/hostapd/roaming.c b/usr.sbin/hostapd/roaming.c index 9d43112445d..43848953d5f 100644 --- a/usr.sbin/hostapd/roaming.c +++ b/usr.sbin/hostapd/roaming.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roaming.c,v 1.7 2019/05/10 01:29:31 guenther Exp $ */ +/* $OpenBSD: roaming.c,v 1.8 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -172,7 +172,7 @@ hostapd_roaming_addr(struct hostapd_apme *apme, struct hostapd_inaddr *addr, } (void)strlcpy(ifra.ifra_name, apme->a_iface, sizeof(ifra.ifra_name)); - if (ioctl(cfg->c_apme_ctl, SIOCDIFADDR, &ifra) < 0) { + if (ioctl(cfg->c_apme_ctl, SIOCDIFADDR, &ifra) == -1) { if (errno != EADDRNOTAVAIL) { hostapd_log(HOSTAPD_LOG_VERBOSE, "%s/%s: failed to delete address %s", @@ -181,7 +181,7 @@ hostapd_roaming_addr(struct hostapd_apme *apme, struct hostapd_inaddr *addr, return (errno); } } - if (add && ioctl(cfg->c_apme_ctl, SIOCAIFADDR, &ifra) < 0) { + if (add && ioctl(cfg->c_apme_ctl, SIOCAIFADDR, &ifra) == -1) { if (errno != EEXIST) { hostapd_log(HOSTAPD_LOG_VERBOSE, "%s/%s: failed to add address %s", diff --git a/usr.sbin/hostctl/hostctl.c b/usr.sbin/hostctl/hostctl.c index dbaf1eb0d6c..f0639dd55f3 100644 --- a/usr.sbin/hostctl/hostctl.c +++ b/usr.sbin/hostctl/hostctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hostctl.c,v 1.4 2018/07/03 16:42:51 sf Exp $ */ +/* $OpenBSD: hostctl.c,v 1.5 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2016 Reyk Floeter <reyk@openbsd.org> @@ -143,7 +143,7 @@ main(int argc, char *argv[]) err(1, "calloc"); if (tflag) { - if (ioctl(fd, PVBUSIOC_TYPE, &pvr, sizeof(pvr)) != 0) + if (ioctl(fd, PVBUSIOC_TYPE, &pvr, sizeof(pvr)) == -1) err(1, "ioctl"); /* The returned type should be a simple single-line key */ @@ -184,7 +184,7 @@ main(int argc, char *argv[]) err(1, "open: %s", path_pvbus); } - if ((ret = ioctl(fd, cmd, &pvr, sizeof(pvr))) != 0) + if ((ret = ioctl(fd, cmd, &pvr, sizeof(pvr))) == -1) err(1, "ioctl"); if (!qflag && strlen(pvr.pvr_value)) { diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y index ead70654e87..054302269f4 100644 --- a/usr.sbin/httpd/parse.y +++ b/usr.sbin/httpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.112 2019/05/08 19:57:45 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.113 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2007 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -2338,7 +2338,7 @@ is_if_in_group(const char *ifname, const char *groupname) int s; int ret = 0; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) err(1, "socket"); memset(&ifgr, 0, sizeof(ifgr)); diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index daedde16551..577c9c7150e 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.118 2019/02/19 11:37:26 pirofti Exp $ */ +/* $OpenBSD: server.c,v 1.119 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -821,7 +821,7 @@ server_tls_readcb(int fd, short event, void *arg) ret = tls_read(clt->clt_tls_ctx, rbuf, howmuch); if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT) { goto retry; - } else if (ret < 0) { + } else if (ret == -1) { what |= EVBUFFER_ERROR; goto err; } @@ -881,7 +881,7 @@ server_tls_writecb(int fd, short event, void *arg) EVBUFFER_LENGTH(bufev->output)); if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT) { goto retry; - } else if (ret < 0) { + } else if (ret == -1) { what |= EVBUFFER_ERROR; goto err; } diff --git a/usr.sbin/ifstated/ifstated.c b/usr.sbin/ifstated/ifstated.c index c35984c479f..225f5aaa9e0 100644 --- a/usr.sbin/ifstated/ifstated.c +++ b/usr.sbin/ifstated/ifstated.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifstated.c,v 1.63 2019/01/22 09:25:29 krw Exp $ */ +/* $OpenBSD: ifstated.c,v 1.64 2019/06/28 13:32:47 deraadt Exp $ */ /* * Copyright (c) 2004 Marco Pfatschbacher <mpf@openbsd.org> @@ -148,7 +148,7 @@ main(int argc, char *argv[]) log_init(debug, LOG_DAEMON); log_setverbose(opts & IFSD_OPT_VERBOSE); - if ((rt_fd = socket(AF_ROUTE, SOCK_RAW, 0)) < 0) + if ((rt_fd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) fatal("no routing socket"); rtfilter = ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_IFANNOUNCE); @@ -328,7 +328,7 @@ external_exec(struct ifsd_external *external, int async) argp[2] = external->command; log_debug("running %s", external->command); pid = fork(); - if (pid < 0) { + if (pid == -1) { log_warn("fork error"); } else if (pid == 0) { execv(_PATH_BSHELL, argp); diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index a5372aaae12..4627ef81148 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inetd.c,v 1.160 2018/10/15 11:29:27 florian Exp $ */ +/* $OpenBSD: inetd.c,v 1.161 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 1983,1991 The Regents of the University of California. @@ -356,7 +356,7 @@ main(int argc, char *argv[]) openlog("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON); - if (getrlimit(RLIMIT_NOFILE, &rlim_nofile) < 0) { + if (getrlimit(RLIMIT_NOFILE, &rlim_nofile) == -1) { syslog(LOG_ERR, "getrlimit: %m"); } else { rlim_nofile_cur = rlim_nofile.rlim_cur; @@ -399,7 +399,7 @@ gettcp(int fd, short events, void *xsep) ctrl = accept(sep->se_fd, NULL, NULL); if (debug) fprintf(stderr, "accept, ctrl %d\n", ctrl); - if (ctrl < 0) { + if (ctrl == -1) { if (errno != EWOULDBLOCK && errno != EINTR && errno != ECONNABORTED) syslog(LOG_WARNING, "accept (for %s): %m", @@ -412,7 +412,7 @@ gettcp(int fd, short events, void *xsep) socklen_t plen = sizeof(peer); char sbuf[NI_MAXSERV]; - if (getpeername(ctrl, (struct sockaddr *)&peer, &plen) < 0) { + if (getpeername(ctrl, (struct sockaddr *)&peer, &plen) == -1) { syslog(LOG_WARNING, "could not getpeername"); close(ctrl); return; @@ -484,7 +484,7 @@ dg_broadcast(struct in_addr *in) struct ifaddrs *ifa, *ifap; struct sockaddr_in *sin; - if (getifaddrs(&ifap) < 0) + if (getifaddrs(&ifap) == -1) return (0); for (ifa = ifap; ifa; ifa = ifa->ifa_next) { if (ifa->ifa_addr->sa_family != AF_INET || @@ -814,7 +814,7 @@ setup(struct servtab *sep) int r; mode_t mask = 0; - if ((sep->se_fd = socket(sep->se_family, sep->se_socktype, 0)) < 0) { + if ((sep->se_fd = socket(sep->se_family, sep->se_socktype, 0)) == -1) { syslog(LOG_ERR, "%s/%s: socket: %m", sep->se_service, sep->se_proto); return; @@ -862,7 +862,7 @@ setsockopt(fd, SOL_SOCKET, opt, &on, sizeof (on)) if (sep->se_family == AF_UNIX) umask(mask); } - if (r < 0) { + if (r == -1) { syslog(LOG_ERR, "%s/%s: bind: %m", sep->se_service, sep->se_proto); (void) close(sep->se_fd); @@ -906,7 +906,7 @@ register_rpc(struct servtab *sep) return; } n = sizeof sin; - if (getsockname(sep->se_fd, (struct sockaddr *)&sin, &n) < 0) { + if (getsockname(sep->se_fd, (struct sockaddr *)&sin, &n) == -1) { syslog(LOG_ERR, "%s/%s: getsockname: %m", sep->se_service, sep->se_proto); return; @@ -1115,7 +1115,7 @@ more: /* check if the family is supported */ s = socket(sep->se_family, SOCK_DGRAM, 0); - if (s < 0) { + if (s == -1) { syslog(LOG_WARNING, "%s/%s: %s: the address family is " "not supported by the kernel", sep->se_service, sep->se_proto, sep->se_hostaddr); @@ -1412,7 +1412,7 @@ bump_nofile(void) struct rlimit rl; - if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { + if (getrlimit(RLIMIT_NOFILE, &rl) == -1) { syslog(LOG_ERR, "getrlimit: %m"); return -1; } @@ -1425,7 +1425,7 @@ bump_nofile(void) return -1; } - if (setrlimit(RLIMIT_NOFILE, &rl) < 0) { + if (setrlimit(RLIMIT_NOFILE, &rl) == -1) { syslog(LOG_ERR, "setrlimit: %m"); return -1; } @@ -1462,7 +1462,7 @@ echo_dg(int s, struct servtab *sep) size = sizeof(ss); if ((i = recvfrom(s, buffer, sizeof(buffer), 0, - (struct sockaddr *)&ss, &size)) < 0) + (struct sockaddr *)&ss, &size)) == -1) return; if (dg_badinput((struct sockaddr *)&ss)) return; @@ -1553,7 +1553,7 @@ chargen_dg(int s, struct servtab *sep) size = sizeof(ss); if (recvfrom(s, text, sizeof(text), 0, (struct sockaddr *)&ss, - &size) < 0) + &size) == -1) return; if (dg_badinput((struct sockaddr *)&ss)) return; @@ -1583,7 +1583,7 @@ machtime(void) { struct timeval tv; - if (gettimeofday(&tv, NULL) < 0) + if (gettimeofday(&tv, NULL) == -1) return (0L); return (htonl((u_int32_t)tv.tv_sec + 2208988800UL)); @@ -1607,7 +1607,7 @@ machtime_dg(int s, struct servtab *sep) size = sizeof(ss); if (recvfrom(s, &result, sizeof(result), 0, - (struct sockaddr *)&ss, &size) < 0) + (struct sockaddr *)&ss, &size) == -1) return; if (dg_badinput((struct sockaddr *)&ss)) return; @@ -1642,7 +1642,7 @@ daytime_dg(int s, struct servtab *sep) size = sizeof(ss); if (recvfrom(s, buffer, sizeof(buffer), 0, (struct sockaddr *)&ss, - &size) < 0) + &size) == -1) return; if (dg_badinput((struct sockaddr *)&ss)) return; @@ -1739,7 +1739,7 @@ spawn(int ctrl, short events, void *xsep) } pid = fork(); } - if (pid < 0) { + if (pid == -1) { syslog(LOG_ERR, "fork: %m"); if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) close(ctrl); @@ -1791,7 +1791,7 @@ spawn(int ctrl, short events, void *xsep) tmpint |= LOGIN_SETGROUP; } if (setusercontext(NULL, pwd, pwd->pw_uid, - tmpint) < 0) { + tmpint) == -1) { syslog(LOG_ERR, "%s/%s: setusercontext: %m", sep->se_service, sep->se_proto); diff --git a/usr.sbin/installboot/armv7_installboot.c b/usr.sbin/installboot/armv7_installboot.c index 7242fbf00db..5e16f436605 100644 --- a/usr.sbin/installboot/armv7_installboot.c +++ b/usr.sbin/installboot/armv7_installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7_installboot.c,v 1.3 2017/05/07 10:40:17 kettenis Exp $ */ +/* $OpenBSD: armv7_installboot.c,v 1.4 2019/06/28 13:32:48 deraadt Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -73,7 +73,7 @@ md_installboot(int devfd, char *dev) int part; /* Get and check disklabel. */ - if (ioctl(devfd, DIOCGDINFO, &dl) != 0) + if (ioctl(devfd, DIOCGDINFO, &dl) == -1) err(1, "disklabel: %s", dev); if (dl.d_magic != DISKMAGIC) errx(1, "bad disklabel magic=0x%08x", dl.d_magic); diff --git a/usr.sbin/installboot/bootstrap.c b/usr.sbin/installboot/bootstrap.c index 4a957cc26e5..19332ff487d 100644 --- a/usr.sbin/installboot/bootstrap.c +++ b/usr.sbin/installboot/bootstrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bootstrap.c,v 1.12 2018/12/13 14:06:10 krw Exp $ */ +/* $OpenBSD: bootstrap.c,v 1.13 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2013 Joel Sing <jsing@openbsd.org> @@ -60,9 +60,9 @@ bootstrap(int devfd, char *dev, char *bootfile) if (verbose) fprintf(stderr, "reading bootstrap from %s\n", bootfile); fd = open(bootfile, O_RDONLY); - if (fd < 0) + if (fd == -1) err(1, "open %s", bootfile); - if (fstat(fd, &sb) != 0) + if (fstat(fd, &sb) == -1) err(1, "fstat %s", bootfile); bootsec = howmany((ssize_t)sb.st_size, dl.d_secsize); bootsize = bootsec * dl.d_secsize; diff --git a/usr.sbin/installboot/i386_installboot.c b/usr.sbin/installboot/i386_installboot.c index 2f55a410001..8ff7b09a9b6 100644 --- a/usr.sbin/installboot/i386_installboot.c +++ b/usr.sbin/installboot/i386_installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_installboot.c,v 1.31 2017/10/27 16:47:08 mpi Exp $ */ +/* $OpenBSD: i386_installboot.c,v 1.32 2019/06/28 13:32:48 deraadt Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -130,7 +130,7 @@ md_installboot(int devfd, char *dev) int part; /* Get and check disklabel. */ - if (ioctl(devfd, DIOCGDINFO, &dl) != 0) + if (ioctl(devfd, DIOCGDINFO, &dl) == -1) err(1, "disklabel: %s", dev); if (dl.d_magic != DISKMAGIC) errx(1, "bad disklabel magic=0x%08x", dl.d_magic); @@ -171,7 +171,7 @@ write_bootblocks(int devfd, char *dev, struct disklabel *dl) u_int start = 0; /* Write patched proto bootblock(s) into the superblock. */ - if (fstat(devfd, &sb) < 0) + if (fstat(devfd, &sb) == -1) err(1, "fstat: %s", dev); if (!S_ISCHR(sb.st_mode)) @@ -592,7 +592,7 @@ loadproto(char *fname, long *size) Elf_Word phsize; Elf_Phdr *ph; - if ((fd = open(fname, O_RDONLY)) < 0) + if ((fd = open(fname, O_RDONLY)) == -1) err(1, "%s", fname); if (read(fd, &eh, sizeof(eh)) != sizeof(eh)) @@ -680,10 +680,10 @@ getbootparams(char *boot, int devfd, struct disklabel *dl) /* Make sure the (probably new) boot file is on disk. */ sync(); sleep(1); - if ((fd = open(boot, O_RDONLY)) < 0) + if ((fd = open(boot, O_RDONLY)) == -1) err(1, "open: %s", boot); - if (fstatfs(fd, &fssb) != 0) + if (fstatfs(fd, &fssb) == -1) err(1, "statfs: %s", boot); if (strncmp(fssb.f_fstypename, "ffs", MFSNAMELEN) && diff --git a/usr.sbin/installboot/i386_nlist.c b/usr.sbin/installboot/i386_nlist.c index d4daf443204..cdb0695d2e5 100644 --- a/usr.sbin/installboot/i386_nlist.c +++ b/usr.sbin/installboot/i386_nlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_nlist.c,v 1.6 2017/10/27 16:47:08 mpi Exp $ */ +/* $OpenBSD: i386_nlist.c,v 1.7 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -109,7 +109,7 @@ __elf_fdnlist(int fd, struct nlist *list) /* Make sure obj is OK */ if (pread(fd, &ehdr, sizeof(Elf_Ehdr), (off_t)0) != sizeof(Elf_Ehdr) || - !__elf_is_okay__(&ehdr) || fstat(fd, &st) < 0) + !__elf_is_okay__(&ehdr) || fstat(fd, &st) == -1) return (-1); /* calculate section header table size */ @@ -301,7 +301,7 @@ nlist_elf32(const char *name, struct nlist *list) int fd, n; fd = open(name, O_RDONLY, 0); - if (fd < 0) + if (fd == -1) return (-1); n = __elf_fdnlist(fd, list); close(fd); diff --git a/usr.sbin/installboot/i386_softraid.c b/usr.sbin/installboot/i386_softraid.c index 4e8bbe26e7e..8790db06806 100644 --- a/usr.sbin/installboot/i386_softraid.c +++ b/usr.sbin/installboot/i386_softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_softraid.c,v 1.10 2016/04/28 16:48:18 krw Exp $ */ +/* $OpenBSD: i386_softraid.c,v 1.11 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2012 Joel Sing <jsing@openbsd.org> * @@ -73,11 +73,11 @@ sr_install_bootblk(int devfd, int vol, int disk) /* Open this device and check its disklabel. */ if ((diskfd = opendev(bd.bd_vendor, (nowrite? O_RDONLY:O_RDWR), - OPENDEV_PART, &dev)) < 0) + OPENDEV_PART, &dev)) == -1) err(1, "open: %s", dev); /* Get and check disklabel. */ - if (ioctl(diskfd, DIOCGDINFO, &dl) != 0) + if (ioctl(diskfd, DIOCGDINFO, &dl) == -1) err(1, "disklabel: %s", dev); if (dl.d_magic != DISKMAGIC) err(1, "bad disklabel magic=0x%08x", dl.d_magic); diff --git a/usr.sbin/installboot/installboot.c b/usr.sbin/installboot/installboot.c index 905e49b90f4..f79176bd154 100644 --- a/usr.sbin/installboot/installboot.c +++ b/usr.sbin/installboot/installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: installboot.c,v 1.11 2015/11/29 00:14:07 deraadt Exp $ */ +/* $OpenBSD: installboot.c,v 1.12 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2012, 2013 Joel Sing <jsing@openbsd.org> @@ -98,7 +98,7 @@ main(int argc, char **argv) } if ((devfd = opendev(dev, (nowrite ? O_RDONLY : O_RDWR), OPENDEV_PART, - &realdev)) < 0) + &realdev)) == -1) err(1, "open: %s", realdev); if (verbose) { diff --git a/usr.sbin/installboot/sparc64_installboot.c b/usr.sbin/installboot/sparc64_installboot.c index 1932476cb29..bef2079a8af 100644 --- a/usr.sbin/installboot/sparc64_installboot.c +++ b/usr.sbin/installboot/sparc64_installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sparc64_installboot.c,v 1.7 2015/12/28 23:00:29 krw Exp $ */ +/* $OpenBSD: sparc64_installboot.c,v 1.8 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2012, 2013 Joel Sing <jsing@openbsd.org> @@ -55,7 +55,7 @@ md_loadboot(void) int fd; /* Load first-stage boot block. */ - if ((fd = open(stage1, O_RDONLY)) < 0) + if ((fd = open(stage1, O_RDONLY)) == -1) err(1, "open"); if (fstat(fd, &sb) == -1) err(1, "fstat"); @@ -76,7 +76,7 @@ md_loadboot(void) close(fd); /* Load second-stage boot loader. */ - if ((fd = open(stage2, O_RDONLY)) < 0) + if ((fd = open(stage2, O_RDONLY)) == -1) err(1, "open"); if (fstat(fd, &sb) == -1) err(1, "stat"); diff --git a/usr.sbin/installboot/sparc64_softraid.c b/usr.sbin/installboot/sparc64_softraid.c index 148b7c80bdf..776cf4a646a 100644 --- a/usr.sbin/installboot/sparc64_softraid.c +++ b/usr.sbin/installboot/sparc64_softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sparc64_softraid.c,v 1.3 2015/10/03 16:56:52 krw Exp $ */ +/* $OpenBSD: sparc64_softraid.c,v 1.4 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2012 Joel Sing <jsing@openbsd.org> * @@ -64,7 +64,7 @@ sr_install_bootblk(int devfd, int vol, int disk) /* Open device. */ if ((diskfd = opendev(bd.bd_vendor, (nowrite ? O_RDONLY : O_RDWR), - OPENDEV_PART, &realdev)) < 0) + OPENDEV_PART, &realdev)) == -1) err(1, "open: %s", realdev); if (verbose) diff --git a/usr.sbin/kgmon/kgmon.c b/usr.sbin/kgmon/kgmon.c index 70c7929b301..cafab0f2285 100644 --- a/usr.sbin/kgmon/kgmon.c +++ b/usr.sbin/kgmon/kgmon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kgmon.c,v 1.25 2018/04/26 12:42:51 guenther Exp $ */ +/* $OpenBSD: kgmon.c,v 1.26 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 1983, 1992, 1993 @@ -188,7 +188,7 @@ openfiles(char *sys, char *kmemf, struct kvmvars *kvp, int cpuid) mib[2] = GPROF_STATE; mib[3] = cpuid; size = sizeof state; - if (sysctl(mib, 4, &state, &size, NULL, 0) < 0) + if (sysctl(mib, 4, &state, &size, NULL, 0) == -1) errx(20, "profiling not defined in kernel."); if (!(bflag || hflag || rflag || (pflag && state == GMON_PROF_ON))) @@ -210,7 +210,7 @@ openfiles(char *sys, char *kmemf, struct kvmvars *kvp, int cpuid) errx(2, "kvm_openfiles: %s", errbuf); kern_readonly(GMON_PROF_ON); } - if (kvm_nlist(kvp->kd, nl) < 0) + if (kvm_nlist(kvp->kd, nl) == -1) errx(3, "%s: no namelist", sys ? sys : _PATH_UNIX); if (!nl[N_GMONPARAM].n_value) errx(20, "profiling not defined in kernel."); @@ -255,7 +255,7 @@ getprof(struct kvmvars *kvp, int cpuid) mib[2] = GPROF_GMONPARAM; mib[3] = cpuid; size = sizeof kvp->gpm; - if (sysctl(mib, 4, &kvp->gpm, &size, NULL, 0) < 0) + if (sysctl(mib, 4, &kvp->gpm, &size, NULL, 0) == -1) size = 0; } if (size != sizeof kvp->gpm) @@ -280,7 +280,7 @@ setprof(struct kvmvars *kvp, int cpuid, int state) mib[1] = KERN_PROF; mib[2] = GPROF_STATE; mib[3] = cpuid; - if (sysctl(mib, 4, &oldstate, &sz, NULL, 0) < 0) + if (sysctl(mib, 4, &oldstate, &sz, NULL, 0) == -1) goto bad; if (oldstate == state) return; @@ -345,7 +345,7 @@ dumpstate(struct kvmvars *kvp, int cpuid) mib[2] = GPROF_COUNT; mib[3] = cpuid; i = kvp->gpm.kcountsize; - if (sysctl(mib, 4, tickbuf, &i, NULL, 0) < 0) + if (sysctl(mib, 4, tickbuf, &i, NULL, 0) == -1) i = 0; } if (i != kvp->gpm.kcountsize) @@ -368,7 +368,7 @@ dumpstate(struct kvmvars *kvp, int cpuid) mib[2] = GPROF_FROMS; mib[3] = cpuid; i = kvp->gpm.fromssize; - if (sysctl(mib, 4, froms, &i, NULL, 0) < 0) + if (sysctl(mib, 4, froms, &i, NULL, 0) == -1) i = 0; } if (i != kvp->gpm.fromssize) @@ -384,7 +384,7 @@ dumpstate(struct kvmvars *kvp, int cpuid) mib[2] = GPROF_TOS; mib[3] = cpuid; i = kvp->gpm.tossize; - if (sysctl(mib, 4, tos, &i, NULL, 0) < 0) + if (sysctl(mib, 4, tos, &i, NULL, 0) == -1) i = 0; } if (i != kvp->gpm.tossize) @@ -435,7 +435,7 @@ getprofhz(struct kvmvars *kvp) mib[1] = KERN_CLOCKRATE; clockrate.profhz = 1; size = sizeof clockrate; - if (sysctl(mib, 2, &clockrate, &size, NULL, 0) < 0) + if (sysctl(mib, 2, &clockrate, &size, NULL, 0) == -1) warn("get clockrate"); return (clockrate.profhz); } @@ -476,13 +476,13 @@ reset(struct kvmvars *kvp, int cpuid) mib[1] = KERN_PROF; mib[2] = GPROF_COUNT; mib[3] = cpuid; - if (sysctl(mib, 4, NULL, NULL, zbuf, kvp->gpm.kcountsize) < 0) + if (sysctl(mib, 4, NULL, NULL, zbuf, kvp->gpm.kcountsize) == -1) err(13, "tickbuf zero"); mib[2] = GPROF_FROMS; - if (sysctl(mib, 4, NULL, NULL, zbuf, kvp->gpm.fromssize) < 0) + if (sysctl(mib, 4, NULL, NULL, zbuf, kvp->gpm.fromssize) == -1) err(14, "froms zero"); mib[2] = GPROF_TOS; - if (sysctl(mib, 4, NULL, NULL, zbuf, kvp->gpm.tossize) < 0) + if (sysctl(mib, 4, NULL, NULL, zbuf, kvp->gpm.tossize) == -1) err(15, "tos zero"); free(zbuf); } @@ -495,7 +495,7 @@ getncpu(void) int ncpu; size = sizeof(ncpu); - if (sysctl(mib, 2, &ncpu, &size, NULL, 0) < 0) { + if (sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1) { warnx("cannot read hw.ncpu"); return (1); } diff --git a/usr.sbin/kvm_mkdb/kvm_mkdb.c b/usr.sbin/kvm_mkdb/kvm_mkdb.c index 64765679058..bda0080948e 100644 --- a/usr.sbin/kvm_mkdb/kvm_mkdb.c +++ b/usr.sbin/kvm_mkdb/kvm_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_mkdb.c,v 1.30 2018/10/26 17:11:33 mestre Exp $ */ +/* $OpenBSD: kvm_mkdb.c,v 1.31 2019/06/28 13:32:48 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -85,7 +85,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) warn("can't set rlimit data size"); } diff --git a/usr.sbin/kvm_mkdb/nlist.c b/usr.sbin/kvm_mkdb/nlist.c index 7745642103e..cd8c01b3bad 100644 --- a/usr.sbin/kvm_mkdb/nlist.c +++ b/usr.sbin/kvm_mkdb/nlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nlist.c,v 1.52 2018/04/26 12:42:51 guenther Exp $ */ +/* $OpenBSD: nlist.c,v 1.53 2019/06/28 13:32:48 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -90,7 +90,7 @@ __elf_knlist(int fd, DB *db, int ksyms) errx(1, "cannot allocate %zu bytes for symbol header", sizeof(Elf_Shdr) * eh.e_shnum); - if (fseek (fp, eh.e_shoff, SEEK_SET) < 0) { + if (fseek(fp, eh.e_shoff, SEEK_SET) == -1) { fmterr = "no exec header"; error = -1; goto done; diff --git a/usr.sbin/kvm_mkdb/testdb.c b/usr.sbin/kvm_mkdb/testdb.c index a804634e61c..649a7d1c4f9 100644 --- a/usr.sbin/kvm_mkdb/testdb.c +++ b/usr.sbin/kvm_mkdb/testdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: testdb.c,v 1.9 2015/01/16 06:40:17 deraadt Exp $ */ +/* $OpenBSD: testdb.c,v 1.10 2019/06/28 13:32:48 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -57,7 +57,7 @@ testdb(char *dbname) mib[0] = CTL_KERN; mib[1] = KERN_VERSION; kversionlen = sizeof(kversion); - if (sysctl(mib, 2, kversion, &kversionlen, NULL, 0) < 0) + if (sysctl(mib, 2, kversion, &kversionlen, NULL, 0) == -1) goto close; /* Read the version out of the database */ diff --git a/usr.sbin/ldapd/ldape.c b/usr.sbin/ldapd/ldape.c index 268fd6bddee..a494d304b27 100644 --- a/usr.sbin/ldapd/ldape.c +++ b/usr.sbin/ldapd/ldape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldape.c,v 1.30 2018/08/12 22:04:09 rob Exp $ */ +/* $OpenBSD: ldape.c,v 1.31 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -381,7 +381,7 @@ ldape(int debug, int verbose, char *csockpath) TAILQ_FOREACH(l, &conf->listeners, entry) { l->fd = socket(l->ss.ss_family, SOCK_STREAM | SOCK_NONBLOCK, 0); - if (l->fd < 0) + if (l->fd == -1) fatal("ldape: socket"); setsockopt(l->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c index c5796bb3c60..01324f9726a 100644 --- a/usr.sbin/ldpd/interface.c +++ b/usr.sbin/ldpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.50 2017/03/03 23:41:27 renato Exp $ */ +/* $OpenBSD: interface.c,v 1.51 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -460,7 +460,7 @@ if_join_ipv4_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = if_get_ipv4_addr(iface); if (setsockopt(global.ipv4.ldp_disc_socket, IPPROTO_IP, - IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq)) < 0) { + IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq)) == -1) { log_warn("%s: error IP_ADD_MEMBERSHIP, interface %s address %s", __func__, iface->name, inet_ntoa(*addr)); return (-1); @@ -480,7 +480,7 @@ if_leave_ipv4_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = if_get_ipv4_addr(iface); if (setsockopt(global.ipv4.ldp_disc_socket, IPPROTO_IP, - IP_DROP_MEMBERSHIP, (void *)&mreq, sizeof(mreq)) < 0) { + IP_DROP_MEMBERSHIP, (void *)&mreq, sizeof(mreq)) == -1) { log_warn("%s: error IP_DROP_MEMBERSHIP, interface %s " "address %s", __func__, iface->name, inet_ntoa(*addr)); return (-1); @@ -501,7 +501,7 @@ if_join_ipv6_group(struct iface *iface, struct in6_addr *addr) mreq.ipv6mr_interface = iface->ifindex; if (setsockopt(global.ipv6.ldp_disc_socket, IPPROTO_IPV6, - IPV6_JOIN_GROUP, &mreq, sizeof(mreq)) < 0) { + IPV6_JOIN_GROUP, &mreq, sizeof(mreq)) == -1) { log_warn("%s: error IPV6_JOIN_GROUP, interface %s address %s", __func__, iface->name, log_in6addr(addr)); return (-1); @@ -522,7 +522,7 @@ if_leave_ipv6_group(struct iface *iface, struct in6_addr *addr) mreq.ipv6mr_interface = iface->ifindex; if (setsockopt(global.ipv6.ldp_disc_socket, IPPROTO_IPV6, - IPV6_LEAVE_GROUP, (void *)&mreq, sizeof(mreq)) < 0) { + IPV6_LEAVE_GROUP, (void *)&mreq, sizeof(mreq)) == -1) { log_warn("%s: error IPV6_LEAVE_GROUP, interface %s address %s", __func__, iface->name, log_in6addr(addr)); return (-1); diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c index afc1f8f4dd3..ec550143be6 100644 --- a/usr.sbin/ldpd/kroute.c +++ b/usr.sbin/ldpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.69 2019/01/23 08:43:45 dlg Exp $ */ +/* $OpenBSD: kroute.c,v 1.70 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2015, 2016 Renato Westphal <renato@openbsd.org> @@ -1835,7 +1835,7 @@ kmpw_install(const char *ifname, struct kpw *kpw) memset(&ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); ifr.ifr_data = (caddr_t) &imr; - if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr)) { + if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) { log_warn("ioctl SIOCSETMPWCFG"); return (-1); } @@ -1853,7 +1853,7 @@ kmpw_uninstall(const char *ifname) memset(&imr, 0, sizeof(imr)); strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); ifr.ifr_data = (caddr_t) &imr; - if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr)) { + if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) { log_warn("ioctl SIOCSETMPWCFG"); return (-1); } diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c index e41b922b403..cf47e3406dc 100644 --- a/usr.sbin/ldpd/neighbor.c +++ b/usr.sbin/ldpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.80 2019/01/23 02:02:04 dlg Exp $ */ +/* $OpenBSD: neighbor.c,v 1.81 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -547,7 +547,7 @@ nbr_connect_cb(int fd, short event, void *arg) socklen_t len; len = sizeof(error); - if (getsockopt(nbr->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(nbr->fd, SOL_SOCKET, SO_ERROR, &error, &len) == -1) { log_warn("%s: getsockopt SOL_SOCKET SO_ERROR", __func__); return; } diff --git a/usr.sbin/ldpd/socket.c b/usr.sbin/ldpd/socket.c index e161099426b..60fbb9c1b35 100644 --- a/usr.sbin/ldpd/socket.c +++ b/usr.sbin/ldpd/socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: socket.c,v 1.9 2016/07/01 23:29:55 renato Exp $ */ +/* $OpenBSD: socket.c,v 1.10 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2016 Renato Westphal <renato@openbsd.org> @@ -195,7 +195,7 @@ int sock_set_reuse(int fd, int enable) { if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, - sizeof(int)) < 0) { + sizeof(int)) == -1) { log_warn("%s: error setting SO_REUSEADDR", __func__); return (-1); } @@ -207,7 +207,7 @@ int sock_set_bindany(int fd, int enable) { if (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &enable, - sizeof(int)) < 0) { + sizeof(int)) == -1) { log_warn("%s: error setting SO_BINDANY", __func__); return (-1); } @@ -218,7 +218,7 @@ sock_set_bindany(int fd, int enable) int sock_set_ipv4_tos(int fd, int tos) { - if (setsockopt(fd, IPPROTO_IP, IP_TOS, (int *)&tos, sizeof(tos)) < 0) { + if (setsockopt(fd, IPPROTO_IP, IP_TOS, (int *)&tos, sizeof(tos)) == -1) { log_warn("%s: error setting IP_TOS to 0x%x", __func__, tos); return (-1); } @@ -230,7 +230,7 @@ int sock_set_ipv4_recvif(int fd, int enable) { if (setsockopt(fd, IPPROTO_IP, IP_RECVIF, &enable, - sizeof(enable)) < 0) { + sizeof(enable)) == -1) { log_warn("%s: error setting IP_RECVIF", __func__); return (-1); } @@ -240,7 +240,7 @@ sock_set_ipv4_recvif(int fd, int enable) int sock_set_ipv4_minttl(int fd, int ttl) { - if (setsockopt(fd, IPPROTO_IP, IP_MINTTL, &ttl, sizeof(ttl)) < 0) { + if (setsockopt(fd, IPPROTO_IP, IP_MINTTL, &ttl, sizeof(ttl)) == -1) { log_warn("%s: error setting IP_MINTTL", __func__); return (-1); } @@ -251,7 +251,7 @@ sock_set_ipv4_minttl(int fd, int ttl) int sock_set_ipv4_ucast_ttl(int fd, int ttl) { - if (setsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl)) < 0) { + if (setsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl)) == -1) { log_warn("%s: error setting IP_TTL", __func__); return (-1); } @@ -263,7 +263,7 @@ int sock_set_ipv4_mcast_ttl(int fd, uint8_t ttl) { if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, - (char *)&ttl, sizeof(ttl)) < 0) { + (char *)&ttl, sizeof(ttl)) == -1) { log_warn("%s: error setting IP_MULTICAST_TTL to %d", __func__, ttl); return (-1); @@ -280,7 +280,7 @@ sock_set_ipv4_mcast(struct iface *iface) addr = if_get_ipv4_addr(iface); if (setsockopt(global.ipv4.ldp_disc_socket, IPPROTO_IP, IP_MULTICAST_IF, - &addr, sizeof(addr)) < 0) { + &addr, sizeof(addr)) == -1) { log_warn("%s: error setting IP_MULTICAST_IF, interface %s", __func__, iface->name); return (-1); @@ -295,7 +295,7 @@ sock_set_ipv4_mcast_loop(int fd) uint8_t loop = 0; if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, - (char *)&loop, sizeof(loop)) < 0) { + (char *)&loop, sizeof(loop)) == -1) { log_warn("%s: error setting IP_MULTICAST_LOOP", __func__); return (-1); } @@ -307,7 +307,7 @@ int sock_set_ipv6_dscp(int fd, int dscp) { if (setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &dscp, - sizeof(dscp)) < 0) { + sizeof(dscp)) == -1) { log_warn("%s: error setting IPV6_TCLASS", __func__); return (-1); } @@ -319,7 +319,7 @@ int sock_set_ipv6_pktinfo(int fd, int enable) { if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &enable, - sizeof(enable)) < 0) { + sizeof(enable)) == -1) { log_warn("%s: error setting IPV6_RECVPKTINFO", __func__); return (-1); } @@ -331,7 +331,7 @@ int sock_set_ipv6_minhopcount(int fd, int hoplimit) { if (setsockopt(fd, IPPROTO_IPV6, IPV6_MINHOPCOUNT, - &hoplimit, sizeof(hoplimit)) < 0) { + &hoplimit, sizeof(hoplimit)) == -1) { log_warn("%s: error setting IPV6_MINHOPCOUNT", __func__); return (-1); } @@ -343,7 +343,7 @@ int sock_set_ipv6_ucast_hops(int fd, int hoplimit) { if (setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, - &hoplimit, sizeof(hoplimit)) < 0) { + &hoplimit, sizeof(hoplimit)) == -1) { log_warn("%s: error setting IPV6_UNICAST_HOPS", __func__); return (-1); } @@ -355,7 +355,7 @@ int sock_set_ipv6_mcast_hops(int fd, int hoplimit) { if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, - &hoplimit, sizeof(hoplimit)) < 0) { + &hoplimit, sizeof(hoplimit)) == -1) { log_warn("%s: error setting IPV6_MULTICAST_HOPS", __func__); return (-1); } @@ -367,7 +367,7 @@ int sock_set_ipv6_mcast(struct iface *iface) { if (setsockopt(global.ipv6.ldp_disc_socket, IPPROTO_IPV6, - IPV6_MULTICAST_IF, &iface->ifindex, sizeof(iface->ifindex)) < 0) { + IPV6_MULTICAST_IF, &iface->ifindex, sizeof(iface->ifindex)) == -1) { log_warn("%s: error setting IPV6_MULTICAST_IF, interface %s", __func__, iface->name); return (-1); @@ -382,7 +382,7 @@ sock_set_ipv6_mcast_loop(int fd) unsigned int loop = 0; if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, - &loop, sizeof(loop)) < 0) { + &loop, sizeof(loop)) == -1) { log_warn("%s: error setting IPV6_MULTICAST_LOOP", __func__); return (-1); } diff --git a/usr.sbin/lpd/lpd.c b/usr.sbin/lpd/lpd.c index 82a3ddb578d..01b5760cdc6 100644 --- a/usr.sbin/lpd/lpd.c +++ b/usr.sbin/lpd/lpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpd.c,v 1.1 2018/04/27 16:14:37 eric Exp $ */ +/* $OpenBSD: lpd.c,v 1.2 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2017 Eric Faurot <eric@openbsd.org> @@ -313,7 +313,7 @@ priv_open_listener(struct listener *l) case AF_INET6: opt = 1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt, - sizeof(opt)) < 0) + sizeof(opt)) == -1) fatal("setsockopt: %s", log_fmt_sockaddr(sa)); if (bind(sock, sa, sa->sa_len) == -1) diff --git a/usr.sbin/lpd/parse.y b/usr.sbin/lpd/parse.y index 123a294dda0..e22ddb3d9ee 100644 --- a/usr.sbin/lpd/parse.y +++ b/usr.sbin/lpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.6 2019/02/13 22:57:08 deraadt Exp $ */ +/* $OpenBSD: parse.y,v 1.7 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -936,7 +936,7 @@ is_if_in_group(const char *ifname, const char *groupname) int s; int ret = 0; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) err(1, "socket"); memset(&ifgr, 0, sizeof(ifgr)); diff --git a/usr.sbin/map-mbone/mapper.c b/usr.sbin/map-mbone/mapper.c index a1bcbab7cd0..925432b56df 100644 --- a/usr.sbin/map-mbone/mapper.c +++ b/usr.sbin/map-mbone/mapper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mapper.c,v 1.24 2016/08/03 23:13:54 krw Exp $ */ +/* $OpenBSD: mapper.c,v 1.25 2019/06/28 13:32:48 deraadt Exp $ */ /* $NetBSD: mapper.c,v 1.3 1995/12/10 11:12:04 mycroft Exp $ */ /* Mapper for connections between MRouteD multicast routers. @@ -876,9 +876,9 @@ int main(int argc, char *argv[]) addr.sin_len = sizeof addr; addr.sin_addr.s_addr = dvmrp_group; addr.sin_port = htons(2000); /* any port over 1024 will do... */ - if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0 - || connect(udp, (struct sockaddr *) &addr, sizeof(addr)) < 0 - || getsockname(udp, (struct sockaddr *) &addr, &addrlen) < 0) { + if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) == -1 + || connect(udp, (struct sockaddr *) &addr, sizeof(addr)) == -1 + || getsockname(udp, (struct sockaddr *) &addr, &addrlen) == -1) { perror("Determining local address"); exit(1); } @@ -908,7 +908,7 @@ int main(int argc, char *argv[]) count = poll(pfd, 1, timeout * 1000); - if (count < 0) { + if (count == -1) { if (errno != EINTR) perror("select"); continue; diff --git a/usr.sbin/memconfig/memconfig.c b/usr.sbin/memconfig/memconfig.c index 628675d4756..601dd1b7d0b 100644 --- a/usr.sbin/memconfig/memconfig.c +++ b/usr.sbin/memconfig/memconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memconfig.c,v 1.18 2016/08/14 18:34:48 guenther Exp $ */ +/* $OpenBSD: memconfig.c,v 1.19 2019/06/28 13:32:48 deraadt Exp $ */ /*- * Copyright (c) 1999 Michael Smith <msmith@freebsd.org> @@ -132,7 +132,7 @@ mrgetall(int memfd, int *nmr) struct mem_range_op mro; mro.mo_arg[0] = 0; - if (ioctl(memfd, MEMRANGE_GET, &mro)) + if (ioctl(memfd, MEMRANGE_GET, &mro) == -1) err(1, "can't size range descriptor array"); *nmr = mro.mo_arg[0]; @@ -143,7 +143,7 @@ mrgetall(int memfd, int *nmr) mro.mo_arg[0] = *nmr; mro.mo_desc = mrd; - if (ioctl(memfd, MEMRANGE_GET, &mro)) + if (ioctl(memfd, MEMRANGE_GET, &mro) == -1) err(1, "can't fetch range descriptor array"); return(mrd); @@ -254,7 +254,7 @@ setfunc(int memfd, int argc, char *argv[]) mro.mo_desc = &mrd; mro.mo_arg[0] = 0; - if (ioctl(memfd, MEMRANGE_SET, &mro)) + if (ioctl(memfd, MEMRANGE_SET, &mro) == -1) err(1, "can't set range"); } @@ -307,7 +307,7 @@ clearfunc(int memfd, int argc, char *argv[]) !(mrdp[i].mr_flags & MDF_FIXACTIVE)) { mro.mo_desc = mrdp + i; - if (ioctl(memfd, MEMRANGE_SET, &mro)) + if (ioctl(memfd, MEMRANGE_SET, &mro) == -1) warn("couldn't clear range owned by '%s'", owner); } @@ -316,7 +316,7 @@ clearfunc(int memfd, int argc, char *argv[]) /* clear-by-base/len */ mro.mo_arg[0] = MEMRANGE_SET_REMOVE; mro.mo_desc = &mrd; - if (ioctl(memfd, MEMRANGE_SET, &mro)) + if (ioctl(memfd, MEMRANGE_SET, &mro) == -1) err(1, "couldn't clear range"); } else { help("clear"); diff --git a/usr.sbin/mksuncd/mksuncd.c b/usr.sbin/mksuncd/mksuncd.c index dc6becb3422..cd1114c0ed9 100644 --- a/usr.sbin/mksuncd/mksuncd.c +++ b/usr.sbin/mksuncd/mksuncd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mksuncd.c,v 1.3 2015/10/12 07:45:48 deraadt Exp $ */ +/* $OpenBSD: mksuncd.c,v 1.4 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -282,7 +282,7 @@ adjust_label(int f, struct sun_disklabel *slp, int part, off_t start, off_t size return (-1); i = write(f, slp, sizeof(*slp)); - if (i < 0) + if (i == -1) err(1, "write modified label"); if (i != sizeof(*slp)) errx(1, "short write modified label"); @@ -297,13 +297,13 @@ append_osfile(int outf, int inf) while (1) { len = read(inf, buf, sizeof(buf)); - if (len < 0) + if (len == -1) err(1, "read osfile"); if (len == 0) return (0); r = write(outf, buf, len); - if (r < 0) + if (r == -1) err(1, "write basefile"); if (r != len) errx(1, "short write basefile"); diff --git a/usr.sbin/mkuboot/mkuboot.c b/usr.sbin/mkuboot/mkuboot.c index c7fb31de823..9afc02f654c 100644 --- a/usr.sbin/mkuboot/mkuboot.c +++ b/usr.sbin/mkuboot/mkuboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkuboot.c,v 1.8 2017/10/29 08:45:53 mpi Exp $ */ +/* $OpenBSD: mkuboot.c,v 1.9 2019/06/28 13:32:48 deraadt Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -224,13 +224,13 @@ main(int argc, char *argv[]) strlcpy((char *)ih.ih_name, imgname, sizeof ih.ih_name); ifd = open(iname, O_RDONLY); - if (ifd < 0) + if (ifd == -1) err(1, "%s", iname); if (fstat(ifd, &sb) == -1) err(1, "%s", iname); ofd = open(oname, O_RDWR | O_TRUNC | O_CREAT, 0644); - if (ofd < 0) + if (ofd == -1) err(1, "%s", oname); if (pledge("stdio", NULL) == -1) diff --git a/usr.sbin/mrinfo/mrinfo.c b/usr.sbin/mrinfo/mrinfo.c index c1f70d9723d..47c51854153 100644 --- a/usr.sbin/mrinfo/mrinfo.c +++ b/usr.sbin/mrinfo/mrinfo.c @@ -375,9 +375,9 @@ main(int argc, char *argv[]) addr.sin_addr.s_addr = target_addr; addr.sin_port = htons(2000); /* any port over 1024 will * do... */ - if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0 || - connect(udp, (struct sockaddr *) & addr, sizeof(addr)) < 0 || - getsockname(udp, (struct sockaddr *) & addr, &addrlen) < 0) { + if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) == -1 || + connect(udp, (struct sockaddr *) & addr, sizeof(addr)) == -1 || + getsockname(udp, (struct sockaddr *) & addr, &addrlen) == -1) { perror("Determining local address"); exit(1); } @@ -422,7 +422,7 @@ main(int argc, char *argv[]) count = poll(pfd, 1, tv.tv_sec * 1000); - if (count < 0) { + if (count == -1) { if (errno != EINTR) perror("select"); continue; diff --git a/usr.sbin/mrouted/cfparse.y b/usr.sbin/mrouted/cfparse.y index 9269812d323..0b8af93ea21 100644 --- a/usr.sbin/mrouted/cfparse.y +++ b/usr.sbin/mrouted/cfparse.y @@ -142,7 +142,7 @@ stmt : error inet_fmt($2, s1)); strlcpy(ffr.ifr_name, ifname, sizeof(ffr.ifr_name)); - if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ffr)<0) + if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ffr) == -1) fatal("ioctl SIOCGIFFLAGS on %s",ffr.ifr_name); if (ffr.ifr_flags & IFF_LOOPBACK) fatal("Tunnel local address %s is a loopback interface", diff --git a/usr.sbin/mrouted/config.c b/usr.sbin/mrouted/config.c index 20f193fd761..9ba913f577f 100644 --- a/usr.sbin/mrouted/config.c +++ b/usr.sbin/mrouted/config.c @@ -27,7 +27,7 @@ config_vifs_from_kernel(void) u_int32_t addr, mask, subnet; short flags; - if (getifaddrs(&ifap) < 0) + if (getifaddrs(&ifap) == -1) logit(LOG_ERR, errno, "getifaddrs"); for (ifa = ifap; ifa; ifa = ifa->ifa_next) { diff --git a/usr.sbin/mrouted/igmp.c b/usr.sbin/mrouted/igmp.c index 46a652e6c5f..a6e5a55f299 100644 --- a/usr.sbin/mrouted/igmp.c +++ b/usr.sbin/mrouted/igmp.c @@ -43,7 +43,7 @@ init_igmp(void) recv_buf = malloc(RECV_BUF_SIZE); send_buf = malloc(RECV_BUF_SIZE); - if ((igmp_socket = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP)) < 0) + if ((igmp_socket = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP)) == -1) logit(LOG_ERR, errno, "IGMP socket"); k_hdr_include(TRUE); /* include IP header when sending */ @@ -331,7 +331,7 @@ send_igmp(u_int32_t src, u_int32_t dst, int type, int code, sdst.sin_len = sizeof(sdst); sdst.sin_addr.s_addr = dst; if (sendto(igmp_socket, send_buf, ntohs(ip->ip_len), 0, - (struct sockaddr *)&sdst, sizeof(sdst)) < 0) { + (struct sockaddr *)&sdst, sizeof(sdst)) == -1) { if (errno == ENETDOWN) check_vif_state(); else diff --git a/usr.sbin/mrouted/kern.c b/usr.sbin/mrouted/kern.c index 89171d2b19b..2c0154d3276 100644 --- a/usr.sbin/mrouted/kern.c +++ b/usr.sbin/mrouted/kern.c @@ -16,7 +16,7 @@ void k_set_rcvbuf(int bufsize) { if (setsockopt(igmp_socket, SOL_SOCKET, SO_RCVBUF, - (char *)&bufsize, sizeof(bufsize)) < 0) + (char *)&bufsize, sizeof(bufsize)) == -1) logit(LOG_ERR, errno, "setsockopt SO_RCVBUF %u", bufsize); } @@ -25,7 +25,7 @@ void k_hdr_include(int bool) { #ifdef IP_HDRINCL if (setsockopt(igmp_socket, IPPROTO_IP, IP_HDRINCL, - (char *)&bool, sizeof(bool)) < 0) + (char *)&bool, sizeof(bool)) == -1) logit(LOG_ERR, errno, "setsockopt IP_HDRINCL %u", bool); #endif } @@ -37,7 +37,7 @@ void k_set_ttl(int t) ttl = t; if (setsockopt(igmp_socket, IPPROTO_IP, IP_MULTICAST_TTL, - (char *)&ttl, sizeof(ttl)) < 0) + (char *)&ttl, sizeof(ttl)) == -1) logit(LOG_ERR, errno, "setsockopt IP_MULTICAST_TTL %u", ttl); } @@ -48,7 +48,7 @@ void k_set_loop(int l) loop = l; if (setsockopt(igmp_socket, IPPROTO_IP, IP_MULTICAST_LOOP, - (char *)&loop, sizeof(loop)) < 0) + (char *)&loop, sizeof(loop)) == -1) logit(LOG_ERR, errno, "setsockopt IP_MULTICAST_LOOP %u", loop); } @@ -59,7 +59,7 @@ void k_set_if(u_int32_t ifa) adr.s_addr = ifa; if (setsockopt(igmp_socket, IPPROTO_IP, IP_MULTICAST_IF, - (char *)&adr, sizeof(adr)) < 0) + (char *)&adr, sizeof(adr)) == -1) logit(LOG_ERR, errno, "setsockopt IP_MULTICAST_IF %s", inet_fmt(ifa, s1)); } @@ -73,7 +73,7 @@ void k_join(u_int32_t grp, u_int32_t ifa) mreq.imr_interface.s_addr = ifa; if (setsockopt(igmp_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, - (char *)&mreq, sizeof(mreq)) < 0) + (char *)&mreq, sizeof(mreq)) == -1) logit(LOG_WARNING, errno, "can't join group %s on interface %s", inet_fmt(grp, s1), inet_fmt(ifa, s2)); } @@ -87,7 +87,7 @@ void k_leave(u_int32_t grp, u_int32_t ifa) mreq.imr_interface.s_addr = ifa; if (setsockopt(igmp_socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, - (char *)&mreq, sizeof(mreq)) < 0) + (char *)&mreq, sizeof(mreq)) == -1) logit(LOG_WARNING, errno, "can't leave group %s on interface %s", inet_fmt(grp, s1), inet_fmt(ifa, s2)); } @@ -97,12 +97,12 @@ void k_init_dvmrp(void) { #ifdef OLD_KERNEL if (setsockopt(igmp_socket, IPPROTO_IP, MRT_INIT, - (char *)NULL, 0) < 0) + (char *)NULL, 0) == -1) #else int v=1; if (setsockopt(igmp_socket, IPPROTO_IP, MRT_INIT, - (char *)&v, sizeof(int)) < 0) + (char *)&v, sizeof(int)) == -1) #endif logit(LOG_ERR, errno, "can't enable Multicast routing in kernel"); } @@ -111,7 +111,7 @@ void k_init_dvmrp(void) void k_stop_dvmrp(void) { if (setsockopt(igmp_socket, IPPROTO_IP, MRT_DONE, - (char *)NULL, 0) < 0) + (char *)NULL, 0) == -1) logit(LOG_WARNING, errno, "can't disable Multicast routing in kernel"); } @@ -128,7 +128,7 @@ void k_add_vif(vifi_t vifi, struct uvif *v) vc.vifc_rmt_addr.s_addr = v->uv_rmt_addr; if (setsockopt(igmp_socket, IPPROTO_IP, MRT_ADD_VIF, - (char *)&vc, sizeof(vc)) < 0) + (char *)&vc, sizeof(vc)) == -1) logit(LOG_ERR, errno, "setsockopt MRT_ADD_VIF"); } @@ -136,7 +136,7 @@ void k_add_vif(vifi_t vifi, struct uvif *v) void k_del_vif(vifi_t vifi) { if (setsockopt(igmp_socket, IPPROTO_IP, MRT_DEL_VIF, - (char *)&vifi, sizeof(vifi)) < 0) + (char *)&vifi, sizeof(vifi)) == -1) logit(LOG_ERR, errno, "setsockopt MRT_DEL_VIF"); } @@ -164,7 +164,7 @@ void k_add_rg(u_int32_t origin, struct gtable *g) /* write to kernel space */ if (setsockopt(igmp_socket, IPPROTO_IP, MRT_ADD_MFC, - (char *)&mc, sizeof(mc)) < 0) { + (char *)&mc, sizeof(mc)) == -1) { #ifdef DEBUG_MFC md_logit(MD_ADD_FAIL, origin, g->gt_mcastgrp); #endif @@ -193,7 +193,7 @@ int k_del_rg(u_int32_t origin, struct gtable *g) /* write to kernel space */ if ((retval = setsockopt(igmp_socket, IPPROTO_IP, MRT_DEL_MFC, - (char *)&mc, sizeof(mc))) < 0) { + (char *)&mc, sizeof(mc))) == -1) { #ifdef DEBUG_MFC md_logit(MD_DEL_FAIL, origin, g->gt_mcastgrp); #endif @@ -215,7 +215,7 @@ int k_get_version(void) int len = sizeof(vers); if (getsockopt(igmp_socket, IPPROTO_IP, MRT_VERSION, - (char *)&vers, &len) < 0) + (char *)&vers, &len) == -1) logit(LOG_ERR, errno, "getsockopt MRT_VERSION: perhaps your kernel is too old"); diff --git a/usr.sbin/mrouted/main.c b/usr.sbin/mrouted/main.c index 2d3334b3ac8..4c83bc95e93 100644 --- a/usr.sbin/mrouted/main.c +++ b/usr.sbin/mrouted/main.c @@ -142,7 +142,7 @@ usage: fprintf(stderr, (void)close(t); } #else - if (setsid() < 0) + if (setsid() == -1) perror("setsid"); #endif } @@ -250,7 +250,7 @@ usage: fprintf(stderr, */ dummy = 0; for(;;) { - if ((n = poll(pfd, nhandlers + 1, -1)) < 0) { + if ((n = poll(pfd, nhandlers + 1, -1)) == -1) { if (errno != EINTR) /* SIGALRM is expected */ logit(LOG_WARNING, errno, "poll failed"); continue; @@ -259,13 +259,13 @@ usage: fprintf(stderr, if (pfd[0].revents & POLLIN) { recvlen = recvfrom(igmp_socket, recv_buf, RECV_BUF_SIZE, 0, NULL, &dummy); - if (recvlen < 0) { + if (recvlen == -1) { if (errno != EINTR) logit(LOG_ERR, errno, "recvfrom"); continue; } (void)sigemptyset(&mask); (void)sigaddset(&mask, SIGALRM); - if (sigprocmask(SIG_BLOCK, &mask, &omask) < 0) + if (sigprocmask(SIG_BLOCK, &mask, &omask) == -1) logit(LOG_ERR, errno, "sigprocmask"); accept_igmp(recvlen); (void)sigprocmask(SIG_SETMASK, &omask, NULL); @@ -488,7 +488,7 @@ restart(int i) */ (void)sigemptyset(&mask); (void)sigaddset(&mask, SIGALRM); - if (sigprocmask(SIG_BLOCK, &mask, &omask) < 0) + if (sigprocmask(SIG_BLOCK, &mask, &omask) == -1) logit(LOG_ERR, errno, "sigprocmask"); free_all_prunes(); free_all_routes(); diff --git a/usr.sbin/mrouted/prune.c b/usr.sbin/mrouted/prune.c index e51d3de6ce8..8bc1f7c397c 100644 --- a/usr.sbin/mrouted/prune.c +++ b/usr.sbin/mrouted/prune.c @@ -1469,7 +1469,7 @@ age_table_entry(void) stnp = >->gt_srctbl; while ((st = *stnp) != NULL) { sg_req.src.s_addr = st->st_origin; - if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) < 0) { + if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) == -1) { logit(LOG_WARNING, errno, "%s (%s %s)", "age_table_entry: SIOCGETSGCNT failing for", inet_fmt(st->st_origin, s1), @@ -1901,7 +1901,7 @@ accept_mtrace(u_int32_t src, u_int32_t dst, u_int32_t group, * obtain # of packets out on interface */ v_req.vifi = vifi; - if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) >= 0) + if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) == 0) resp->tr_vifout = htonl(v_req.ocount); /* @@ -1918,7 +1918,7 @@ accept_mtrace(u_int32_t src, u_int32_t dst, u_int32_t group, if (gt && gt->gt_mcastgrp == group) { sg_req.src.s_addr = qry->tr_src; sg_req.grp.s_addr = group; - if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) >= 0) + if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) == 0) resp->tr_pktcnt = htonl(sg_req.pktcnt); if (VIFM_ISSET(vifi, gt->gt_scope)) @@ -1950,7 +1950,7 @@ accept_mtrace(u_int32_t src, u_int32_t dst, u_int32_t group, } else { /* get # of packets in on interface */ v_req.vifi = rt->rt_parent; - if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) >= 0) + if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) == 0) resp->tr_vifin = htonl(v_req.icount); MASK_TO_VAL(rt->rt_originmask, resp->tr_smask); diff --git a/usr.sbin/mrouted/rsrr.c b/usr.sbin/mrouted/rsrr.c index 4bf8183ff8a..3cf659de420 100644 --- a/usr.sbin/mrouted/rsrr.c +++ b/usr.sbin/mrouted/rsrr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsrr.c,v 1.15 2017/01/21 11:32:04 guenther Exp $ */ +/* $OpenBSD: rsrr.c,v 1.16 2019/06/28 13:32:48 deraadt Exp $ */ /* $NetBSD: rsrr.c,v 1.3 1995/12/10 10:07:14 mycroft Exp $ */ /* @@ -85,7 +85,7 @@ rsrr_init(void) { struct sockaddr_un serv_addr; - if ((rsrr_socket = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) + if ((rsrr_socket = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) logit(LOG_ERR, errno, "Can't create RSRR socket"); unlink(RSRR_SERV_PATH); @@ -93,7 +93,7 @@ rsrr_init(void) serv_addr.sun_family = AF_UNIX; strlcpy(serv_addr.sun_path, RSRR_SERV_PATH, sizeof serv_addr.sun_path); - if (bind(rsrr_socket, (struct sockaddr *)&serv_addr, sizeof serv_addr) < 0) + if (bind(rsrr_socket, (struct sockaddr *)&serv_addr, sizeof serv_addr) == -1) logit(LOG_ERR, errno, "Can't bind RSRR socket"); if (register_input_handler(rsrr_socket,rsrr_read) < 0) @@ -110,7 +110,7 @@ rsrr_read(int f) bzero((char *) &client_addr, sizeof(client_addr)); rsrr_recvlen = recvfrom(rsrr_socket, rsrr_recv_buf, sizeof(rsrr_recv_buf), 0, (struct sockaddr *)&client_addr, &client_length); - if (rsrr_recvlen < 0) { + if (rsrr_recvlen == -1) { if (errno != EINTR) logit(LOG_ERR, errno, "RSRR recvfrom"); return; @@ -370,7 +370,7 @@ rsrr_send(int sendlen) (struct sockaddr *)&client_addr, client_length); /* Check for errors. */ - if (error < 0) { + if (error == -1) { logit(LOG_WARNING, errno, "Failed send on RSRR socket"); } else if (error != sendlen) { logit(LOG_WARNING, 0, diff --git a/usr.sbin/mrouted/vif.c b/usr.sbin/mrouted/vif.c index be1baf52299..c228a88c494 100644 --- a/usr.sbin/mrouted/vif.c +++ b/usr.sbin/mrouted/vif.c @@ -71,7 +71,7 @@ init_vifs(void) * the kernel and the contents of the configuration file. * (Open a UDP socket for ioctl use in the config procedures.) */ - if ((udp_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if ((udp_socket = socket(AF_INET, SOCK_DGRAM, 0)) == -1) logit(LOG_ERR, errno, "UDP socket"); logit(LOG_INFO,0,"Getting vifs from kernel interfaces"); config_vifs_from_kernel(); @@ -169,7 +169,7 @@ check_vif_state(void) if (v->uv_flags & VIFF_DISABLED) continue; strncpy(ifr.ifr_name, v->uv_name, IFNAMSIZ); - if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ifr) < 0) + if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ifr) == -1) logit(LOG_ERR, errno, "ioctl SIOCGIFFLAGS for %s", ifr.ifr_name); @@ -702,9 +702,9 @@ accept_neighbor_request(u_int32_t src, u_int32_t dst) addr.sin_len = sizeof addr; addr.sin_addr.s_addr = dst; addr.sin_port = htons(2000); /* any port over 1024 will do... */ - if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0 - || connect(udp, (struct sockaddr *) &addr, sizeof(addr)) < 0 - || getsockname(udp, (struct sockaddr *) &addr, &addrlen) < 0) { + if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) == -1 + || connect(udp, (struct sockaddr *) &addr, sizeof(addr)) == -1 + || getsockname(udp, (struct sockaddr *) &addr, &addrlen) == -1) { logit(LOG_WARNING, errno, "Determining local address"); close(udp); return; @@ -787,9 +787,9 @@ accept_neighbor_request2(u_int32_t src, u_int32_t dst) addr.sin_len = sizeof addr; addr.sin_addr.s_addr = dst; addr.sin_port = htons(2000); /* any port over 1024 will do... */ - if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0 - || connect(udp, (struct sockaddr *) &addr, sizeof(addr)) < 0 - || getsockname(udp, (struct sockaddr *) &addr, &addrlen) < 0) { + if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) == -1 + || connect(udp, (struct sockaddr *) &addr, sizeof(addr)) == -1 + || getsockname(udp, (struct sockaddr *) &addr, &addrlen) == -1) { logit(LOG_WARNING, errno, "Determining local address"); close(udp); return; @@ -1332,7 +1332,7 @@ dump_vifs(FILE *fp) } } v_req.vifi = vifi; - if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) < 0) { + if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) == -1) { logit(LOG_WARNING, 0, "SIOCGETVIFCNT fails"); } diff --git a/usr.sbin/mtrace/mtrace.c b/usr.sbin/mtrace/mtrace.c index 8b5e657fa0d..5acf9ab3171 100644 --- a/usr.sbin/mtrace/mtrace.c +++ b/usr.sbin/mtrace/mtrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mtrace.c,v 1.39 2017/08/31 12:03:02 otto Exp $ */ +/* $OpenBSD: mtrace.c,v 1.40 2019/06/28 13:32:49 deraadt Exp $ */ /* $NetBSD: mtrace.c,v 1.5 1995/12/10 10:57:15 mycroft Exp $ */ /* @@ -443,7 +443,7 @@ send_recv(u_int32_t dst, int type, int code, int tries, struct resp_buf *save) count = poll(pfd, 1, tv.tv_sec * 1000); - if (count < 0) { + if (count == -1) { if (errno != EINTR) perror("poll"); continue; } else if (count == 0) { @@ -1280,9 +1280,9 @@ usage: mtrace [-lMnpsv] [-g gateway] [-i if_addr] [-m max_hops] [-q nqueries]\n\ addr.sin_addr.s_addr = qgrp; addr.sin_port = htons(2000); /* Any port above 1024 will do */ - if (((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0) || - (connect(udp, (struct sockaddr *) &addr, sizeof(addr)) < 0) || - getsockname(udp, (struct sockaddr *) &addr, &addrlen) < 0) { + if (((udp = socket(AF_INET, SOCK_DGRAM, 0)) == -1) || + (connect(udp, (struct sockaddr *) &addr, sizeof(addr)) == -1) || + getsockname(udp, (struct sockaddr *) &addr, &addrlen) == -1) { perror("Determining local address"); exit(1); } diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index 0582e75c39c..e759d9f09b5 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -1,5 +1,5 @@ /* $NetBSD: compare.c,v 1.11 1996/09/05 09:56:48 mycroft Exp $ */ -/* $OpenBSD: compare.c,v 1.27 2016/08/16 16:41:46 krw Exp $ */ +/* $OpenBSD: compare.c,v 1.28 2019/06/28 13:32:49 deraadt Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -220,7 +220,7 @@ typeerr: LABEL; } } if (s->flags & F_CKSUM) { - if ((fd = open(p->fts_accpath, MTREE_O_FLAGS, 0)) < 0) { + if ((fd = open(p->fts_accpath, MTREE_O_FLAGS, 0)) == -1) { LABEL; (void)printf("%scksum: %s: %s\n", tab, p->fts_accpath, strerror(errno)); diff --git a/usr.sbin/mtree/crc.c b/usr.sbin/mtree/crc.c index c33b8ac061b..7098c0a7e50 100644 --- a/usr.sbin/mtree/crc.c +++ b/usr.sbin/mtree/crc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crc.c,v 1.3 2009/10/27 23:59:53 deraadt Exp $ */ +/* $OpenBSD: crc.c,v 1.4 2019/06/28 13:32:49 deraadt Exp $ */ /* $NetBSD: crc.c,v 1.7 1996/02/27 21:29:53 jtc Exp $ */ /*- @@ -118,7 +118,7 @@ crc(int fd, u_int32_t *cval, u_int32_t *clen) COMPUTE(crc, *p); COMPUTE(crc_total, *p); } - if (nr < 0) + if (nr == -1) return (1); *clen = len; diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c index 45feab40277..bcab0023ead 100644 --- a/usr.sbin/mtree/create.c +++ b/usr.sbin/mtree/create.c @@ -1,5 +1,5 @@ /* $NetBSD: create.c,v 1.11 1996/09/05 09:24:19 mycroft Exp $ */ -/* $OpenBSD: create.c,v 1.33 2018/09/16 02:41:16 millert Exp $ */ +/* $OpenBSD: create.c,v 1.34 2019/06/28 13:32:49 deraadt Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -192,7 +192,7 @@ statf(int indent, FTSENT *p) (long long)p->fts_statp->st_mtimespec.tv_sec, p->fts_statp->st_mtimespec.tv_nsec); if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) { - if ((fd = open(p->fts_accpath, MTREE_O_FLAGS, 0)) < 0 || + if ((fd = open(p->fts_accpath, MTREE_O_FLAGS, 0)) == -1 || crc(fd, &val, &len)) error("%s: %s", p->fts_accpath, strerror(errno)); (void)close(fd); diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index 2791d8b0375..099cb155c74 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ndp.c,v 1.92 2019/01/22 09:25:29 krw Exp $ */ +/* $OpenBSD: ndp.c,v 1.93 2019/06/28 13:32:49 deraadt Exp $ */ /* $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $ */ /* @@ -289,9 +289,9 @@ getsocket(void) if (rtsock >= 0) return; rtsock = socket(AF_ROUTE, SOCK_RAW, 0); - if (rtsock < 0) + if (rtsock == -1) err(1, "routing socket"); - if (setsockopt(rtsock, AF_ROUTE, ROUTE_TABLEFILTER, &rdomain, len) < 0) + if (setsockopt(rtsock, AF_ROUTE, ROUTE_TABLEFILTER, &rdomain, len) == -1) err(1, "ROUTE_TABLEFILTER"); if (pledge("stdio dns", NULL) == -1) @@ -700,13 +700,13 @@ getnbrinfo(struct in6_addr *addr, int ifindex, int warning) static struct in6_nbrinfo nbi; int s; - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) + if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) == -1) err(1, "socket"); bzero(&nbi, sizeof(nbi)); if_indextoname(ifindex, nbi.ifname); nbi.addr = *addr; - if (ioctl(s, SIOCGNBRINFO_IN6, (caddr_t)&nbi) < 0) { + if (ioctl(s, SIOCGNBRINFO_IN6, (caddr_t)&nbi) == -1) { if (warning) warn("ioctl(SIOCGNBRINFO_IN6)"); close(s); @@ -814,7 +814,7 @@ doit: l = rtm->rtm_msglen; rtm->rtm_seq = ++seq; rtm->rtm_type = cmd; - if ((rlen = write(rtsock, (char *)&m_rtmsg, l)) < 0) { + if ((rlen = write(rtsock, (char *)&m_rtmsg, l)) == -1) { if (errno != ESRCH || cmd != RTM_DELETE) { err(1, "writing to routing socket"); /* NOTREACHED */ @@ -824,7 +824,7 @@ doit: l = read(rtsock, (char *)&m_rtmsg, sizeof(m_rtmsg)); } while (l > 0 && (rtm->rtm_version != RTM_VERSION || rtm->rtm_seq != seq || rtm->rtm_pid != pid)); - if (l < 0) + if (l == -1) (void) fprintf(stderr, "ndp: read from routing socket: %s\n", strerror(errno)); return (0); @@ -878,13 +878,13 @@ ifinfo(char *ifname) struct in6_ndireq nd; int s; - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { + if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) == -1) { err(1, "socket"); /* NOTREACHED */ } bzero(&nd, sizeof(nd)); strlcpy(nd.ifname, ifname, sizeof(nd.ifname)); - if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) + if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) == -1) err(1, "ioctl(SIOCGIFINFO_IN6)"); if (!nd.ndi.initialized) diff --git a/usr.sbin/npppctl/npppctl.c b/usr.sbin/npppctl/npppctl.c index 45c2a50185d..82706168073 100644 --- a/usr.sbin/npppctl/npppctl.c +++ b/usr.sbin/npppctl/npppctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npppctl.c,v 1.8 2017/08/11 16:25:59 goda Exp $ */ +/* $OpenBSD: npppctl.c,v 1.9 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2012 Internet Initiative Japan Inc. @@ -102,12 +102,12 @@ main(int argc, char *argv[]) if ((result = parse(argc, argv)) == NULL) exit(EXIT_FAILURE); - if ((ctlsock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) + if ((ctlsock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) err(EXIT_FAILURE, "socket"); memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_UNIX; strlcpy(sun.sun_path, npppd_ctlpath, sizeof(sun.sun_path)); - if (connect(ctlsock, (struct sockaddr *)&sun, sizeof(sun)) < 0) + if (connect(ctlsock, (struct sockaddr *)&sun, sizeof(sun)) == -1) err(EXIT_FAILURE, "connect"); imsg_init(&ctl_ibuf, ctlsock); diff --git a/usr.sbin/ntpd/constraint.c b/usr.sbin/ntpd/constraint.c index f1af7fa602a..f478ec789e9 100644 --- a/usr.sbin/ntpd/constraint.c +++ b/usr.sbin/ntpd/constraint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: constraint.c,v 1.46 2019/06/16 07:36:25 otto Exp $ */ +/* $OpenBSD: constraint.c,v 1.47 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -955,7 +955,7 @@ httpsdate_request(struct httpsdate *httpsdate, struct timeval *when) ret = tls_write(httpsdate->tls_ctx, buf, len); if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT) continue; - if (ret < 0) { + if (ret == -1) { log_warnx("tls write failed: %s (%s): %s", httpsdate->tls_addr, httpsdate->tls_hostname, tls_error(httpsdate->tls_ctx)); @@ -1091,7 +1091,7 @@ tls_readline(struct tls *tls, size_t *lenp, size_t *maxlength, ret = tls_read(tls, &c, 1); if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT) goto again; - if (ret < 0) { + if (ret == -1) { /* SSL read error, ignore */ free(buf); return (NULL); diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c index 33037db8464..ef1b43e133a 100644 --- a/usr.sbin/ntpd/ntpd.c +++ b/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.123 2019/06/27 15:18:42 otto Exp $ */ +/* $OpenBSD: ntpd.c,v 1.124 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -111,7 +111,7 @@ auto_preconditions(const struct ntpd_conf *cnf) int constraints, securelevel; size_t sz = sizeof(int); - if (sysctl(mib, 2, &securelevel, &sz, NULL, 0) < 0) + if (sysctl(mib, 2, &securelevel, &sz, NULL, 0) == -1) err(1, "sysctl"); constraints = !TAILQ_EMPTY(&cnf->constraints); return !cnf->settime && constraints && securelevel == 0; diff --git a/usr.sbin/ocspcheck/http.c b/usr.sbin/ocspcheck/http.c index 5c914a48571..e0df6cfa118 100644 --- a/usr.sbin/ocspcheck/http.c +++ b/usr.sbin/ocspcheck/http.c @@ -1,4 +1,4 @@ -/* $Id: http.c,v 1.11 2018/11/29 14:25:07 tedu Exp $ */ +/* $Id: http.c,v 1.12 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -72,7 +72,7 @@ dosysread(char *buf, size_t sz, const struct http *http) ssize_t rc; rc = read(http->fd, buf, sz); - if (rc < 0) + if (rc == -1) warn("%s: read", http->src.ip); return rc; } @@ -83,7 +83,7 @@ dosyswrite(const void *buf, size_t sz, const struct http *http) ssize_t rc; rc = write(http->fd, buf, sz); - if (rc < 0) + if (rc == -1) warn("%s: write", http->src.ip); return rc; } @@ -97,7 +97,7 @@ dotlsread(char *buf, size_t sz, const struct http *http) rc = tls_read(http->ctx, buf, sz); } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT); - if (rc < 0) + if (rc == -1) warnx("%s: tls_read: %s", http->src.ip, tls_error(http->ctx)); return rc; @@ -112,7 +112,7 @@ dotlswrite(const void *buf, size_t sz, const struct http *http) rc = tls_write(http->ctx, buf, sz); } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT); - if (rc < 0) + if (rc == -1) warnx("%s: tls_write: %s", http->src.ip, tls_error(http->ctx)); return rc; diff --git a/usr.sbin/ospf6d/interface.c b/usr.sbin/ospf6d/interface.c index d97a1149347..9feb8c69e96 100644 --- a/usr.sbin/ospf6d/interface.c +++ b/usr.sbin/ospf6d/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.24 2018/07/12 13:45:03 remi Exp $ */ +/* $OpenBSD: interface.c,v 1.25 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -735,7 +735,7 @@ if_join_group(struct iface *iface, struct in6_addr *addr) mreq.ipv6mr_interface = iface->ifindex; if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, - &mreq, sizeof(mreq)) < 0) { + &mreq, sizeof(mreq)) == -1) { log_warn("if_join_group: error IPV6_JOIN_GROUP, " "interface %s address %s", iface->name, log_in6addr(addr)); @@ -769,7 +769,7 @@ if_leave_group(struct iface *iface, struct in6_addr *addr) mreq.ipv6mr_interface = iface->ifindex; if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_LEAVE_GROUP, - (void *)&mreq, sizeof(mreq)) < 0) { + (void *)&mreq, sizeof(mreq)) == -1) { log_warn("if_leave_group: error IPV6_LEAVE_GROUP, " "interface %s address %s", iface->name, log_in6addr(addr)); @@ -795,7 +795,7 @@ if_set_mcast(struct iface *iface) case IF_TYPE_POINTOPOINT: case IF_TYPE_BROADCAST: if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, - &iface->ifindex, sizeof(iface->ifindex)) < 0) { + &iface->ifindex, sizeof(iface->ifindex)) == -1) { log_debug("if_set_mcast: error setting " "IP_MULTICAST_IF, interface %s", iface->name); return (-1); @@ -820,7 +820,7 @@ if_set_mcast_loop(int fd) u_int loop = 0; if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, - (u_int *)&loop, sizeof(loop)) < 0) { + (u_int *)&loop, sizeof(loop)) == -1) { log_warn("if_set_mcast_loop: error setting " "IPV6_MULTICAST_LOOP"); return (-1); @@ -833,7 +833,7 @@ int if_set_ipv6_pktinfo(int fd, int enable) { if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &enable, - sizeof(enable)) < 0) { + sizeof(enable)) == -1) { log_warn("if_set_ipv6_pktinfo: error setting IPV6_PKTINFO"); return (-1); } @@ -848,7 +848,7 @@ if_set_ipv6_checksum(int fd) log_debug("if_set_ipv6_checksum setting cksum offset to %d", offset); if (setsockopt(fd, IPPROTO_IPV6, IPV6_CHECKSUM, &offset, - sizeof(offset)) < 0) { + sizeof(offset)) == -1) { log_warn("if_set_ipv6_checksum: error setting IPV6_CHECKSUM"); return (-1); } diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c index 57a9ce2f01d..1d966f34b59 100644 --- a/usr.sbin/ospfd/interface.c +++ b/usr.sbin/ospfd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.82 2018/03/11 13:16:49 claudio Exp $ */ +/* $OpenBSD: interface.c,v 1.83 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -663,7 +663,7 @@ int if_set_recvif(int fd, int enable) { if (setsockopt(fd, IPPROTO_IP, IP_RECVIF, &enable, - sizeof(enable)) < 0) { + sizeof(enable)) == -1) { log_warn("if_set_recvif: error setting IP_RECVIF"); return (-1); } @@ -734,7 +734,7 @@ if_join_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = iface->addr.s_addr; if (setsockopt(iface->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, - (void *)&mreq, sizeof(mreq)) < 0) { + (void *)&mreq, sizeof(mreq)) == -1) { log_warn("if_join_group: error IP_ADD_MEMBERSHIP, " "interface %s address %s", iface->name, inet_ntoa(*addr)); @@ -782,7 +782,7 @@ if_leave_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = iface->addr.s_addr; if (setsockopt(iface->fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, - (void *)&mreq, sizeof(mreq)) < 0) { + (void *)&mreq, sizeof(mreq)) == -1) { log_warn("if_leave_group: error IP_DROP_MEMBERSHIP, " "interface %s address %s", iface->name, inet_ntoa(*addr)); @@ -809,7 +809,7 @@ if_set_mcast(struct iface *iface) case IF_TYPE_POINTOPOINT: case IF_TYPE_BROADCAST: if (setsockopt(iface->fd, IPPROTO_IP, IP_MULTICAST_IF, - &iface->addr.s_addr, sizeof(iface->addr.s_addr)) < 0) { + &iface->addr.s_addr, sizeof(iface->addr.s_addr)) == -1) { log_warn("if_set_mcast: error setting " "IP_MULTICAST_IF, interface %s", iface->name); return (-1); @@ -834,7 +834,7 @@ if_set_mcast_loop(int fd) u_int8_t loop = 0; if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, - (char *)&loop, sizeof(loop)) < 0) { + (char *)&loop, sizeof(loop)) == -1) { log_warn("if_set_mcast_loop: error setting IP_MULTICAST_LOOP"); return (-1); } @@ -847,7 +847,7 @@ if_set_ip_hdrincl(int fd) { int hincl = 1; - if (setsockopt(fd, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof(hincl)) < 0) { + if (setsockopt(fd, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof(hincl)) == -1) { log_warn("if_set_ip_hdrincl: error setting IP_HDRINCL"); return (-1); } diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c index 7f4a47fabf7..6f159bb9d6a 100644 --- a/usr.sbin/pcidump/pcidump.c +++ b/usr.sbin/pcidump/pcidump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcidump.c,v 1.54 2019/06/02 02:37:12 dlg Exp $ */ +/* $OpenBSD: pcidump.c,v 1.55 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2006, 2007 David Gwynne <loki@animata.net> @@ -903,14 +903,14 @@ dump_rom(int bus, int dev, int func) rom.pr_sel.pc_bus = bus; rom.pr_sel.pc_dev = dev; rom.pr_sel.pc_func = func; - if (ioctl(pcifd, PCIOCGETROMLEN, &rom)) + if (ioctl(pcifd, PCIOCGETROMLEN, &rom) == -1) return (errno); rom.pr_rom = malloc(rom.pr_romlen); if (rom.pr_rom == NULL) return (ENOMEM); - if (ioctl(pcifd, PCIOCGETROM, &rom)) + if (ioctl(pcifd, PCIOCGETROM, &rom) == -1) return (errno); if (write(romfd, rom.pr_rom, rom.pr_romlen) == -1) diff --git a/usr.sbin/portmap/portmap.c b/usr.sbin/portmap/portmap.c index e7eea45b43f..f8791d4e097 100644 --- a/usr.sbin/portmap/portmap.c +++ b/usr.sbin/portmap/portmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: portmap.c,v 1.49 2018/08/04 03:23:08 deraadt Exp $ */ +/* $OpenBSD: portmap.c,v 1.50 2019/06/28 13:32:49 deraadt Exp $ */ /*- * Copyright (c) 1996, 1997 Theo de Raadt (OpenBSD). All rights reserved. @@ -138,12 +138,12 @@ main(int argc, char *argv[]) laddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); laddr.sin_port = htons(PMAPPORT); - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { syslog(LOG_ERR, "cannot create udp socket: %m"); exit(1); } setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on); - if (bind(sock, (struct sockaddr *)&addr, len) != 0) { + if (bind(sock, (struct sockaddr *)&addr, len) == -1) { syslog(LOG_ERR, "cannot bind udp: %m"); exit(1); } @@ -153,12 +153,12 @@ main(int argc, char *argv[]) exit(1); } - if ((lsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + if ((lsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { syslog(LOG_ERR, "cannot create udp socket: %m"); exit(1); } setsockopt(lsock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on); - if (bind(lsock, (struct sockaddr *)&laddr, len) != 0) { + if (bind(lsock, (struct sockaddr *)&laddr, len) == -1) { syslog(LOG_ERR, "cannot bind local udp: %m"); exit(1); } @@ -181,12 +181,12 @@ main(int argc, char *argv[]) pml->pml_map.pm_port = PMAPPORT; pmaplist = pml; - if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { + if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { syslog(LOG_ERR, "cannot create tcp socket: %m"); exit(1); } setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on); - if (bind(sock, (struct sockaddr *)&addr, len) != 0) { + if (bind(sock, (struct sockaddr *)&addr, len) == -1) { syslog(LOG_ERR, "cannot bind tcp: %m"); exit(1); } @@ -196,12 +196,12 @@ main(int argc, char *argv[]) exit(1); } - if ((lsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { + if ((lsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { syslog(LOG_ERR, "cannot create tcp socket: %m"); exit(1); } setsockopt(lsock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on); - if (bind(lsock, (struct sockaddr *)&laddr, len) != 0) { + if (bind(lsock, (struct sockaddr *)&laddr, len) == -1) { syslog(LOG_ERR, "cannot bind tcp: %m"); exit(1); } diff --git a/usr.sbin/pppd/sys-bsd.c b/usr.sbin/pppd/sys-bsd.c index 69ca841d213..e8deee6d2ff 100644 --- a/usr.sbin/pppd/sys-bsd.c +++ b/usr.sbin/pppd/sys-bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys-bsd.c,v 1.28 2019/01/22 09:25:29 krw Exp $ */ +/* $OpenBSD: sys-bsd.c,v 1.29 2019/06/28 13:32:49 deraadt Exp $ */ /* * sys-bsd.c - System-dependent procedures for setting up @@ -161,7 +161,7 @@ void sys_init() { /* Get an internet socket for doing socket ioctl's on. */ - if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { syslog(LOG_ERR, "Couldn't create IP socket: %m"); die(1); } @@ -179,7 +179,7 @@ sys_cleanup() if (if_is_up) { strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) >= 0 + if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) == 0 && ((ifr.ifr_flags & IFF_UP) != 0)) { ifr.ifr_flags &= ~IFF_UP; ioctl(sockfd, SIOCSIFFLAGS, &ifr); @@ -225,11 +225,11 @@ ppp_available() struct ifreq ifr; extern char *no_ppp_msg; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) return 1; /* can't tell */ strlcpy(ifr.ifr_name, "ppp0", sizeof(ifr.ifr_name)); - ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; + ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) == 0; close(s); no_ppp_msg = "\ @@ -252,7 +252,7 @@ establish_ppp(fd) /* * Demand mode - prime the old ppp device to relinquish the unit. */ - if (ioctl(ppp_fd, PPPIOCXFERUNIT, 0) < 0) { + if (ioctl(ppp_fd, PPPIOCXFERUNIT, 0) == -1) { syslog(LOG_ERR, "ioctl(transfer ppp unit): %m"); die(1); } @@ -261,11 +261,11 @@ establish_ppp(fd) /* * Save the old line discipline of fd, and set it to PPP. */ - if (ioctl(fd, TIOCGETD, &initdisc) < 0) { + if (ioctl(fd, TIOCGETD, &initdisc) == -1) { syslog(LOG_ERR, "ioctl(TIOCGETD): %m"); die(1); } - if (ioctl(fd, TIOCSETD, &pppdisc) < 0) { + if (ioctl(fd, TIOCSETD, &pppdisc) == -1) { syslog(LOG_ERR, "ioctl(TIOCSETD): %m"); die(1); } @@ -274,7 +274,7 @@ establish_ppp(fd) /* * Find out which interface we were given. */ - if (ioctl(fd, PPPIOCGUNIT, &ifunit) < 0) { + if (ioctl(fd, PPPIOCGUNIT, &ifunit) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m"); die(1); } @@ -282,7 +282,7 @@ establish_ppp(fd) /* * Check that we got the same unit again. */ - if (ioctl(fd, PPPIOCGUNIT, &x) < 0) { + if (ioctl(fd, PPPIOCGUNIT, &x) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m"); die(1); } @@ -301,11 +301,11 @@ establish_ppp(fd) * Enable debug in the driver if requested. */ if (kdebugflag) { - if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { + if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) == -1) { syslog(LOG_WARNING, "ioctl (PPPIOCGFLAGS): %m"); } else { x |= (kdebugflag & 0xFF) * SC_DEBUG; - if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) + if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) == -1) syslog(LOG_WARNING, "ioctl(PPPIOCSFLAGS): %m"); } } @@ -330,12 +330,12 @@ restore_loop() /* * Transfer the ppp interface back to the loopback. */ - if (ioctl(ppp_fd, PPPIOCXFERUNIT, 0) < 0) { + if (ioctl(ppp_fd, PPPIOCXFERUNIT, 0) == -1) { syslog(LOG_ERR, "ioctl(transfer ppp unit): %m"); die(1); } x = PPPDISC; - if (ioctl(loop_slave, TIOCSETD, &x) < 0) { + if (ioctl(loop_slave, TIOCSETD, &x) == -1) { syslog(LOG_ERR, "ioctl(TIOCSETD): %m"); die(1); } @@ -343,7 +343,7 @@ restore_loop() /* * Check that we got the same unit again. */ - if (ioctl(loop_slave, PPPIOCGUNIT, &x) < 0) { + if (ioctl(loop_slave, PPPIOCGUNIT, &x) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m"); die(1); } @@ -364,12 +364,12 @@ disestablish_ppp(fd) int fd; { /* Reset non-blocking mode on fd. */ - if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0) + if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) == -1) syslog(LOG_WARNING, "Couldn't restore device fd flags: %m"); initfdflags = -1; /* Restore old line discipline. */ - if (initdisc >= 0 && ioctl(fd, TIOCSETD, &initdisc) < 0) + if (initdisc >= 0 && ioctl(fd, TIOCSETD, &initdisc) == -1) syslog(LOG_ERR, "ioctl(TIOCSETD): %m"); initdisc = -1; @@ -422,7 +422,7 @@ set_up_tty(fd, local) { struct termios tios; - if (tcgetattr(fd, &tios) < 0) { + if (tcgetattr(fd, &tios) == -1) { syslog(LOG_ERR, "tcgetattr: %m"); die(1); } @@ -470,7 +470,7 @@ set_up_tty(fd, local) } baud_rate = inspeed; - if (tcsetattr(fd, TCSAFLUSH, &tios) < 0) { + if (tcsetattr(fd, TCSAFLUSH, &tios) == -1) { syslog(LOG_ERR, "tcsetattr: %m"); die(1); } @@ -495,7 +495,7 @@ restore_tty(fd) */ inittermios.c_lflag &= ~(ECHO | ECHONL); } - if (tcsetattr(fd, TCSAFLUSH, &inittermios) < 0) + if (tcsetattr(fd, TCSAFLUSH, &inittermios) == -1) if (errno != ENXIO) syslog(LOG_WARNING, "tcsetattr: %m"); ioctl(fd, TIOCSWINSZ, &wsinfo); @@ -529,7 +529,7 @@ open_ppp_loopback() struct termios tios; int pppdisc = PPPDISC; - if (openpty(&loop_master, &loop_slave, loop_name, NULL, NULL) < 0) { + if (openpty(&loop_master, &loop_slave, loop_name, NULL, NULL) == -1) { syslog(LOG_ERR, "No free pty for loopback"); die(1); } @@ -541,7 +541,7 @@ open_ppp_loopback() tios.c_iflag = IGNPAR; tios.c_oflag = 0; tios.c_lflag = 0; - if (tcsetattr(loop_slave, TCSAFLUSH, &tios) < 0) + if (tcsetattr(loop_slave, TCSAFLUSH, &tios) == -1) syslog(LOG_WARNING, "couldn't set attributes on loopback: %m"); } @@ -550,7 +550,7 @@ open_ppp_loopback() syslog(LOG_WARNING, "couldn't set loopback to nonblock: %m"); ppp_fd = loop_slave; - if (ioctl(ppp_fd, TIOCSETD, &pppdisc) < 0) { + if (ioctl(ppp_fd, TIOCSETD, &pppdisc) == -1) { syslog(LOG_ERR, "ioctl(TIOCSETD): %m"); die(1); } @@ -558,7 +558,7 @@ open_ppp_loopback() /* * Find out which interface we were given. */ - if (ioctl(ppp_fd, PPPIOCGUNIT, &ifunit) < 0) { + if (ioctl(ppp_fd, PPPIOCGUNIT, &ifunit) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m"); die(1); } @@ -567,11 +567,11 @@ open_ppp_loopback() * Enable debug in the driver if requested. */ if (kdebugflag) { - if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &flags) < 0) { + if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &flags) == -1) { syslog(LOG_WARNING, "ioctl (PPPIOCGFLAGS): %m"); } else { flags |= (kdebugflag & 0xFF) * SC_DEBUG; - if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &flags) < 0) + if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &flags) == -1) syslog(LOG_WARNING, "ioctl(PPPIOCSFLAGS): %m"); } } @@ -591,7 +591,7 @@ output(unit, p, len) if (debug) log_packet(p, len, "sent ", LOG_DEBUG); - if (write(ttyfd, p, len) < 0) { + if (write(ttyfd, p, len) == -1) { if (errno != EIO) syslog(LOG_ERR, "write: %m"); } @@ -618,7 +618,7 @@ wait_input(timo) FD_SET(ttyfd, fdsp); n = select(ttyfd+1, fdsp, NULL, fdsp, timo); - if (n < 0 && errno != EINTR) { + if (n == -1 && errno != EINTR) { syslog(LOG_ERR, "select: %m"); free(fdsp); die(1); @@ -647,7 +647,7 @@ wait_loop_output(timo) FD_SET(loop_master, fdsp); n = select(loop_master + 1, fdsp, NULL, fdsp, timo); - if (n < 0 && errno != EINTR) { + if (n == -1 && errno != EINTR) { syslog(LOG_ERR, "select: %m"); free(fdsp); die(1); @@ -667,7 +667,7 @@ wait_time(timo) int n; n = select(0, NULL, NULL, NULL, timo); - if (n < 0 && errno != EINTR) { + if (n == -1 && errno != EINTR) { syslog(LOG_ERR, "select: %m"); die(1); } @@ -683,7 +683,7 @@ read_packet(buf) { int len; - if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) { + if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) == -1) { if (errno == EWOULDBLOCK || errno == EINTR) return -1; syslog(LOG_ERR, "read: %m"); @@ -736,23 +736,23 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp) strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); ifr.ifr_mtu = mtu; - if (ioctl(sockfd, SIOCSIFMTU, (caddr_t) &ifr) < 0) { + if (ioctl(sockfd, SIOCSIFMTU, (caddr_t) &ifr) == -1) { syslog(LOG_ERR, "ioctl(SIOCSIFMTU): %m"); quit(); } - if (ioctl(ppp_fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0) { + if (ioctl(ppp_fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCSASYNCMAP): %m"); quit(); } - if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { + if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) == -1) { syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m"); quit(); } x = pcomp? x | SC_COMP_PROT: x &~ SC_COMP_PROT; x = accomp? x | SC_COMP_AC: x &~ SC_COMP_AC; - if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { + if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); quit(); } @@ -767,7 +767,7 @@ ppp_set_xaccm(unit, accm) int unit; ext_accm accm; { - if (ioctl(ppp_fd, PPPIOCSXASYNCMAP, accm) < 0 && errno != ENOTTY) + if (ioctl(ppp_fd, PPPIOCSXASYNCMAP, accm) == -1 && errno != ENOTTY) syslog(LOG_WARNING, "ioctl(set extended ACCM): %m"); } @@ -784,20 +784,20 @@ ppp_recv_config(unit, mru, asyncmap, pcomp, accomp) { int x; - if (ioctl(ppp_fd, PPPIOCSMRU, (caddr_t) &mru) < 0) { + if (ioctl(ppp_fd, PPPIOCSMRU, (caddr_t) &mru) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCSMRU): %m"); quit(); } - if (ioctl(ppp_fd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) < 0) { + if (ioctl(ppp_fd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCSRASYNCMAP): %m"); quit(); } - if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { + if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) == -1) { syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m"); quit(); } x = !accomp? x | SC_REJ_COMP_AC: x &~ SC_REJ_COMP_AC; - if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { + if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); quit(); } @@ -833,13 +833,13 @@ ccp_flags_set(unit, isopen, isup) { int x; - if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { + if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) == -1) { syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m"); return; } x = isopen? x | SC_CCP_OPEN: x &~ SC_CCP_OPEN; x = isup? x | SC_CCP_UP: x &~ SC_CCP_UP; - if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) + if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) == -1) syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); } @@ -854,7 +854,7 @@ ccp_fatal_error(unit) { int x; - if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { + if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCGFLAGS): %m"); return 0; } @@ -884,13 +884,13 @@ set_filters(pass, active) int ret = 1; if (pass->bf_len > 0) { - if (ioctl(ppp_fd, PPPIOCSPASS, pass) < 0) { + if (ioctl(ppp_fd, PPPIOCSPASS, pass) == -1) { syslog(LOG_ERR, "Couldn't set pass-filter in kernel: %m"); ret = 0; } } if (active->bf_len > 0) { - if (ioctl(ppp_fd, PPPIOCSACTIVE, active) < 0) { + if (ioctl(ppp_fd, PPPIOCSACTIVE, active) == -1) { syslog(LOG_ERR, "Couldn't set active-filter in kernel: %m"); ret = 0; } @@ -908,17 +908,17 @@ sifvjcomp(u, vjcomp, cidcomp, maxcid) { u_int x; - if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { + if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) == -1) { syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m"); return 0; } x = vjcomp ? x | SC_COMP_TCP: x &~ SC_COMP_TCP; x = cidcomp? x & ~SC_NO_TCP_CCID: x | SC_NO_TCP_CCID; - if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { + if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); return 0; } - if (vjcomp && ioctl(ppp_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) { + if (vjcomp && ioctl(ppp_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) == -1) { syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); return 0; } @@ -935,12 +935,12 @@ sifup(u) struct ifreq ifr; strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { + if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) == -1) { syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m"); return 0; } ifr.ifr_flags |= IFF_UP; - if (ioctl(sockfd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) { + if (ioctl(sockfd, SIOCSIFFLAGS, (caddr_t) &ifr) == -1) { syslog(LOG_ERR, "ioctl(SIOCSIFFLAGS): %m"); return 0; } @@ -961,7 +961,7 @@ sifnpmode(u, proto, mode) npi.protocol = proto; npi.mode = mode; - if (ioctl(ppp_fd, PPPIOCSNPMODE, &npi) < 0) { + if (ioctl(ppp_fd, PPPIOCSNPMODE, &npi) == -1) { syslog(LOG_ERR, "ioctl(set NP %d mode to %d): %m", proto, mode); return 0; } @@ -986,12 +986,12 @@ sifdown(u) /* ignore errors, because ppp_fd might have been closed by now. */ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { + if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) == -1) { syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m"); rv = 0; } else { ifr.ifr_flags &= ~IFF_UP; - if (ioctl(sockfd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) { + if (ioctl(sockfd, SIOCSIFFLAGS, (caddr_t) &ifr) == -1) { syslog(LOG_ERR, "ioctl(SIOCSIFFLAGS): %m"); rv = 0; } else @@ -1033,11 +1033,11 @@ sifaddr(u, o, h, m) BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask)); BZERO(&ifr, sizeof(ifr)); strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifr) < 0) { + if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifr) == -1) { if (errno != EADDRNOTAVAIL) syslog(LOG_WARNING, "Couldn't remove interface address: %m"); } - if (ioctl(sockfd, SIOCAIFADDR, (caddr_t) &ifra) < 0) { + if (ioctl(sockfd, SIOCAIFADDR, (caddr_t) &ifra) == -1) { if (errno != EEXIST) { syslog(LOG_ERR, "Couldn't set interface address: %m"); return 0; @@ -1071,7 +1071,7 @@ cifaddr(u, o, h) SET_SA_FAMILY(ifra.ifra_broadaddr, AF_INET); ((struct sockaddr_in *) &ifra.ifra_broadaddr)->sin_addr.s_addr = h; BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask)); - if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifra) < 0) { + if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifra) == -1) { if (errno != EADDRNOTAVAIL) syslog(LOG_WARNING, "Couldn't delete interface address: %m"); return 0; @@ -1117,7 +1117,7 @@ dodefaultroute(g, cmd) struct sockaddr_in mask; } rtmsg; - if ((routes = socket(AF_ROUTE, SOCK_RAW, AF_INET)) < 0) { + if ((routes = socket(AF_ROUTE, SOCK_RAW, AF_INET)) == -1) { syslog(LOG_ERR, "Couldn't %s default route: socket: %m", cmd=='s'? "add": "delete"); return 0; @@ -1138,7 +1138,7 @@ dodefaultroute(g, cmd) rtmsg.mask.sin_family = AF_INET; rtmsg.hdr.rtm_msglen = sizeof(rtmsg); - if (write(routes, &rtmsg, sizeof(rtmsg)) < 0) { + if (write(routes, &rtmsg, sizeof(rtmsg)) == -1) { syslog(LOG_ERR, "Couldn't %s default route: %m", cmd=='s'? "add": "delete"); close(routes); @@ -1181,7 +1181,7 @@ sifproxyarp(unit, hisaddr) return 0; } - if ((routes = socket(AF_ROUTE, SOCK_RAW, AF_INET)) < 0) { + if ((routes = socket(AF_ROUTE, SOCK_RAW, AF_INET)) == -1) { syslog(LOG_ERR, "Couldn't add proxy arp entry: socket: %m"); return 0; } @@ -1199,7 +1199,7 @@ sifproxyarp(unit, hisaddr) arpmsg.hdr.rtm_msglen = (char *) &arpmsg.hwa - (char *) &arpmsg + arpmsg.hwa.sdl_len; - if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) { + if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) == -1) { syslog(LOG_ERR, "Couldn't add proxy arp entry: %m"); close(routes); return 0; @@ -1228,12 +1228,12 @@ cifproxyarp(unit, hisaddr) arpmsg.hdr.rtm_type = RTM_DELETE; arpmsg.hdr.rtm_seq = ++rtm_seq; - if ((routes = socket(AF_ROUTE, SOCK_RAW, AF_INET)) < 0) { + if ((routes = socket(AF_ROUTE, SOCK_RAW, AF_INET)) == -1) { syslog(LOG_ERR, "Couldn't delete proxy arp entry: socket: %m"); return 0; } - if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) { + if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) == -1) { syslog(LOG_ERR, "Couldn't delete proxy arp entry: %m"); close(routes); return 0; @@ -1277,7 +1277,7 @@ sifproxyarp(unit, hisaddr) SET_SA_FAMILY(arpreq.arp_pa, AF_INET); ((struct sockaddr_in *) &arpreq.arp_pa)->sin_addr.s_addr = hisaddr; arpreq.arp_flags = ATF_PERM | ATF_PUBL; - if (ioctl(sockfd, SIOCSARP, (caddr_t)&arpreq) < 0) { + if (ioctl(sockfd, SIOCSARP, (caddr_t)&arpreq) == -1) { syslog(LOG_ERR, "Couldn't add proxy arp entry: %m"); return 0; } @@ -1299,7 +1299,7 @@ cifproxyarp(unit, hisaddr) BZERO(&arpreq, sizeof(arpreq)); SET_SA_FAMILY(arpreq.arp_pa, AF_INET); ((struct sockaddr_in *) &arpreq.arp_pa)->sin_addr.s_addr = hisaddr; - if (ioctl(sockfd, SIOCDARP, (caddr_t)&arpreq) < 0) { + if (ioctl(sockfd, SIOCDARP, (caddr_t)&arpreq) == -1) { syslog(LOG_WARNING, "Couldn't delete proxy arp entry: %m"); return 0; } @@ -1458,7 +1458,7 @@ lock(dev) if (asprintf(&lock_file, "%s%s", LOCK_PREFIX, dev) == -1) novm("lock file name"); - while ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) { + while ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) == -1) { if (errno == EEXIST && (fd = open(lock_file, O_RDONLY, 0)) >= 0) { /* Read the lock file to find out who has the device locked */ diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c index 62ef9b988b4..40555109559 100644 --- a/usr.sbin/pwd_mkdb/pwd_mkdb.c +++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pwd_mkdb.c,v 1.55 2018/10/09 12:33:40 millert Exp $ */ +/* $OpenBSD: pwd_mkdb.c,v 1.56 2019/06/28 13:32:49 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -265,7 +265,7 @@ main(int argc, char **argv) if (makeold) { (void)snprintf(buf, sizeof(buf), "%s.orig", pname); if ((tfd = open(buf, - O_WRONLY|O_CREAT|O_EXCL, PERM_INSECURE)) < 0) + O_WRONLY|O_CREAT|O_EXCL, PERM_INSECURE)) == -1) fatal("%s", buf); if ((oldfp = fdopen(tfd, "w")) == NULL) fatal("%s", buf); @@ -386,16 +386,16 @@ cp(char *from, char *to, mode_t mode) static char buf[MAXBSIZE]; int from_fd, rcount, to_fd, wcount; - if ((from_fd = open(from, O_RDONLY, 0)) < 0) + if ((from_fd = open(from, O_RDONLY, 0)) == -1) fatal("%s", from); - if ((to_fd = open(to, O_WRONLY|O_CREAT|O_EXCL, mode)) < 0) + if ((to_fd = open(to, O_WRONLY|O_CREAT|O_EXCL, mode)) == -1) fatal("%s", to); while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) { wcount = write(to_fd, buf, rcount); if (rcount != wcount || wcount == -1) fatal("%s to %s", from, to); } - if (rcount < 0) + if (rcount == -1) fatal("%s to %s", from, to); close(to_fd); close(from_fd); diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c index 193b9b52f75..8178b058629 100644 --- a/usr.sbin/rad/frontend.c +++ b/usr.sbin/rad/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.29 2019/05/10 01:29:31 guenther Exp $ */ +/* $OpenBSD: frontend.c,v 1.30 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -200,7 +200,7 @@ frontend(int debug, int verbose) fatal("can't drop privileges"); /* XXX pass in from main */ - if ((ioctlsock = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0)) < 0) + if ((ioctlsock = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == -1) fatal("socket"); if (pledge("stdio inet unix recvfd route mcast", NULL) == -1) @@ -606,7 +606,7 @@ icmp6_receive(int fd, short events, void *arg) int if_index = 0, *hlimp = NULL; char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; - if ((len = recvmsg(fd, &icmp6ev.rcvmhdr, 0)) < 0) { + if ((len = recvmsg(fd, &icmp6ev.rcvmhdr, 0)) == -1) { log_warn("recvmsg"); return; } @@ -908,7 +908,7 @@ get_interface_prefixes(struct ra_iface *ra_iface, struct ra_prefix_conf sizeof(ifr6.ifr_name)); memcpy(&ifr6.ifr_addr, sin6, sizeof(ifr6.ifr_addr)); - if (ioctl(ioctlsock, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) < 0) + if (ioctl(ioctlsock, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) == -1) continue; /* addr got deleted while we were looking */ prefixlen = in6_mask2prefixlen(&((struct sockaddr_in6 *) @@ -1158,7 +1158,7 @@ ra_output(struct ra_iface *ra_iface, struct sockaddr_in6 *to) log_debug("send RA on %s", ra_iface->name); len = sendmsg(icmp6sock, &sndmhdr, 0); - if (len < 0) + if (len == -1) log_warn("sendmsg on %s", ra_iface->name); } diff --git a/usr.sbin/rad/rad.c b/usr.sbin/rad/rad.c index f4e96ab319e..93675167b6b 100644 --- a/usr.sbin/rad/rad.c +++ b/usr.sbin/rad/rad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rad.c,v 1.20 2019/03/31 03:36:18 yasuoka Exp $ */ +/* $OpenBSD: rad.c,v 1.21 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -260,19 +260,19 @@ main(int argc, char *argv[]) fatal("could not establish imsg links"); if ((icmp6sock = socket(AF_INET6, SOCK_RAW | SOCK_CLOEXEC, - IPPROTO_ICMPV6)) < 0) + IPPROTO_ICMPV6)) == -1) fatal("ICMPv6 socket"); if (setsockopt(icmp6sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, - sizeof(on)) < 0) + sizeof(on)) == -1) fatal("IPV6_RECVPKTINFO"); if (setsockopt(icmp6sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, - sizeof(on)) < 0) + sizeof(on)) == -1) fatal("IPV6_RECVHOPLIMIT"); if (setsockopt(icmp6sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &off, - sizeof(off)) < 0) + sizeof(off)) == -1) fatal("IPV6_RECVHOPLIMIT"); /* only router advertisements and solicitations */ @@ -284,13 +284,13 @@ main(int argc, char *argv[]) fatal("ICMP6_FILTER"); if ((frontend_routesock = socket(AF_ROUTE, SOCK_RAW | SOCK_CLOEXEC, - AF_INET6)) < 0) + AF_INET6)) == -1) fatal("route socket"); rtfilter = ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_NEWADDR) | ROUTE_FILTER(RTM_DELADDR); if (setsockopt(frontend_routesock, AF_ROUTE, ROUTE_MSGFILTER, - &rtfilter, sizeof(rtfilter)) < 0) + &rtfilter, sizeof(rtfilter)) == -1) fatal("setsockopt(ROUTE_MSGFILTER)"); if ((control_fd = control_init(csock)) == -1) diff --git a/usr.sbin/radiusd/radiusd.c b/usr.sbin/radiusd/radiusd.c index 33d7bf6c9e9..4b01b310dbc 100644 --- a/usr.sbin/radiusd/radiusd.c +++ b/usr.sbin/radiusd/radiusd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd.c,v 1.26 2019/04/03 11:54:56 yasuoka Exp $ */ +/* $OpenBSD: radiusd.c,v 1.27 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2013 Internet Initiative Japan Inc. @@ -202,7 +202,7 @@ radiusd_start(struct radiusd *radiusd) goto on_error; } if ((s = socket(l->addr.ipv4.sin_family, - l->stype | SOCK_NONBLOCK, l->sproto)) < 0) { + l->stype | SOCK_NONBLOCK, l->sproto)) == -1) { log_warn("Listen %s port %d is failed: socket()", hbuf, (int)htons(l->addr.ipv4.sin_port)); goto on_error; @@ -362,7 +362,7 @@ radiusd_listen_on_event(int fd, short evmask, void *ctx) if (evmask & EV_READ) { peersz = sizeof(peer); if ((sz = recvfrom(listn->sock, buf, sizeof(buf), 0, - (struct sockaddr *)&peer, &peersz)) < 0) { + (struct sockaddr *)&peer, &peersz)) == -1) { if (errno == EAGAIN) return; log_warn("%s: recvfrom() failed", __func__); @@ -956,12 +956,12 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name) close(pairsock[1]); module->fd = pairsock[0]; - if ((ival = fcntl(module->fd, F_GETFL)) < 0) { + if ((ival = fcntl(module->fd, F_GETFL)) == -1) { log_warn("Could not load module `%s': fcntl(F_GETFL)", name); goto on_error; } - if (fcntl(module->fd, F_SETFL, ival | O_NONBLOCK) < 0) { + if (fcntl(module->fd, F_SETFL, ival | O_NONBLOCK) == -1) { log_warn("Could not load module `%s': fcntl(F_SETFL,O_NONBLOCK)", name); goto on_error; diff --git a/usr.sbin/radiusd/radiusd_module.c b/usr.sbin/radiusd/radiusd_module.c index 43e72d0c2ca..f38170af91b 100644 --- a/usr.sbin/radiusd/radiusd_module.c +++ b/usr.sbin/radiusd/radiusd_module.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_module.c,v 1.12 2019/04/03 11:54:56 yasuoka Exp $ */ +/* $OpenBSD: radiusd_module.c,v 1.13 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -102,9 +102,9 @@ module_start(struct module_base *base) #ifdef USE_LIBEVENT int ival; - if ((ival = fcntl(base->ibuf.fd, F_GETFL)) < 0) + if ((ival = fcntl(base->ibuf.fd, F_GETFL)) == -1) err(1, "Failed to F_GETFL"); - if (fcntl(base->ibuf.fd, F_SETFL, ival | O_NONBLOCK) < 0) + if (fcntl(base->ibuf.fd, F_SETFL, ival | O_NONBLOCK) == -1) err(1, "Failed to setup NONBLOCK"); event_set(&base->ev, base->ibuf.fd, EV_READ, module_on_event, base); event_add(&base->ev, NULL); diff --git a/usr.sbin/radiusd/radiusd_radius.c b/usr.sbin/radiusd/radiusd_radius.c index 3e35fc1b731..af83969dbb6 100644 --- a/usr.sbin/radiusd/radiusd_radius.c +++ b/usr.sbin/radiusd/radiusd_radius.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_radius.c,v 1.16 2019/04/01 11:05:41 yasuoka Exp $ */ +/* $OpenBSD: radiusd_radius.c,v 1.17 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2013 Internet Initiative Japan Inc. @@ -342,7 +342,7 @@ radius_server_start(struct radius_server *server) char buf1[NI_MAXHOST + NI_MAXSERV + 32]; if ((server->sock = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0)) - < 0) { + == -1) { module_radius_log(server->module, LOG_WARNING, "%s: socket() failed", __func__); goto on_error; diff --git a/usr.sbin/rarpd/arptab.c b/usr.sbin/rarpd/arptab.c index 86e86e70e9c..711f1c2cef0 100644 --- a/usr.sbin/rarpd/arptab.c +++ b/usr.sbin/rarpd/arptab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arptab.c,v 1.30 2019/01/22 09:25:29 krw Exp $ */ +/* $OpenBSD: arptab.c,v 1.31 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 1984, 1993 @@ -73,7 +73,7 @@ void arptab_init(void) { s = socket(AF_ROUTE, SOCK_RAW, 0); - if (s < 0) + if (s == -1) err(1, "arp: socket"); } @@ -217,7 +217,7 @@ doit: l = rtm->rtm_msglen; rtm->rtm_seq = ++seq; rtm->rtm_type = cmd; - if (write(s, (char *)&m_rtmsg, l) < 0) { + if (write(s, (char *)&m_rtmsg, l) == -1) { if (errno != ESRCH && errno != EEXIST) { syslog(LOG_ERR, "writing to routing socket: %m"); return (-1); @@ -227,7 +227,7 @@ doit: l = recv(s, (char *)&m_rtmsg, sizeof(m_rtmsg), MSG_DONTWAIT); } while (l > 0 && (rtm->rtm_version != RTM_VERSION || rtm->rtm_seq != seq || rtm->rtm_pid != pid)); - if (l < 0) { + if (l == -1) { if (errno == EAGAIN || errno == EINTR) goto retry; syslog(LOG_ERR, "arptab_set: read from routing socket: %m"); diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c index 56d98844420..f3227883404 100644 --- a/usr.sbin/rarpd/rarpd.c +++ b/usr.sbin/rarpd/rarpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rarpd.c,v 1.75 2018/08/07 18:39:56 deraadt Exp $ */ +/* $OpenBSD: rarpd.c,v 1.76 2019/06/28 13:32:50 deraadt Exp $ */ /* $NetBSD: rarpd.c,v 1.25 1998/04/23 02:48:33 mrg Exp $ */ /* @@ -251,12 +251,12 @@ rarp_open(char *device) /* Set immediate mode so packets are processed as they arrive. */ immediate = 1; - if (ioctl(fd, BIOCIMMEDIATE, &immediate) < 0) { + if (ioctl(fd, BIOCIMMEDIATE, &immediate) == -1) { error("BIOCIMMEDIATE: %s", strerror(errno)); } (void) strncpy(ifr.ifr_name, device, sizeof ifr.ifr_name); - if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) { + if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) == -1) { if (aflag) { /* for -a skip not ethernet interfaces */ close(fd); return -1; @@ -268,7 +268,7 @@ rarp_open(char *device) * Check that the data link layer is an Ethernet; this code * won't work with anything else. */ - if (ioctl(fd, BIOCGDLT, (caddr_t) &dlt) < 0) + if (ioctl(fd, BIOCGDLT, (caddr_t) &dlt) == -1) error("BIOCGDLT: %s", strerror(errno)); if (dlt != DLT_EN10MB) { if (aflag) { /* for -a skip not ethernet interfaces */ @@ -278,7 +278,7 @@ rarp_open(char *device) error("%s is not an ethernet", device); } /* Set filter program. */ - if (ioctl(fd, BIOCSETF, (caddr_t)&filter) < 0) + if (ioctl(fd, BIOCSETF, (caddr_t)&filter) == -1) error("BIOCSETF: %s", strerror(errno)); return fd; } @@ -333,7 +333,7 @@ rarp_loop(void) if (iflist == 0) error("no interfaces"); - if (ioctl(iflist->ii_fd, BIOCGBLEN, (caddr_t)&bufsize) < 0) + if (ioctl(iflist->ii_fd, BIOCGBLEN, (caddr_t)&bufsize) == -1) error("BIOCGBLEN: %s", strerror(errno)); arptab_init(); @@ -374,9 +374,9 @@ rarp_loop(void) again: cc = read(fd, (char *)buf, bufsize); /* Don't choke when we get ptraced */ - if (cc < 0 && errno == EINTR) + if (cc == -1 && errno == EINTR) goto again; - if (cc < 0) + if (cc == -1) error("read: %s", strerror(errno)); /* Loop through the packet(s) */ #define bhp ((struct bpf_hdr *)bp) diff --git a/usr.sbin/rbootd/bpf.c b/usr.sbin/rbootd/bpf.c index 069253c0973..5ada9b29bed 100644 --- a/usr.sbin/rbootd/bpf.c +++ b/usr.sbin/rbootd/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.26 2017/04/19 05:36:13 natano Exp $ */ +/* $OpenBSD: bpf.c,v 1.27 2019/06/28 13:32:50 deraadt Exp $ */ /* $NetBSD: bpf.c,v 1.5.2.1 1995/11/14 08:45:42 thorpej Exp $ */ /* @@ -94,7 +94,7 @@ BpfOpen(void) * type and make sure it's type Ethernet. */ (void) strncpy(ifr.ifr_name, IntfName, sizeof(ifr.ifr_name)); - if (ioctl(BpfFd, BIOCSETIF, (caddr_t)&ifr) < 0) { + if (ioctl(BpfFd, BIOCSETIF, (caddr_t)&ifr) == -1) { syslog(LOG_ERR, "bpf: ioctl(BIOCSETIF,%s): %m", IntfName); DoExit(); } @@ -102,7 +102,7 @@ BpfOpen(void) /* * Make sure we are dealing with an Ethernet device. */ - if (ioctl(BpfFd, BIOCGDLT, (caddr_t)&n) < 0) { + if (ioctl(BpfFd, BIOCGDLT, (caddr_t)&n) == -1) { syslog(LOG_ERR, "bpf: ioctl(BIOCGDLT): %m"); DoExit(); } @@ -116,7 +116,7 @@ BpfOpen(void) * On read(), return packets immediately (do not buffer them). */ n = 1; - if (ioctl(BpfFd, BIOCIMMEDIATE, (caddr_t)&n) < 0) { + if (ioctl(BpfFd, BIOCIMMEDIATE, (caddr_t)&n) == -1) { syslog(LOG_ERR, "bpf: ioctl(BIOCIMMEDIATE): %m"); DoExit(); } @@ -132,11 +132,11 @@ BpfOpen(void) #endif ifr.ifr_addr.sa_family = AF_UNSPEC; bcopy(&RmpMcastAddr[0], (char *)&ifr.ifr_addr.sa_data[0], RMP_ADDRLEN); - if (ioctl(BpfFd, SIOCADDMULTI, (caddr_t)&ifr) < 0) { + if (ioctl(BpfFd, SIOCADDMULTI, (caddr_t)&ifr) == -1) { syslog(LOG_WARNING, "bpf: can't add mcast addr (%m), setting promiscuous mode"); - if (ioctl(BpfFd, BIOCPROMISC, (caddr_t)0) < 0) { + if (ioctl(BpfFd, BIOCPROMISC, (caddr_t)0) == -1) { syslog(LOG_ERR, "bpf: can't set promiscuous mode: %m"); DoExit(); } @@ -145,7 +145,7 @@ BpfOpen(void) /* * Ask BPF how much buffer space it requires and allocate one. */ - if (ioctl(BpfFd, BIOCGBLEN, (caddr_t)&BpfLen) < 0) { + if (ioctl(BpfFd, BIOCGBLEN, (caddr_t)&BpfLen) == -1) { syslog(LOG_ERR, "bpf: ioctl(BIOCGBLEN): %m"); DoExit(); } @@ -213,17 +213,17 @@ BpfOpen(void) sizeof(bpf_wf_insn)/sizeof(bpf_wf_insn[0]), bpf_wf_insn }; - if (ioctl(BpfFd, BIOCSETF, (caddr_t)&bpf_pgm) < 0) { + if (ioctl(BpfFd, BIOCSETF, (caddr_t)&bpf_pgm) == -1) { syslog(LOG_ERR, "bpf: ioctl(BIOCSETF): %m"); DoExit(); } - if (ioctl(BpfFd, BIOCSETWF, (caddr_t)&bpf_w_pgm) < 0) { + if (ioctl(BpfFd, BIOCSETWF, (caddr_t)&bpf_w_pgm) == -1) { syslog(LOG_ERR, "bpf: ioctl(BIOCSETWF): %m"); DoExit(); } - if (ioctl(BpfFd, BIOCLOCK) < 0) { + if (ioctl(BpfFd, BIOCLOCK) == -1) { syslog(LOG_ERR, "bpf: ioctl(BIOCLOCK): %m"); DoExit(); } @@ -324,7 +324,7 @@ BpfRead(RMPCONN *rconn, int doread) * We let the caller decide whether or not we can issue a read(). */ if (doread) { - if ((cc = read(BpfFd, (char *)BpfPkt, (int)BpfLen)) < 0) { + if ((cc = read(BpfFd, (char *)BpfPkt, (int)BpfLen)) == -1) { syslog(LOG_ERR, "bpf: read: %m"); return(0); } else { @@ -379,7 +379,7 @@ BpfRead(RMPCONN *rconn, int doread) int BpfWrite(RMPCONN *rconn) { - if (write(BpfFd, (char *)&rconn->rmp, rconn->rmplen) < 0) { + if (write(BpfFd, (char *)&rconn->rmp, rconn->rmplen) == -1) { syslog(LOG_ERR, "write: %s: %m", EnetStr(rconn)); return(0); } diff --git a/usr.sbin/rbootd/parseconf.c b/usr.sbin/rbootd/parseconf.c index 4739c15d9eb..2563ce9b59a 100644 --- a/usr.sbin/rbootd/parseconf.c +++ b/usr.sbin/rbootd/parseconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parseconf.c,v 1.13 2016/05/29 02:19:02 guenther Exp $ */ +/* $OpenBSD: parseconf.c,v 1.14 2019/06/28 13:32:50 deraadt Exp $ */ /* $NetBSD: parseconf.c,v 1.4 1995/10/06 05:12:16 thorpej Exp $ */ /* @@ -320,7 +320,7 @@ GetBootFiles(void) */ i = 0; for (dp = readdir(dfd); dp != NULL; dp = readdir(dfd)) { - if (stat(dp->d_name, &statb) < 0 || + if (stat(dp->d_name, &statb) == -1 || (statb.st_mode & S_IFMT) != S_IFREG) continue; if (i == C_MAXFILE) diff --git a/usr.sbin/rbootd/rbootd.c b/usr.sbin/rbootd/rbootd.c index 5c1dbee3edc..a1c4050b164 100644 --- a/usr.sbin/rbootd/rbootd.c +++ b/usr.sbin/rbootd/rbootd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rbootd.c,v 1.31 2016/05/29 02:19:02 guenther Exp $ */ +/* $OpenBSD: rbootd.c,v 1.32 2019/06/28 13:32:50 deraadt Exp $ */ /* $NetBSD: rbootd.c,v 1.5 1995/10/06 05:12:17 thorpej Exp $ */ /* @@ -159,7 +159,7 @@ main(int argc, char *argv[]) * All boot files are relative to the boot directory, we might * as well chdir() there to make life easier. */ - if (chdir(BootDir) < 0) { + if (chdir(BootDir) == -1) { syslog(LOG_ERR, "chdir: %m (%s)", BootDir); DoExit(); } @@ -215,7 +215,7 @@ main(int argc, char *argv[]) nsel = poll(pfd, 1, RmpConns ? RMP_TIMEOUT * 100 : -1); - if (nsel < 0) { + if (nsel == -1) { if (errno == EINTR) continue; syslog(LOG_ERR, "poll: %m"); diff --git a/usr.sbin/rbootd/rmpproto.c b/usr.sbin/rbootd/rmpproto.c index 74d8277b9b6..268fc2e780b 100644 --- a/usr.sbin/rbootd/rmpproto.c +++ b/usr.sbin/rbootd/rmpproto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rmpproto.c,v 1.12 2016/03/16 15:41:11 krw Exp $ */ +/* $OpenBSD: rmpproto.c,v 1.13 2019/06/28 13:32:50 deraadt Exp $ */ /* $NetBSD: rmpproto.c,v 1.5.2.1 1995/11/14 08:45:44 thorpej Exp $ */ /* @@ -355,7 +355,7 @@ match: * "too many open files" - RMP_E_BUSY * anything else - RMP_E_OPENFILE */ - if ((rconn->bootfd = open(filename, O_RDONLY, 0600)) < 0) { + if ((rconn->bootfd = open(filename, O_RDONLY, 0600)) == -1) { rpl->r_brpl.rmp_retcode = (errno == ENOENT)? RMP_E_NOFILE: (errno == EMFILE || errno == ENFILE)? RMP_E_BUSY: RMP_E_OPENFILE; @@ -444,7 +444,7 @@ SendReadRepl(RMPCONN *rconn) * Position read head on file according to info in request packet. */ GETWORD(req->r_rrq.rmp_offset, size); - if (lseek(oldconn->bootfd, (off_t)size, SEEK_SET) < 0) { + if (lseek(oldconn->bootfd, (off_t)size, SEEK_SET) == -1) { syslog(LOG_ERR, "SendReadRepl: lseek: %m (%s)", EnetStr(rconn)); rpl->r_rrpl.rmp_retcode = RMP_E_ABORT; @@ -457,7 +457,7 @@ SendReadRepl(RMPCONN *rconn) */ if ((size = read(oldconn->bootfd, &rpl->r_rrpl.rmp_data, (int) ntohs(req->r_rrq.rmp_size))) <= 0) { - if (size < 0) { + if (size == -1) { syslog(LOG_ERR, "SendReadRepl: read: %m (%s)", EnetStr(rconn)); rpl->r_rrpl.rmp_retcode = RMP_E_ABORT; diff --git a/usr.sbin/rdate/ntp.c b/usr.sbin/rdate/ntp.c index 547bdd98e53..d48b6cae19e 100644 --- a/usr.sbin/rdate/ntp.c +++ b/usr.sbin/rdate/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.34 2018/08/18 15:25:20 mestre Exp $ */ +/* $OpenBSD: ntp.c,v 1.35 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 1996, 1997 by N.M. Maclaren. All rights reserved. @@ -146,7 +146,7 @@ ntp_client(const char *hostname, int family, struct timeval *new, s = -1; for (res = res0; res; res = res->ai_next) { s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (s < 0) + if (s == -1) continue; ret = sync_ntp(s, res->ai_addr, &offset, &error); @@ -188,7 +188,7 @@ sync_ntp(int fd, const struct sockaddr *peer, double *offset, double *error) *offset = 0.0; *error = NTP_INSANITY; - if (connect(fd, peer, SA_LEN(peer)) < 0) { + if (connect(fd, peer, SA_LEN(peer)) == -1) { warn("Failed to connect to server"); return (-1); } @@ -318,7 +318,7 @@ read_packet(int fd, struct ntp_data *data, double *off, double *error) retry: r = poll(pfd, 1, 1000 * MAX_DELAY / MAX_QUERIES); - if (r < 0) { + if (r == -1) { if (errno == EINTR) goto retry; warn("select"); @@ -331,7 +331,7 @@ retry: return (1); length = read(fd, receive, NTP_PACKET_MAX); - if (length < 0) { + if (length == -1) { warn("Unable to receive NTP packet from server"); return (-1); } diff --git a/usr.sbin/rdate/rfc868time.c b/usr.sbin/rdate/rfc868time.c index 2158fb632dc..a7f84fce505 100644 --- a/usr.sbin/rdate/rfc868time.c +++ b/usr.sbin/rdate/rfc868time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rfc868time.c,v 1.11 2018/08/18 15:25:20 mestre Exp $ */ +/* $OpenBSD: rfc868time.c,v 1.12 2019/06/28 13:32:50 deraadt Exp $ */ /* $NetBSD: rdate.c,v 1.4 1996/03/16 12:37:45 pk Exp $ */ /* @@ -88,10 +88,10 @@ rfc868time_client(const char *hostname, int family, struct timeval *new, s = -1; for (res = res0; res; res = res->ai_next) { s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (s < 0) + if (s == -1) continue; - if (connect(s, res->ai_addr, res->ai_addrlen) < 0) { + if (connect(s, res->ai_addr, res->ai_addrlen) == -1) { close(s); s = -1; continue; @@ -99,7 +99,7 @@ rfc868time_client(const char *hostname, int family, struct timeval *new, break; } - if (s < 0) + if (s == -1) err(1, "Could not connect socket"); freeaddrinfo(res0); diff --git a/usr.sbin/relayd/check_icmp.c b/usr.sbin/relayd/check_icmp.c index 1b2557c25fc..3d251b28651 100644 --- a/usr.sbin/relayd/check_icmp.c +++ b/usr.sbin/relayd/check_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_icmp.c,v 1.47 2017/07/12 22:57:40 jca Exp $ */ +/* $OpenBSD: check_icmp.c,v 1.48 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -52,7 +52,7 @@ icmp_setup(struct relayd *env, struct ctl_icmp_event *cie, int af) if (af == AF_INET6) proto = IPPROTO_ICMPV6; - if ((cie->s = socket(af, SOCK_RAW | SOCK_NONBLOCK, proto)) < 0) + if ((cie->s = socket(af, SOCK_RAW | SOCK_NONBLOCK, proto)) == -1) fatal("%s: socket", __func__); val = ICMP_RCVBUF_SIZE; if (setsockopt(cie->s, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)) == -1) diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y index 6cdbba67d5f..0d46ae20095 100644 --- a/usr.sbin/relayd/parse.y +++ b/usr.sbin/relayd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.238 2019/05/31 15:25:57 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.239 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -3385,7 +3385,7 @@ is_if_in_group(const char *ifname, const char *groupname) int s; int ret = 0; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) err(1, "socket"); memset(&ifgr, 0, sizeof(ifgr)); diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 7ec8f0ec41a..864d9104fbe 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.248 2019/06/26 12:13:47 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.249 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -2504,7 +2504,7 @@ relay_tls_readcb(int fd, short event, void *arg) ret = tls_read(cre->tls, rbuf, howmuch); if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT) { goto retry; - } else if (ret < 0) { + } else if (ret == -1) { what |= EVBUFFER_ERROR; goto err; } @@ -2563,7 +2563,7 @@ relay_tls_writecb(int fd, short event, void *arg) EVBUFFER_LENGTH(bufev->output)); if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT) { goto retry; - } else if (ret < 0) { + } else if (ret == -1) { what |= EVBUFFER_ERROR; goto err; } diff --git a/usr.sbin/ripd/interface.c b/usr.sbin/ripd/interface.c index 79b2424243d..a176e1368cc 100644 --- a/usr.sbin/ripd/interface.c +++ b/usr.sbin/ripd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.14 2017/01/17 16:30:54 jca Exp $ */ +/* $OpenBSD: interface.c,v 1.15 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -257,7 +257,7 @@ int if_set_mcast_ttl(int fd, u_int8_t ttl) { if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, - (char *)&ttl, sizeof(ttl)) < 0) { + (char *)&ttl, sizeof(ttl)) == -1) { log_warn("if_set_mcast_ttl: error setting " "IP_MULTICAST_TTL to %d", ttl); return (-1); @@ -272,7 +272,7 @@ if_set_opt(int fd) int yes = 1; if (setsockopt(fd, IPPROTO_IP, IP_RECVIF, &yes, - sizeof(int)) < 0) { + sizeof(int)) == -1) { log_warn("if_set_opt: error setting IP_RECVIF"); return (-1); } @@ -284,7 +284,7 @@ int if_set_tos(int fd, int tos) { if (setsockopt(fd, IPPROTO_IP, IP_TOS, - (int *)&tos, sizeof(tos)) < 0) { + (int *)&tos, sizeof(tos)) == -1) { log_warn("if_set_tos: error setting IP_TOS to 0x%x", tos); return (-1); } @@ -299,7 +299,7 @@ if_set_mcast(struct iface *iface) case IF_TYPE_POINTOPOINT: case IF_TYPE_BROADCAST: if (setsockopt(iface->fd, IPPROTO_IP, IP_MULTICAST_IF, - &iface->addr.s_addr, sizeof(iface->addr.s_addr)) < 0) { + &iface->addr.s_addr, sizeof(iface->addr.s_addr)) == -1) { log_debug("if_set_mcast: error setting " "IP_MULTICAST_IF, interface %s", iface->name); return (-1); @@ -318,7 +318,7 @@ if_set_mcast_loop(int fd) u_int8_t loop = 0; if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, - (char *)&loop, sizeof(loop)) < 0) { + (char *)&loop, sizeof(loop)) == -1) { log_warn("if_set_mcast_loop: error setting IP_MULTICAST_LOOP"); return (-1); } @@ -349,7 +349,7 @@ if_join_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = iface->addr.s_addr; if (setsockopt(iface->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, - (void *)&mreq, sizeof(mreq)) < 0) + (void *)&mreq, sizeof(mreq)) == -1) return (-1); break; default: @@ -371,7 +371,7 @@ if_leave_group(struct iface *iface, struct in_addr *addr) mreq.imr_interface.s_addr = iface->addr.s_addr; if (setsockopt(iface->fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, - (void *)&mreq, sizeof(mreq)) < 0) + (void *)&mreq, sizeof(mreq)) == -1) return (-1); break; default: @@ -406,7 +406,7 @@ if_new(struct kif *kif) /* set up ifreq */ strlcpy(ifr->ifr_name, kif->ifname, sizeof(ifr->ifr_name)); if ((s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, - 0)) < 0) + 0)) == -1) err(1, "if_new: socket"); /* get type */ @@ -429,20 +429,20 @@ if_new(struct kif *kif) iface->baudrate = kif->baudrate; /* get address */ - if (ioctl(s, SIOCGIFADDR, ifr) < 0) + if (ioctl(s, SIOCGIFADDR, ifr) == -1) err(1, "if_new: cannot get address"); sain = (struct sockaddr_in *)&ifr->ifr_addr; iface->addr = sain->sin_addr; /* get mask */ - if (ioctl(s, SIOCGIFNETMASK, ifr) < 0) + if (ioctl(s, SIOCGIFNETMASK, ifr) == -1) err(1, "if_new: cannot get mask"); sain = (struct sockaddr_in *)&ifr->ifr_addr; iface->mask = sain->sin_addr; /* get p2p dst address */ if (kif->flags & IFF_POINTOPOINT) { - if (ioctl(s, SIOCGIFDSTADDR, ifr) < 0) + if (ioctl(s, SIOCGIFDSTADDR, ifr) == -1) err(1, "if_new: cannot get dst addr"); sain = (struct sockaddr_in *)&ifr->ifr_addr; iface->dst = sain->sin_addr; diff --git a/usr.sbin/rmt/rmt.c b/usr.sbin/rmt/rmt.c index d1542b3083d..eaeba84c0a4 100644 --- a/usr.sbin/rmt/rmt.c +++ b/usr.sbin/rmt/rmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rmt.c,v 1.22 2019/02/10 16:42:35 phessler Exp $ */ +/* $OpenBSD: rmt.c,v 1.23 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -228,7 +228,7 @@ top: } } rval = write(tape, record, n); - if (rval < 0) + if (rval == -1) goto ioerror; goto respond; @@ -238,7 +238,7 @@ top: n = atoi(count); record = checkbuf(record, n); rval = read(tape, record, n); - if (rval < 0) + if (rval == -1) goto ioerror; (void) snprintf(resp, sizeof resp, "A%d\n", rval); (void) write(STDOUT_FILENO, resp, strlen(resp)); diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c index e33a17ae3bf..ee1cf0b6d1c 100644 --- a/usr.sbin/route6d/route6d.c +++ b/usr.sbin/route6d/route6d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route6d.c,v 1.98 2019/01/22 09:25:29 krw Exp $ */ +/* $OpenBSD: route6d.c,v 1.99 2019/06/28 13:32:50 deraadt Exp $ */ /* $KAME: route6d.c,v 1.111 2006/10/25 06:38:13 jinmei Exp $ */ /* @@ -300,7 +300,7 @@ main(int argc, char *argv[]) } if (dflag == 0) { - if (daemon(0, 0) < 0) { + if (daemon(0, 0) == -1) { fatal("daemon"); /*NOTREACHED*/ } @@ -530,39 +530,39 @@ init(void) } ripsock = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (ripsock < 0) { + if (ripsock == -1) { fatal("rip socket"); /*NOTREACHED*/ } if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_V6ONLY, - &int1, sizeof(int1)) < 0) { + &int1, sizeof(int1)) == -1) { fatal("rip IPV6_V6ONLY"); /*NOTREACHED*/ } - if (bind(ripsock, res->ai_addr, res->ai_addrlen) < 0) { + if (bind(ripsock, res->ai_addr, res->ai_addrlen) == -1) { fatal("rip bind"); /*NOTREACHED*/ } if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, - &int255, sizeof(int255)) < 0) { + &int255, sizeof(int255)) == -1) { fatal("rip IPV6_MULTICAST_HOPS"); /*NOTREACHED*/ } if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, - &int0, sizeof(int0)) < 0) { + &int0, sizeof(int0)) == -1) { fatal("rip IPV6_MULTICAST_LOOP"); /*NOTREACHED*/ } i = 1; if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &i, - sizeof(i)) < 0) { + sizeof(i)) == -1) { fatal("rip IPV6_RECVPKTINFO"); /*NOTREACHED*/ } if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, - &int1, sizeof(int1)) < 0) { + &int1, sizeof(int1)) == -1) { fatal("rip IPV6_RECVHOPLIMIT"); /*NOTREACHED*/ } @@ -587,7 +587,7 @@ init(void) pfd[0].events = POLLIN; if (nflag == 0) { - if ((rtsock = socket(AF_ROUTE, SOCK_RAW, 0)) < 0) { + if ((rtsock = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) { fatal("route socket"); /*NOTREACHED*/ } @@ -927,7 +927,7 @@ sendpacket(struct sockaddr_in6 *sin6, int len) pi->ipi6_ifindex = idx; } - if (sendmsg(ripsock, &m, 0) < 0) { + if (sendmsg(ripsock, &m, 0) == -1) { log_debug("sendmsg: %s", strerror(errno)); return errno; } @@ -977,7 +977,7 @@ riprecv(void) m.msg_iovlen = 1; m.msg_control = (caddr_t)&cmsgbuf.buf; m.msg_controllen = sizeof(cmsgbuf.buf); - if ((len = recvmsg(ripsock, &m, 0)) < 0) { + if ((len = recvmsg(ripsock, &m, 0)) == -1) { fatal("recvmsg"); /*NOTREACHED*/ } @@ -1359,7 +1359,7 @@ ifconfig(void) struct ipv6_mreq mreq; int s; - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { + if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) == -1) { fatal("socket"); /*NOTREACHED*/ } @@ -1410,7 +1410,7 @@ ifconfig(void) mreq.ipv6mr_multiaddr = ifcp->ifc_ripsin.sin6_addr; mreq.ipv6mr_interface = ifcp->ifc_index; if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_JOIN_GROUP, - &mreq, sizeof(mreq)) < 0) { + &mreq, sizeof(mreq)) == -1) { fatalx("IPV6_JOIN_GROUP"); /*NOTREACHED*/ } @@ -1436,7 +1436,7 @@ ifconfig1(const char *name, const struct sockaddr *sa, struct ifc *ifcp, int s) return; ifr.ifr_addr = *sin6; strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCGIFNETMASK_IN6, (char *)&ifr) < 0) { + if (ioctl(s, SIOCGIFNETMASK_IN6, (char *)&ifr) == -1) { fatal("ioctl: SIOCGIFNETMASK_IN6"); /*NOTREACHED*/ } @@ -1461,7 +1461,7 @@ ifconfig1(const char *name, const struct sockaddr *sa, struct ifc *ifcp, int s) ifa->ifa_plen = plen; if (ifcp->ifc_flags & IFF_POINTOPOINT) { ifr.ifr_addr = *sin6; - if (ioctl(s, SIOCGIFDSTADDR_IN6, (char *)&ifr) < 0) { + if (ioctl(s, SIOCGIFDSTADDR_IN6, (char *)&ifr) == -1) { fatal("ioctl: SIOCGIFDSTADDR_IN6"); /*NOTREACHED*/ } @@ -1483,7 +1483,7 @@ ifconfig1(const char *name, const struct sockaddr *sa, struct ifc *ifcp, int s) ifcp->ifc_mtu = getifmtu(ifcp->ifc_index); if (ifcp->ifc_mtu > RIP6_MAXMTU) ifcp->ifc_mtu = RIP6_MAXMTU; - if (ioctl(s, SIOCGIFMETRIC, (char *)&ifr) < 0) { + if (ioctl(s, SIOCGIFMETRIC, (char *)&ifr) == -1) { fatal("ioctl: SIOCGIFMETRIC"); /*NOTREACHED*/ } @@ -1514,7 +1514,7 @@ rtrecv(void) int i, addrs; struct riprt *rrt; - if ((len = read(rtsock, buf, sizeof(buf))) < 0) { + if ((len = read(rtsock, buf, sizeof(buf))) == -1) { perror("read from rtsock"); exit(1); } @@ -2368,7 +2368,7 @@ krtread(int again) free(buf); buf = NULL; errmsg = NULL; - if (sysctl(mib, 6, NULL, &msize, NULL, 0) < 0) { + if (sysctl(mib, 6, NULL, &msize, NULL, 0) == -1) { errmsg = "sysctl estimate"; continue; } @@ -2376,7 +2376,7 @@ krtread(int again) errmsg = "malloc"; continue; } - if (sysctl(mib, 6, buf, &msize, NULL, 0) < 0) { + if (sysctl(mib, 6, buf, &msize, NULL, 0) == -1) { errmsg = "sysctl NET_RT_DUMP"; continue; } @@ -2687,14 +2687,14 @@ getroute(struct netinfo6 *np, struct in6_addr *gw) sin6->sin6_len = sizeof(struct sockaddr_in6); sin6->sin6_family = AF_INET6; sin6->sin6_addr = np->rip6_dest; - if (write(rtsock, buf, len) < 0) { + if (write(rtsock, buf, len) == -1) { if (errno == ESRCH) /* No such route found */ return NULL; perror("write to rtsock"); exit(1); } do { - if ((len = read(rtsock, buf, sizeof(buf))) < 0) { + if ((len = read(rtsock, buf, sizeof(buf))) == -1) { perror("read from rtsock"); exit(1); } diff --git a/usr.sbin/rpc.lockd/lockd_lock.c b/usr.sbin/rpc.lockd/lockd_lock.c index bd687a7c803..ad4162b8898 100644 --- a/usr.sbin/rpc.lockd/lockd_lock.c +++ b/usr.sbin/rpc.lockd/lockd_lock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lockd_lock.c,v 1.9 2015/01/16 06:40:20 deraadt Exp $ */ +/* $OpenBSD: lockd_lock.c,v 1.10 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2000 Manuel Bouyer. @@ -508,7 +508,7 @@ do_lock(struct file_lock *fl, int block) struct stat st; fl->fd = fhopen((fhandle_t *)fl->filehandle.fhdata, O_RDWR); - if (fl->fd < 0) { + if (fl->fd == -1) { switch (errno) { case ESTALE: error = nlm4_stale_fh; @@ -526,7 +526,7 @@ do_lock(struct file_lock *fl, int block) LIST_REMOVE(fl, lcklst); return error; } - if (fstat(fl->fd, &st) < 0) { + if (fstat(fl->fd, &st) == -1) { syslog(LOG_NOTICE, "fstat failed (from %s) (%m)", fl->client_name); } @@ -738,7 +738,7 @@ siglock(void) sigemptyset(&block); sigaddset(&block, SIGCHLD); - if (sigprocmask(SIG_BLOCK, &block, NULL) < 0) { + if (sigprocmask(SIG_BLOCK, &block, NULL) == -1) { syslog(LOG_WARNING, "siglock failed (%m)"); } } @@ -751,7 +751,7 @@ sigunlock(void) sigemptyset(&block); sigaddset(&block, SIGCHLD); - if (sigprocmask(SIG_UNBLOCK, &block, NULL) < 0) { + if (sigprocmask(SIG_UNBLOCK, &block, NULL) == -1) { syslog(LOG_WARNING, "sigunlock failed (%m)"); } } diff --git a/usr.sbin/rpki-client/io.c b/usr.sbin/rpki-client/io.c index 20a88e499a5..766565ac7ad 100644 --- a/usr.sbin/rpki-client/io.c +++ b/usr.sbin/rpki-client/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.3 2019/06/19 16:30:37 deraadt Exp $ */ +/* $OpenBSD: io.c,v 1.4 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -62,7 +62,7 @@ io_simple_write(int fd, const void *res, size_t sz) if (sz == 0) return; - if ((ssz = write(fd, res, sz)) < 0) + if ((ssz = write(fd, res, sz)) == -1) err(EXIT_FAILURE, "write"); else if ((size_t)ssz != sz) errx(EXIT_FAILURE, "write: short write"); @@ -145,7 +145,7 @@ io_simple_read(int fd, void *res, size_t sz) again: if (sz == 0) return; - if ((ssz = read(fd, res, sz)) < 0) + if ((ssz = read(fd, res, sz)) == -1) err(EXIT_FAILURE, "read"); else if (ssz == 0) errx(EXIT_FAILURE, "read: unexpected end of file"); diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c index e4b086bc86c..37867111b98 100644 --- a/usr.sbin/rpki-client/main.c +++ b/usr.sbin/rpki-client/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.10 2019/06/19 16:39:02 claudio Exp $ */ +/* $OpenBSD: main.c,v 1.11 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -628,7 +628,7 @@ proc_rsync(const char *prog, int fd, int noop) * That will mean that we can safely exit. */ - if ((ssz = read(fd, &id, sizeof(size_t))) < 0) + if ((ssz = read(fd, &id, sizeof(size_t))) == -1) err(EXIT_FAILURE, "read"); if (ssz == 0) break; @@ -1034,7 +1034,7 @@ proc_parser(int fd, int force, int norev) if (bsz) { assert(bpos < bmax); - if ((ssz = write(fd, b + bpos, bsz)) < 0) + if ((ssz = write(fd, b + bpos, bsz)) == -1) err(EXIT_FAILURE, "write"); bpos += ssz; bsz -= ssz; diff --git a/usr.sbin/sasyncd/conf.y b/usr.sbin/sasyncd/conf.y index 0b6731c19b5..b5970a68807 100644 --- a/usr.sbin/sasyncd/conf.y +++ b/usr.sbin/sasyncd/conf.y @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.y,v 1.20 2019/03/21 10:55:41 otto Exp $ */ +/* $OpenBSD: conf.y,v 1.21 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -370,7 +370,7 @@ conf_parse_file(char *cfgfile) } fd = open(cfgfile, O_RDONLY, 0); - if (fd < 0) + if (fd == -1) goto bad; conflen = st.st_size; diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index dea969afc16..99cd09cd398 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensorsd.c,v 1.65 2019/05/31 15:55:50 schwarze Exp $ */ +/* $OpenBSD: sensorsd.c,v 1.66 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -606,7 +606,7 @@ report_sdlim(struct sdlim_t *sdlim, time_t last_report) cmd[i]); break; } - if (r < 0 || (r >= len - n)) { + if (r == -1 || (r >= len - n)) { syslog(LOG_CRIT, "could not parse " "command"); return; diff --git a/usr.sbin/smtpd/crypto.c b/usr.sbin/smtpd/crypto.c index 39576f71a80..b6a7547cf11 100644 --- a/usr.sbin/smtpd/crypto.c +++ b/usr.sbin/smtpd/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.7 2019/05/24 18:01:52 gilles Exp $ */ +/* $OpenBSD: crypto.c,v 1.8 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2013 Gilles Chehade <gilles@openbsd.org> @@ -74,7 +74,7 @@ crypto_encrypt_file(FILE * in, FILE * out) struct stat sb; /* XXX - Do NOT encrypt files bigger than 64GB */ - if (fstat(fileno(in), &sb) < 0) + if (fstat(fileno(in), &sb) == -1) return 0; if (sb.st_size >= 0x1000000000LL) return 0; @@ -140,7 +140,7 @@ crypto_decrypt_file(FILE * in, FILE * out) struct stat sb; /* input file too small to be an encrypted file */ - if (fstat(fileno(in), &sb) < 0) + if (fstat(fileno(in), &sb) == -1) return 0; if (sb.st_size <= (off_t) (sizeof version + sizeof tag + sizeof iv)) return 0; diff --git a/usr.sbin/smtpd/mail.maildir.c b/usr.sbin/smtpd/mail.maildir.c index e1796e0eb04..cc9d5429aa1 100644 --- a/usr.sbin/smtpd/mail.maildir.c +++ b/usr.sbin/smtpd/mail.maildir.c @@ -93,7 +93,7 @@ maildir_mkdirs(const char *dirname) char pathname[PATH_MAX]; char *subdirs[] = { "cur", "tmp", "new" }; - if (mkdirs(dirname, 0700) < 0 && errno != EEXIST) + if (mkdirs(dirname, 0700) == -1 && errno != EEXIST) err(1, NULL); for (i = 0; i < nitems(subdirs); ++i) { @@ -101,7 +101,7 @@ maildir_mkdirs(const char *dirname) subdirs[i]); if (ret == -1 || (size_t)ret >= sizeof pathname) errc(1, ENAMETOOLONG, "%s/%s", dirname, subdirs[i]); - if (mkdir(pathname, 0700) < 0 && errno != EEXIST) + if (mkdir(pathname, 0700) == -1 && errno != EEXIST) err(1, NULL); } } @@ -177,7 +177,7 @@ maildir_engine(const char *dirname, int junk) (void)snprintf(tmp, sizeof tmp, "%s/tmp/%s", dirname, filename); fd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0600); - if (fd < 0) + if (fd == -1) err(1, NULL); if ((fp = fdopen(fd, "w")) == NULL) err(1, NULL); @@ -198,14 +198,14 @@ maildir_engine(const char *dirname, int junk) if (fflush(fp) == EOF || ferror(fp) || - fsync(fd) < 0 || + fsync(fd) == -1 || fclose(fp) == EOF) err(1, NULL); (void)snprintf(new, sizeof new, "%s/new/%s", is_junk ? junkpath : dirname, filename); - if (rename(tmp, new) < 0) + if (rename(tmp, new) == -1) err(1, NULL); exit(0); diff --git a/usr.sbin/smtpd/mail.mboxfile.c b/usr.sbin/smtpd/mail.mboxfile.c index 6dbcc0583b4..0cc1d7429e8 100644 --- a/usr.sbin/smtpd/mail.mboxfile.c +++ b/usr.sbin/smtpd/mail.mboxfile.c @@ -72,7 +72,7 @@ mboxfile_engine(const char *sender, const char *filename) time(&now); fd = open(filename, O_CREAT | O_APPEND | O_WRONLY | O_EXLOCK, 0600); - if (fd < 0) + if (fd == -1) err(1, NULL); if ((fp = fdopen(fd, "w")) == NULL) @@ -93,7 +93,7 @@ mboxfile_engine(const char *sender, const char *filename) if (fflush(fp) == EOF || ferror(fp) || - fsync(fd) < 0 || + fsync(fd) == -1 || fclose(fp) == EOF) err(1, NULL); } diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index 348192fc22f..9fe558216a3 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.137 2019/01/05 10:20:21 gilles Exp $ */ +/* $OpenBSD: mda.c,v 1.138 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -521,7 +521,7 @@ mda_getlastline(int fd, char *dst, size_t dstsz) ssize_t len; int out = 0; - if (lseek(fd, 0, SEEK_SET) < 0) { + if (lseek(fd, 0, SEEK_SET) == -1) { log_warn("warn: mda: lseek"); close(fd); return (-1); diff --git a/usr.sbin/smtpd/mproc.c b/usr.sbin/smtpd/mproc.c index c3751901b62..5b824fd6873 100644 --- a/usr.sbin/smtpd/mproc.c +++ b/usr.sbin/smtpd/mproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mproc.c,v 1.33 2019/05/24 14:31:30 gilles Exp $ */ +/* $OpenBSD: mproc.c,v 1.34 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@faurot.net> @@ -48,7 +48,7 @@ mproc_fork(struct mproc *p, const char *path, char *argv[]) { int sp[2]; - if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) < 0) + if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) == -1) return (-1); io_set_nonblocking(sp[0]); @@ -60,7 +60,7 @@ mproc_fork(struct mproc *p, const char *path, char *argv[]) if (p->pid == 0) { /* child process */ dup2(sp[0], STDIN_FILENO); - if (closefrom(STDERR_FILENO + 1) < 0) + if (closefrom(STDERR_FILENO + 1) == -1) exit(1); execv(path, argv); diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c index d07c997be04..1ae0b91f745 100644 --- a/usr.sbin/smtpd/mta_session.c +++ b/usr.sbin/smtpd/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.118 2019/06/24 15:14:01 gilles Exp $ */ +/* $OpenBSD: mta_session.c,v 1.119 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -975,7 +975,7 @@ mta_response(struct mta_session *s, char *line) */ sa_len = sizeof(ss); sa = (struct sockaddr *)&ss; - if (getsockname(io_fileno(s->io), sa, &sa_len) < 0) + if (getsockname(io_fileno(s->io), sa, &sa_len) == -1) mta_delivery_log(e, NULL, buf, delivery, line); else mta_delivery_log(e, sa_to_text(sa), @@ -1373,7 +1373,7 @@ mta_flush_task(struct mta_session *s, int delivery, const char *error, size_t co */ sa = (struct sockaddr *)&ss; sa_len = sizeof(ss); - if (getsockname(io_fileno(s->io), sa, &sa_len) < 0) + if (getsockname(io_fileno(s->io), sa, &sa_len) == -1) mta_delivery_log(e, NULL, relay, delivery, error); else mta_delivery_log(e, sa_to_text(sa), diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index 9607e29ab39..39163158874 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.252 2019/05/20 07:04:13 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.253 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -3161,7 +3161,7 @@ is_if_in_group(const char *ifname, const char *groupname) int s; int ret = 0; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) err(1, "socket"); memset(&ifgr, 0, sizeof(ifgr)); diff --git a/usr.sbin/smtpd/queue_fs.c b/usr.sbin/smtpd/queue_fs.c index ecbc53a8647..d1cd4800a9e 100644 --- a/usr.sbin/smtpd/queue_fs.c +++ b/usr.sbin/smtpd/queue_fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_fs.c,v 1.18 2018/12/30 23:09:58 guenther Exp $ */ +/* $OpenBSD: queue_fs.c,v 1.19 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -414,7 +414,7 @@ fsqueue_check_space(void) uint64_t used; uint64_t total; - if (statfs(PATH_QUEUE, &buf) < 0) { + if (statfs(PATH_QUEUE, &buf) == -1) { log_warn("warn: queue-fs: statfs"); return 0; } diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index 921d9f8a6d0..3eaede011a2 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.164 2018/12/23 16:37:53 eric Exp $ */ +/* $OpenBSD: smtp.c,v 1.165 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -138,7 +138,7 @@ smtp_setup_listeners(void) } opt = 1; if (setsockopt(l->fd, SOL_SOCKET, SO_REUSEADDR, &opt, - sizeof(opt)) < 0) + sizeof(opt)) == -1) fatal("smtpd: setsockopt"); if (bind(l->fd, (struct sockaddr *)&l->ss, l->ss.ss_len) == -1) fatal("smtpd: bind"); diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 5c5836d0ae2..67880cb0741 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.393 2019/06/27 13:10:48 kili Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.394 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -2912,7 +2912,7 @@ smtp_message_printf(struct smtp_tx *tx, const char *fmt, ...) len = vfprintf(tx->ofile, fmt, ap); va_end(ap); - if (len < 0) { + if (len == -1) { log_warn("smtp-in: session %016"PRIx64": vfprintf", tx->session->id); tx->error = TX_ERROR_IO; } diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 4409aa16d28..9cc4fdf77d7 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.322 2019/06/28 05:35:35 deraadt Exp $ */ +/* $OpenBSD: smtpd.c,v 1.323 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -1179,7 +1179,7 @@ fork_proc_backend(const char *key, const char *conf, const char *procname) if (pid == 0) { /* child process */ dup2(sp[0], STDIN_FILENO); - if (closefrom(STDERR_FILENO + 1) < 0) + if (closefrom(STDERR_FILENO + 1) == -1) exit(1); if (procname == NULL) @@ -1297,7 +1297,7 @@ fork_processor(const char *name, const char *command, const char *user, const ch if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, errfd) == -1) err(1, "socketpair"); - if ((pid = fork()) < 0) + if ((pid = fork()) == -1) err(1, "fork"); /* parent passes the child fd over to lka */ @@ -1329,9 +1329,9 @@ fork_processor(const char *name, const char *command, const char *user, const ch setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) err(1, "fork_processor: cannot drop privileges"); - if (closefrom(STDERR_FILENO + 1) < 0) + if (closefrom(STDERR_FILENO + 1) == -1) err(1, "closefrom"); - if (setsid() < 0) + if (setsid() == -1) err(1, "setsid"); if (signal(SIGPIPE, SIG_DFL) == SIG_ERR || signal(SIGINT, SIG_DFL) == SIG_ERR || @@ -1421,7 +1421,7 @@ forkmda(struct mproc *p, uint64_t id, struct deliver *deliver) return; } - if (pipe(pipefd) < 0) { + if (pipe(pipefd) == -1) { (void)snprintf(ebuf, sizeof ebuf, "pipe: %s", strerror(errno)); m_create(p_pony, IMSG_MDA_DONE, 0, 0, -1); m_add_id(p_pony, id); @@ -1450,7 +1450,7 @@ forkmda(struct mproc *p, uint64_t id, struct deliver *deliver) unlink(sfn); pid = fork(); - if (pid < 0) { + if (pid == -1) { (void)snprintf(ebuf, sizeof ebuf, "fork: %s", strerror(errno)); m_create(p_pony, IMSG_MDA_DONE, 0, 0, -1); m_add_id(p_pony, id); @@ -1475,19 +1475,19 @@ forkmda(struct mproc *p, uint64_t id, struct deliver *deliver) m_close(p); return; } - if (chdir(pw_dir) < 0 && chdir("/") < 0) + if (chdir(pw_dir) == -1 && chdir("/") == -1) err(1, "chdir"); if (setgroups(1, &pw_gid) || setresgid(pw_gid, pw_gid, pw_gid) || setresuid(pw_uid, pw_uid, pw_uid)) err(1, "forkmda: cannot drop privileges"); - if (dup2(pipefd[0], STDIN_FILENO) < 0 || - dup2(allout, STDOUT_FILENO) < 0 || - dup2(allout, STDERR_FILENO) < 0) + if (dup2(pipefd[0], STDIN_FILENO) == -1 || + dup2(allout, STDOUT_FILENO) == -1 || + dup2(allout, STDERR_FILENO) == -1) err(1, "forkmda: dup2"); - if (closefrom(STDERR_FILENO + 1) < 0) + if (closefrom(STDERR_FILENO + 1) == -1) err(1, "closefrom"); - if (setsid() < 0) + if (setsid() == -1) err(1, "setsid"); if (signal(SIGPIPE, SIG_DFL) == SIG_ERR || signal(SIGINT, SIG_DFL) == SIG_ERR || @@ -1726,7 +1726,7 @@ parent_forward_open(char *username, char *directory, uid_t uid, gid_t gid) return -1; } - if (stat(directory, &sb) < 0) { + if (stat(directory, &sb) == -1) { log_warn("warn: smtpd: parent_forward_open: %s", directory); return -1; } diff --git a/usr.sbin/smtpd/table_db.c b/usr.sbin/smtpd/table_db.c index 426d0f7cf90..daa6a3f8143 100644 --- a/usr.sbin/smtpd/table_db.c +++ b/usr.sbin/smtpd/table_db.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table_db.c,v 1.20 2018/12/27 15:04:59 eric Exp $ */ +/* $OpenBSD: table_db.c,v 1.21 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -136,7 +136,7 @@ table_db_open2(struct table *table) >= sizeof handle->pathname) goto error; - if (stat(handle->pathname, &sb) < 0) + if (stat(handle->pathname, &sb) == -1) goto error; handle->mtime = sb.st_mtime; @@ -173,7 +173,7 @@ table_db_lookup(struct table *table, enum table_service service, const char *key size_t i; struct stat sb; - if (stat(handle->pathname, &sb) < 0) + if (stat(handle->pathname, &sb) == -1) return -1; /* DB has changed, close and reopen */ diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index 2d9628488d6..b1d95aac0fe 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.140 2019/01/30 21:33:34 gilles Exp $ */ +/* $OpenBSD: util.c,v 1.141 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -570,7 +570,7 @@ secure_file(int fd, char *path, char *userdir, uid_t uid, int mayread) homedir[0] = '\0'; /* Check the open file to avoid races. */ - if (fstat(fd, &st) < 0 || + if (fstat(fd, &st) == -1 || !S_ISREG(st.st_mode) || st.st_uid != uid || (st.st_mode & (mayread ? 022 : 066)) != 0) @@ -582,7 +582,7 @@ secure_file(int fd, char *path, char *userdir, uid_t uid, int mayread) return 0; (void)strlcpy(buf, cp, sizeof(buf)); - if (stat(buf, &st) < 0 || + if (stat(buf, &st) == -1 || (st.st_uid != 0 && st.st_uid != uid) || (st.st_mode & 022) != 0) return 0; diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c index fb0ae33aff1..6a965a44b18 100644 --- a/usr.sbin/snmpd/mib.c +++ b/usr.sbin/snmpd/mib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.c,v 1.93 2019/05/02 14:04:10 gerhard Exp $ */ +/* $OpenBSD: mib.c,v 1.94 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2012 Joel Knight <joel@openbsd.org> @@ -1916,7 +1916,7 @@ mib_pflimits(struct oid *oid, struct ber_oid *o, struct ber_element **elm) if (pl.index == PF_LIMIT_MAX) return (-1); - if (ioctl(devpf, DIOCGETLIMIT, &pl)) { + if (ioctl(devpf, DIOCGETLIMIT, &pl) == -1) { log_warn("DIOCGETLIMIT"); return (-1); } @@ -1972,7 +1972,7 @@ mib_pftimeouts(struct oid *oid, struct ber_oid *o, struct ber_element **elm) if (pt.timeout == PFTM_MAX) return (-1); - if (ioctl(devpf, DIOCGETTIMEOUT, &pt)) { + if (ioctl(devpf, DIOCGETTIMEOUT, &pt) == -1) { log_warn("DIOCGETTIMEOUT"); return (-1); } @@ -2383,7 +2383,7 @@ mib_pflabelnum(struct oid *oid, struct ber_oid *o, struct ber_element **elm) extern int devpf; memset(&pr, 0, sizeof(pr)); - if (ioctl(devpf, DIOCGETRULES, &pr)) { + if (ioctl(devpf, DIOCGETRULES, &pr) == -1) { log_warn("DIOCGETRULES"); return (-1); } @@ -2392,7 +2392,7 @@ mib_pflabelnum(struct oid *oid, struct ber_oid *o, struct ber_element **elm) lnr = 0; for (nr = 0; nr < mnr; ++nr) { pr.nr = nr; - if (ioctl(devpf, DIOCGETRULE, &pr)) { + if (ioctl(devpf, DIOCGETRULE, &pr) == -1) { log_warn("DIOCGETRULE"); return (-1); } @@ -2420,7 +2420,7 @@ mib_pflabels(struct oid *oid, struct ber_oid *o, struct ber_element **elm) idx = o->bo_id[OIDIDX_pfLabelEntry]; memset(&pr, 0, sizeof(pr)); - if (ioctl(devpf, DIOCGETRULES, &pr)) { + if (ioctl(devpf, DIOCGETRULES, &pr) == -1) { log_warn("DIOCGETRULES"); return (-1); } @@ -2429,7 +2429,7 @@ mib_pflabels(struct oid *oid, struct ber_oid *o, struct ber_element **elm) lnr = 0; for (nr = 0; nr < mnr; ++nr) { pr.nr = nr; - if (ioctl(devpf, DIOCGETRULE, &pr)) { + if (ioctl(devpf, DIOCGETRULE, &pr) == -1) { log_warn("DIOCGETRULE"); return (-1); } diff --git a/usr.sbin/snmpd/pf.c b/usr.sbin/snmpd/pf.c index df4ccf7e5ff..ca610da0832 100644 --- a/usr.sbin/snmpd/pf.c +++ b/usr.sbin/snmpd/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.10 2015/02/06 23:21:59 millert Exp $ */ +/* $OpenBSD: pf.c,v 1.11 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2012 Joel Knight <joel@openbsd.org> @@ -73,7 +73,7 @@ pf_get_stats(struct pf_status *s) extern int devpf; memset(s, 0, sizeof(*s)); - if (ioctl(devpf, DIOCGETSTATUS, s)) { + if (ioctl(devpf, DIOCGETSTATUS, s) == -1) { log_warn("DIOCGETSTATUS"); return (-1); } @@ -98,7 +98,7 @@ pfr_get_astats(struct pfr_table *tbl, struct pfr_astats *addr, int *size, io.pfrio_buffer = addr; io.pfrio_esize = sizeof(*addr); io.pfrio_size = *size; - if (ioctl(devpf, DIOCRGETASTATS, &io)) + if (ioctl(devpf, DIOCRGETASTATS, &io) == -1) return (-1); *size = io.pfrio_size; return (0); @@ -120,7 +120,7 @@ pfr_get_tstats(struct pfr_table *filter, struct pfr_tstats *tbl, int *size, io.pfrio_buffer = tbl; io.pfrio_esize = sizeof(*tbl); io.pfrio_size = *size; - if (ioctl(devpf, DIOCRGETTSTATS, &io)) + if (ioctl(devpf, DIOCRGETTSTATS, &io) == -1) return (-1); *size = io.pfrio_size; return (0); @@ -198,7 +198,7 @@ pfi_get_ifaces(const char *filter, struct pfi_kif *buf, int *size) io.pfiio_buffer = buf; io.pfiio_esize = sizeof(*buf); io.pfiio_size = *size; - if (ioctl(devpf, DIOCIGETIFACES, &io)) + if (ioctl(devpf, DIOCIGETIFACES, &io) == -1) return (-1); *size = io.pfiio_size; return (0); diff --git a/usr.sbin/switchd/ofcconn.c b/usr.sbin/switchd/ofcconn.c index 059f2f4fdd9..1f2973a9ead 100644 --- a/usr.sbin/switchd/ofcconn.c +++ b/usr.sbin/switchd/ofcconn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofcconn.c,v 1.12 2016/10/12 19:07:42 reyk Exp $ */ +/* $OpenBSD: ofcconn.c,v 1.13 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2016 YASUOKA Masahiko <yasuoka@openbsd.org> @@ -243,7 +243,7 @@ ofsw_on_io(int fd, short evmask, void *ctx) if ((evmask & EV_READ) && ofsw_ofc_write_ready(os)) { if ((msgsz = read(os->os_fd, msg, sizeof(msg))) <= 0) { - if (msgsz < 0) + if (msgsz == -1) log_warn("%s: %s read", __func__, os->os_name); else log_warnx("%s: %s closed", __func__, @@ -310,7 +310,7 @@ ofsw_write(struct ofsw *os, struct ofcconn *oc0) } if (hdr->oh_type != OFP_T_HELLO) { if ((sz = write(os->os_fd, msg, msglen)) != msglen) { - if (sz < 0) + if (sz == -1) log_warn("%s: %s write failed", __func__, os->os_name); else diff --git a/usr.sbin/syslogd/evbuffer_tls.c b/usr.sbin/syslogd/evbuffer_tls.c index 9a0f8daecf1..3fa75c499a2 100644 --- a/usr.sbin/syslogd/evbuffer_tls.c +++ b/usr.sbin/syslogd/evbuffer_tls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evbuffer_tls.c,v 1.11 2017/07/04 15:52:26 bluhm Exp $ */ +/* $OpenBSD: evbuffer_tls.c,v 1.12 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2002-2004 Niels Provos <provos@citi.umich.edu> @@ -229,7 +229,7 @@ buffertls_handshakecb(int fd, short event, void *arg) what |= EVBUFFER_ERROR; break; } - if (res < 0) + if (res == -1) goto error; /* Handshake was successful, change to read and write callback. */ diff --git a/usr.sbin/syslogd/privsep.c b/usr.sbin/syslogd/privsep.c index 45463dbe703..1da7f4f46bd 100644 --- a/usr.sbin/syslogd/privsep.c +++ b/usr.sbin/syslogd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.69 2018/08/07 18:36:49 deraadt Exp $ */ +/* $OpenBSD: privsep.c,v 1.70 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org> @@ -110,7 +110,7 @@ priv_init(int lockfd, int nullfd, int argc, char *argv[]) errx(1, "unknown user _syslogd"); child_pid = fork(); - if (child_pid < 0) + if (child_pid == -1) err(1, "fork() failed"); if (!child_pid) { @@ -239,7 +239,7 @@ priv_exec(char *conf, int numeric, int child, int argc, char *argv[]) if (sigprocmask(SIG_SETMASK, &sigmask, NULL) == -1) err(1, "sigprocmask priv"); - if (stat(conf, &cf_info) < 0) + if (stat(conf, &cf_info) == -1) err(1, "stat config file failed"); TAILQ_INIT(&lognames); @@ -261,7 +261,7 @@ priv_exec(char *conf, int numeric, int child, int argc, char *argv[]) check_tty_name(path, sizeof(path)); fd = open(path, O_WRONLY|O_NONBLOCK, 0); send_fd(sock, fd); - if (fd < 0) + if (fd == -1) warnx("priv_open_tty failed"); else close(fd); @@ -287,7 +287,7 @@ priv_exec(char *conf, int numeric, int child, int argc, char *argv[]) errx(1, "invalid cmd"); send_fd(sock, fd); - if (fd < 0) + if (fd == -1) warnx("priv_open_log failed"); else close(fd); @@ -297,7 +297,7 @@ priv_exec(char *conf, int numeric, int child, int argc, char *argv[]) log_debug("[priv]: msg PRIV_OPEN_UTMP received"); fd = open(_PATH_UTMP, O_RDONLY|O_NONBLOCK, 0); send_fd(sock, fd); - if (fd < 0) + if (fd == -1) warnx("priv_open_utmp failed"); else close(fd); @@ -308,7 +308,7 @@ priv_exec(char *conf, int numeric, int child, int argc, char *argv[]) stat(conf, &cf_info); fd = open(conf, O_RDONLY|O_NONBLOCK, 0); send_fd(sock, fd); - if (fd < 0) + if (fd == -1) warnx("priv_open_config failed"); else close(fd); @@ -316,7 +316,7 @@ priv_exec(char *conf, int numeric, int child, int argc, char *argv[]) case PRIV_CONFIG_MODIFIED: log_debug("[priv]: msg PRIV_CONFIG_MODIFIED received"); - if (stat(conf, &cf_stat) < 0 || + if (stat(conf, &cf_stat) == -1 || timespeccmp(&cf_info.st_mtimespec, &cf_stat.st_mtimespec, <) || cf_info.st_size != cf_stat.st_size) { diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index a398eba5ab5..cd3ce8cc63a 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.259 2019/01/18 15:44:14 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.260 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2014-2017 Alexander Bluhm <bluhm@genua.de> @@ -1040,7 +1040,7 @@ klog_readcb(int fd, short event, void *arg) if (n > 0) { linebuf[n] = '\0'; printsys(linebuf); - } else if (n < 0 && errno != EINTR) { + } else if (n == -1 && errno != EINTR) { log_warn("read klog"); event_del(ev); } @@ -1063,7 +1063,7 @@ udp_readcb(int fd, short event, void *arg) cvthname((struct sockaddr *)&sa, resolve, sizeof(resolve)); log_debug("cvthname res: %s", resolve); printline(resolve, linebuf); - } else if (n < 0 && errno != EINTR && errno != EWOULDBLOCK) + } else if (n == -1 && errno != EINTR && errno != EWOULDBLOCK) log_warn("recvfrom udp"); } @@ -1080,7 +1080,7 @@ unix_readcb(int fd, short event, void *arg) if (n > 0) { linebuf[n] = '\0'; printline(LocalHostName, linebuf); - } else if (n < 0 && errno != EINTR && errno != EWOULDBLOCK) + } else if (n == -1 && errno != EINTR && errno != EWOULDBLOCK) log_warn("recvfrom unix"); } @@ -1180,7 +1180,7 @@ acceptcb(int lfd, short event, void *arg, int usetls) } p->p_ctx = NULL; if (usetls) { - if (tls_accept_socket(server_ctx, &p->p_ctx, fd) < 0) { + if (tls_accept_socket(server_ctx, &p->p_ctx, fd) == -1) { log_warnx("tls_accept_socket \"%s\": %s", peername, tls_error(server_ctx)); bufferevent_free(p->p_bufev); @@ -2063,7 +2063,7 @@ fprintlog(struct filed *f, int flags, char *msg) } retryonce = 0; again: - if (writev(f->f_file, iov, 6) < 0) { + if (writev(f->f_file, iov, 6) == -1) { int e = errno; /* allow to recover from file system full */ diff --git a/usr.sbin/syslogd/ttymsg.c b/usr.sbin/syslogd/ttymsg.c index f55e95edfb7..baa6e18ebfd 100644 --- a/usr.sbin/syslogd/ttymsg.c +++ b/usr.sbin/syslogd/ttymsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttymsg.c,v 1.17 2017/10/05 16:15:24 bluhm Exp $ */ +/* $OpenBSD: ttymsg.c,v 1.18 2019/06/28 13:32:51 deraadt Exp $ */ /* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */ /* @@ -112,7 +112,7 @@ ttymsg(struct iovec *iov, int iovcnt, char *utline) * open will fail on slip lines or exclusive-use lines * if not running as root; not an error. */ - if ((fd = priv_open_tty(device)) < 0) { + if ((fd = priv_open_tty(device)) == -1) { if (errno != EBUSY && errno != EACCES) log_warn("priv_open_tty device \"%s\"", device); return; @@ -208,7 +208,7 @@ ttycb(int fd, short event, void *arg) goto done; wret = write(fd, td->td_line, td->td_length); - if (wret < 0 && errno != EINTR && errno != EWOULDBLOCK) + if (wret == -1 && errno != EINTR && errno != EWOULDBLOCK) goto done; if (wret > 0) { td->td_length -= wret; diff --git a/usr.sbin/tcpdump/pfctl_osfp.c b/usr.sbin/tcpdump/pfctl_osfp.c index aaead627535..dcd39e6fe4d 100644 --- a/usr.sbin/tcpdump/pfctl_osfp.c +++ b/usr.sbin/tcpdump/pfctl_osfp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_osfp.c,v 1.15 2018/11/08 17:19:01 brynet Exp $ */ +/* $OpenBSD: pfctl_osfp.c,v 1.16 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2003 Mike Frantzen <frantzen@openbsd.org> @@ -263,7 +263,7 @@ pfctl_file_fingerprints(int dev, int opts, const char *fp_filename) void pfctl_clear_fingerprints(int dev, int opts) { - if (ioctl(dev, DIOCOSFPFLUSH)) + if (ioctl(dev, DIOCOSFPFLUSH) == -1) err(1, "DIOCOSFPFLUSH"); } @@ -294,7 +294,7 @@ pfctl_load_fingerprints(int dev, int opts) for (i = 0; i >= 0; i++) { memset(&io, 0, sizeof(io)); io.fp_getnum = i; - if (ioctl(dev, DIOCOSFPGET, &io)) { + if (ioctl(dev, DIOCOSFPGET, &io) == -1) { if (errno == EBUSY) break; warn("DIOCOSFPGET"); @@ -622,7 +622,7 @@ add_fingerprint(int dev, int opts, struct pf_osfp_ioctl *fp) /* Linked to the sys/net/pf_osfp.c. Call pf_osfp_add() */ if ((errno = pf_osfp_add(fp))) #else - if ((opts & PF_OPT_NOACTION) == 0 && ioctl(dev, DIOCOSFPADD, fp)) + if ((opts & PF_OPT_NOACTION) == 0 && ioctl(dev, DIOCOSFPADD, fp) == -1) #endif /* FAKE_PF_KERNEL */ { if (errno == EEXIST) { diff --git a/usr.sbin/tcpdump/privsep.c b/usr.sbin/tcpdump/privsep.c index 6e708216e2a..7caa398597e 100644 --- a/usr.sbin/tcpdump/privsep.c +++ b/usr.sbin/tcpdump/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.53 2019/03/18 00:09:22 dlg Exp $ */ +/* $OpenBSD: privsep.c,v 1.54 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2003 Can Erkin Acar @@ -172,7 +172,7 @@ priv_init(int argc, char **argv) sigprocmask(SIG_BLOCK, &allsigs, &oset); child_pid = fork(); - if (child_pid < 0) + if (child_pid == -1) err(1, "fork() failed"); if (child_pid) { @@ -404,7 +404,7 @@ impl_open_dump(int fd, const char *RFileName) } else { file = open(RFileName, O_RDONLY, 0); err = errno; - if (file < 0) + if (file == -1) logmsg(LOG_DEBUG, "[priv]: failed to open %s: %s", RFileName, strerror(errno)); } @@ -423,7 +423,7 @@ impl_open_pfosfp(int fd) file = open(PF_OSFP_FILE, O_RDONLY, 0); err = errno; - if (file < 0) + if (file == -1) logmsg(LOG_DEBUG, "[priv]: failed to open %s: %s", PF_OSFP_FILE, strerror(errno)); send_fd(fd, file); @@ -443,7 +443,7 @@ impl_open_output(int fd, const char *WFileName) err = errno; send_fd(fd, file); must_write(fd, &err, sizeof(int)); - if (file < 0) + if (file == -1) logmsg(LOG_DEBUG, "[priv]: failed to open %s: %s", WFileName, strerror(err)); else diff --git a/usr.sbin/tcpdump/privsep_pcap.c b/usr.sbin/tcpdump/privsep_pcap.c index 3d248ed1eb7..dd761ec6f53 100644 --- a/usr.sbin/tcpdump/privsep_pcap.c +++ b/usr.sbin/tcpdump/privsep_pcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep_pcap.c,v 1.24 2019/03/18 00:09:22 dlg Exp $ */ +/* $OpenBSD: privsep_pcap.c,v 1.25 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2004 Can Erkin Acar @@ -79,7 +79,7 @@ setfilter(int bpfd, int sock, char *filter) goto err; /* if bpf descriptor is open, set the filter XXX check oflag? */ - if (bpfd >= 0 && ioctl(bpfd, BIOCSETF, &fcode)) { + if (bpfd >= 0 && ioctl(bpfd, BIOCSETF, &fcode) == -1) { snprintf(hpcap.errbuf, PCAP_ERRBUF_SIZE, "ioctl: BIOCSETF: %s", strerror(errno)); pcap_freecode(&fcode); @@ -189,23 +189,23 @@ pcap_live(const char *device, int snaplen, int promisc, u_int dlt, ioctl(fd, BIOCSBLEN, &v); strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); - if (ioctl(fd, BIOCSETIF, &ifr) < 0) + if (ioctl(fd, BIOCSETIF, &ifr) == -1) goto error; - if (dlt != (u_int) -1 && ioctl(fd, BIOCSDLT, &dlt)) + if (dlt != (u_int) -1 && ioctl(fd, BIOCSDLT, &dlt) == -1) goto error; if (promisc) /* this is allowed to fail */ ioctl(fd, BIOCPROMISC, NULL); - if (ioctl(fd, BIOCSDIRFILT, &dirfilt) < 0) + if (ioctl(fd, BIOCSDIRFILT, &dirfilt) == -1) goto error; - if (ioctl(fd, BIOCSFILDROP, &fildrop) < 0) + if (ioctl(fd, BIOCSFILDROP, &fildrop) == -1) goto error; /* lock the descriptor */ - if (ioctl(fd, BIOCLOCK, NULL) < 0) + if (ioctl(fd, BIOCLOCK, NULL) == -1) goto error; return (fd); @@ -263,7 +263,7 @@ priv_pcap_live(const char *dev, int slen, int prom, int to_ms, } /* fd is locked, can only use 'safe' ioctls */ - if (ioctl(fd, BIOCVERSION, &bv) < 0) { + if (ioctl(fd, BIOCVERSION, &bv) == -1) { snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCVERSION: %s", pcap_strerror(errno)); goto bad; @@ -280,7 +280,7 @@ priv_pcap_live(const char *dev, int slen, int prom, int to_ms, p->snapshot = slen; /* Get the data link layer type. */ - if (ioctl(fd, BIOCGDLT, &v) < 0) { + if (ioctl(fd, BIOCGDLT, &v) == -1) { snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCGDLT: %s", pcap_strerror(errno)); goto bad; @@ -296,14 +296,14 @@ priv_pcap_live(const char *dev, int slen, int prom, int to_ms, struct timeval to; to.tv_sec = to_ms / 1000; to.tv_usec = (to_ms * 1000) % 1000000; - if (ioctl(p->fd, BIOCSRTIMEOUT, &to) < 0) { + if (ioctl(p->fd, BIOCSRTIMEOUT, &to) == -1) { snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCSRTIMEOUT: %s", pcap_strerror(errno)); goto bad; } } - if (ioctl(fd, BIOCGBLEN, &v) < 0) { + if (ioctl(fd, BIOCGBLEN, &v) == -1) { snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCGBLEN: %s", pcap_strerror(errno)); goto bad; diff --git a/usr.sbin/tcpdump/tcpdump.c b/usr.sbin/tcpdump/tcpdump.c index fadb1162d61..7664d8c4b3c 100644 --- a/usr.sbin/tcpdump/tcpdump.c +++ b/usr.sbin/tcpdump/tcpdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcpdump.c,v 1.90 2019/05/26 22:42:42 dlg Exp $ */ +/* $OpenBSD: tcpdump.c,v 1.91 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -188,7 +188,7 @@ pcap_list_linktypes(pcap_t *p) if (fd < 0) error("Invalid bpf descriptor"); - if (ioctl(fd, BIOCGDLTLIST, &dl) < 0) + if (ioctl(fd, BIOCGDLTLIST, &dl) == -1) err(1, "BIOCGDLTLIST"); if (dl.bfl_len > MAXDLT) diff --git a/usr.sbin/tcpdump/util.c b/usr.sbin/tcpdump/util.c index a344e7b9ae0..082ae5236aa 100644 --- a/usr.sbin/tcpdump/util.c +++ b/usr.sbin/tcpdump/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.28 2019/01/26 00:53:57 procter Exp $ */ +/* $OpenBSD: util.c,v 1.29 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 @@ -266,10 +266,10 @@ read_infile(char *fname) char *cp; fd = open(fname, O_RDONLY); - if (fd < 0) + if (fd == -1) error("can't open %s: %s", fname, pcap_strerror(errno)); - if (fstat(fd, &buf) < 0) + if (fstat(fd, &buf) == -1) error("can't stat %s: %s", fname, pcap_strerror(errno)); if (buf.st_size >= SSIZE_MAX) diff --git a/usr.sbin/tftpd/tftpd.c b/usr.sbin/tftpd/tftpd.c index b3c708b9e3e..5dd3533a2cd 100644 --- a/usr.sbin/tftpd/tftpd.c +++ b/usr.sbin/tftpd/tftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftpd.c,v 1.41 2018/01/26 16:40:14 naddy Exp $ */ +/* $OpenBSD: tftpd.c,v 1.42 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2012 David Gwynne <dlg@uq.edu.au> @@ -744,7 +744,7 @@ tftpd_recv(int fd, short events, void *arg) &on, sizeof(on)); if (bind(client->sock, (struct sockaddr *)&s_in, - s_in.ss_len) < 0) { + s_in.ss_len) == -1) { lwarn("bind to %s", getip(&s_in)); goto err; } @@ -1004,7 +1004,7 @@ retryread: * set. */ wmode = O_TRUNC; - if (stat(filename, &stbuf) < 0) { + if (stat(filename, &stbuf) == -1) { if (!cancreate) { /* * In -i mode, retry failed read requests from @@ -1043,12 +1043,12 @@ retryread: } } fd = open(filename, mode == RRQ ? O_RDONLY : (O_WRONLY|wmode), 0666); - if (fd < 0) + if (fd == -1) return (errno + 100); /* * If the file was created, set default permissions. */ - if ((wmode & O_CREAT) && fchmod(fd, 0666) < 0) { + if ((wmode & O_CREAT) && fchmod(fd, 0666) == -1) { int serrno = errno; close(fd); diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index c88ae555434..b120620528f 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute.c,v 1.160 2019/03/19 23:27:50 tedu Exp $ */ +/* $OpenBSD: traceroute.c,v 1.161 2019/06/28 13:32:51 deraadt Exp $ */ /* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */ /* @@ -347,14 +347,14 @@ main(int argc, char *argv[]) conf->waittime = 5 * 1000; - if ((rcvsock6 = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) + if ((rcvsock6 = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) == -1) v6sock_errno = errno; - else if ((sndsock6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) + else if ((sndsock6 = socket(AF_INET6, SOCK_DGRAM, 0)) == -1) v6sock_errno = errno; - if ((rcvsock4 = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) + if ((rcvsock4 = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) == -1) v4sock_errno = errno; - else if ((sndsock4 = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) + else if ((sndsock4 = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) == -1) v4sock_errno = errno; /* revoke privs */ @@ -400,12 +400,12 @@ main(int argc, char *argv[]) mib[3] = IPV6CTL_DEFHLIM; /* specify to tell receiving interface */ if (setsockopt(rcvsock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, - sizeof(on)) < 0) + sizeof(on)) == -1) err(1, "setsockopt(IPV6_RECVPKTINFO)"); /* specify to tell hoplimit field of received IP6 hdr */ if (setsockopt(rcvsock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, - sizeof(on)) < 0) + sizeof(on)) == -1) err(1, "setsockopt(IPV6_RECVHOPLIMIT)"); } @@ -687,7 +687,7 @@ main(int argc, char *argv[]) ip->ip_tos = conf->tos; if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, - &on, sizeof(on)) < 0) + &on, sizeof(on)) == -1) err(6, "IP_HDRINCL"); if (conf->source) { @@ -703,7 +703,7 @@ main(int argc, char *argv[]) errx(1, "source is on 127/8, destination is" " not"); if (ouid && bind(sndsock, (struct sockaddr *)&from4, - sizeof(from4)) < 0) + sizeof(from4)) == -1) err(1, "bind"); } packetlen = datalen; @@ -787,35 +787,34 @@ main(int argc, char *argv[]) nxt = to6; nxt.sin6_port = htons(DUMMY_PORT); - if ((dummy = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) + if ((dummy = socket(AF_INET6, SOCK_DGRAM, 0)) == -1) err(1, "socket"); if (conf->rtableid > 0 && setsockopt(dummy, SOL_SOCKET, SO_RTABLE, - &conf->rtableid, sizeof(conf->rtableid)) < 0) + &conf->rtableid, sizeof(conf->rtableid)) == -1) err(1, "setsockopt(SO_RTABLE)"); if (connect(dummy, (struct sockaddr *)&nxt, - nxt.sin6_len) < 0) + nxt.sin6_len) == -1) err(1, "connect"); len = sizeof(from6); if (getsockname(dummy, (struct sockaddr *)&from6, - &len) < 0) + &len) == -1) err(1, "getsockname"); close(dummy); } from6.sin6_port = htons(0); - if (bind(sndsock, (struct sockaddr *)&from6, from6.sin6_len) < - 0) + if (bind(sndsock, (struct sockaddr *)&from6, from6.sin6_len) == -1) err(1, "bind sndsock"); if (conf->tflag) { if (setsockopt(sndsock, IPPROTO_IPV6, IPV6_TCLASS, - &conf->tos, sizeof(conf->tos)) < 0) + &conf->tos, sizeof(conf->tos)) == -1) err(6, "IPV6_TCLASS"); } len = sizeof(from6); - if (getsockname(sndsock, (struct sockaddr *)&from6, &len) < 0) + if (getsockname(sndsock, (struct sockaddr *)&from6, &len) == -1) err(1, "getsockname"); srcport = ntohs(from6.sin6_port); break; @@ -832,7 +831,7 @@ main(int argc, char *argv[]) } if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, - &datalen, sizeof(datalen)) < 0) + &datalen, sizeof(datalen)) == -1) err(6, "SO_SNDBUF"); if (conf->nflag && !conf->Aflag) { diff --git a/usr.sbin/traceroute/worker.c b/usr.sbin/traceroute/worker.c index 92979359c21..e56bf59dff1 100644 --- a/usr.sbin/traceroute/worker.c +++ b/usr.sbin/traceroute/worker.c @@ -1,4 +1,4 @@ -/* $OpenBSD: worker.c,v 1.5 2017/08/03 17:36:06 florian Exp $ */ +/* $OpenBSD: worker.c,v 1.6 2019/06/28 13:32:51 deraadt Exp $ */ /* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */ /* @@ -324,7 +324,7 @@ build_probe6(struct tr_conf *conf, int seq, u_int8_t hops, int iflag, i = hops; if (setsockopt(sndsock, IPPROTO_IPV6, IPV6_UNICAST_HOPS, - (char *)&i, sizeof(i)) < 0) + (char *)&i, sizeof(i)) == -1) warn("setsockopt IPV6_UNICAST_HOPS"); if (iflag) @@ -373,8 +373,8 @@ send_probe(struct tr_conf *conf, int seq, u_int8_t ttl, int iflag, dump_packet(); i = sendto(sndsock, outpacket, datalen, 0, to, to->sa_len); - if (i < 0 || i != datalen) { - if (i < 0) + if (i == -1 || i != datalen) { + if (i == -1) warn("sendto"); printf("%s: wrote %s %d chars, ret=%d\n", __progname, hostname, datalen, i); diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c index 2b352823a98..2e39803df59 100644 --- a/usr.sbin/user/user.c +++ b/usr.sbin/user/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.125 2019/06/28 05:35:35 deraadt Exp $ */ +/* $OpenBSD: user.c,v 1.126 2019/06/28 13:32:51 deraadt Exp $ */ /* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */ /* @@ -249,7 +249,7 @@ removehomedir(const char *user, uid_t uid, const char *dir) } /* directory exists (and is a directory!) */ - if (stat(dir, &st) < 0) { + if (stat(dir, &st) == -1) { warnx("Home directory `%s' doesn't exist", dir); return 0; } @@ -269,7 +269,7 @@ removehomedir(const char *user, uid_t uid, const char *dir) /* we add the "|| true" to keep asystem() quiet if there is a non-zero exit status. */ (void) asystem("%s -rf %s > /dev/null 2>&1 || true", RM, dir); (void) seteuid(0); - if (rmdir(dir) < 0) { + if (rmdir(dir) == -1) { warnx("Unable to remove all files in `%s'", dir); return 0; } @@ -357,7 +357,7 @@ creategid(char *group, gid_t gid, const char *name) _PATH_GROUP); return 0; } - if (flock(fileno(from), LOCK_EX | LOCK_NB) < 0) { + if (flock(fileno(from), LOCK_EX | LOCK_NB) == -1) { warn("can't lock `%s'", _PATH_GROUP); } (void) fstat(fileno(from), &st); @@ -398,7 +398,7 @@ creategid(char *group, gid_t gid, const char *name) unlink(f); return 0; } - if (rename(f, _PATH_GROUP) < 0) { + if (rename(f, _PATH_GROUP) == -1) { warn("can't create gid: can't rename `%s' to `%s'", f, _PATH_GROUP); unlink(f); @@ -429,7 +429,7 @@ modify_gid(char *group, char *newent) _PATH_GROUP); return 0; } - if (flock(fileno(from), LOCK_EX | LOCK_NB) < 0) { + if (flock(fileno(from), LOCK_EX | LOCK_NB) == -1) { warn("can't lock `%s'", _PATH_GROUP); } (void) fstat(fileno(from), &st); @@ -497,7 +497,7 @@ modify_gid(char *group, char *newent) unlink(f); return 0; } - if (rename(f, _PATH_GROUP) < 0) { + if (rename(f, _PATH_GROUP) == -1) { warn("can't modify gid: can't rename `%s' to `%s'", f, _PATH_GROUP); unlink(f); return 0; @@ -554,7 +554,7 @@ append_group(char *user, int ngroups, const char **groups) _PATH_GROUP); return 0; } - if (flock(fileno(from), LOCK_EX | LOCK_NB) < 0) { + if (flock(fileno(from), LOCK_EX | LOCK_NB) == -1) { warn("can't lock `%s'", _PATH_GROUP); } (void) fstat(fileno(from), &st); @@ -624,7 +624,7 @@ append_group(char *user, int ngroups, const char **groups) unlink(f); return 0; } - if (rename(f, _PATH_GROUP) < 0) { + if (rename(f, _PATH_GROUP) == -1) { warn("can't append group: can't rename `%s' to `%s'", f, _PATH_GROUP); unlink(f); return 0; @@ -801,7 +801,7 @@ read_defaults(user_t *up) up->u_inactive = DEF_INACTIVE; up->u_expire = DEF_EXPIRE; if ((fp = fopen(CONFFILE, "r")) == NULL) { - if (stat(CONFFILE, &st) < 0 && !setdefaults(up)) { + if (stat(CONFFILE, &st) == -1 && !setdefaults(up)) { warn("can't create `%s' defaults file", CONFFILE); } fp = fopen(CONFFILE, "r"); @@ -1001,14 +1001,14 @@ adduser(char *login_name, user_t *up) if (!valid_class(up->u_class)) { errx(EXIT_FAILURE, "No such login class `%s'", up->u_class); } - if ((masterfd = open(_PATH_MASTERPASSWD, O_RDONLY)) < 0) { + if ((masterfd = open(_PATH_MASTERPASSWD, O_RDONLY)) == -1) { err(EXIT_FAILURE, "can't open `%s'", _PATH_MASTERPASSWD); } - if (flock(masterfd, LOCK_EX | LOCK_NB) < 0) { + if (flock(masterfd, LOCK_EX | LOCK_NB) == -1) { err(EXIT_FAILURE, "can't lock `%s'", _PATH_MASTERPASSWD); } pw_init(); - if ((ptmpfd = pw_lock(WAITSECS)) < 0) { + if ((ptmpfd = pw_lock(WAITSECS)) == -1) { int saved_errno = errno; close(masterfd); errc(EXIT_FAILURE, saved_errno, "can't obtain pw_lock"); @@ -1132,7 +1132,7 @@ adduser(char *login_name, user_t *up) warnx("Warning: expire time `%s' invalid, account expiry off", up->u_expire); } - if (lstat(home, &st) < 0 && !(up->u_flags & F_MKDIR) && + if (lstat(home, &st) == -1 && !(up->u_flags & F_MKDIR) && strcmp(home, _PATH_NONEXISTENT) != 0) { warnx("Warning: home directory `%s' doesn't exist, and -m was" " not specified", home); @@ -1232,7 +1232,7 @@ adduser(char *login_name, user_t *up) } fclose(fp); close(ptmpfd); - if (pw_mkdb(yp ? NULL : login_name, 0) < 0) { + if (pw_mkdb(yp ? NULL : login_name, 0) == -1) { pw_abort(); err(EXIT_FAILURE, "pw_mkdb failed"); } @@ -1261,7 +1261,7 @@ rm_user_from_groups(char *login_name) login_name, _PATH_GROUP); return 0; } - if (flock(fileno(from), LOCK_EX | LOCK_NB) < 0) { + if (flock(fileno(from), LOCK_EX | LOCK_NB) == -1) { warn("can't lock `%s'", _PATH_GROUP); } (void) fstat(fileno(from), &st); @@ -1331,7 +1331,7 @@ rm_user_from_groups(char *login_name) unlink(f); return 0; } - if (rename(f, _PATH_GROUP) < 0) { + if (rename(f, _PATH_GROUP) == -1) { warn("can't remove gid for `%s': can't rename `%s' to `%s'", login_name, f, _PATH_GROUP); unlink(f); @@ -1435,14 +1435,14 @@ moduser(char *login_name, char *newlogin, user_t *up) /* get the last char of the shell in case we need it for '-U' or '-Z' */ shell_last_char = pwp->pw_shell+strlen(pwp->pw_shell) - 1; - if ((masterfd = open(_PATH_MASTERPASSWD, O_RDONLY)) < 0) { + if ((masterfd = open(_PATH_MASTERPASSWD, O_RDONLY)) == -1) { err(EXIT_FAILURE, "can't open `%s'", _PATH_MASTERPASSWD); } - if (flock(masterfd, LOCK_EX | LOCK_NB) < 0) { + if (flock(masterfd, LOCK_EX | LOCK_NB) == -1) { err(EXIT_FAILURE, "can't lock `%s'", _PATH_MASTERPASSWD); } pw_init(); - if ((ptmpfd = pw_lock(WAITSECS)) < 0) { + if ((ptmpfd = pw_lock(WAITSECS)) == -1) { int saved_errno = errno; close(masterfd); errc(EXIT_FAILURE, saved_errno, "can't obtain pw_lock"); diff --git a/usr.sbin/vipw/vipw.c b/usr.sbin/vipw/vipw.c index 83ba0c117c9..685a437b73a 100644 --- a/usr.sbin/vipw/vipw.c +++ b/usr.sbin/vipw/vipw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vipw.c,v 1.23 2019/03/25 15:45:18 robert Exp $ */ +/* $OpenBSD: vipw.c,v 1.24 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -76,10 +76,10 @@ main(int argc, char *argv[]) pw_init(); tfd = pw_lock(0); - if (tfd < 0) + if (tfd == -1) errx(1, "the passwd file is busy or you cannot lock."); pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0); - if (pfd < 0) + if (pfd == -1) pw_error(_PATH_MASTERPASSWD, 1, 1); copyfile(pfd, tfd, &begin); (void)close(tfd); @@ -112,9 +112,9 @@ copyfile(int from, int to, struct stat *sb) pw_error(_PATH_MASTERPASSWD, 1, 1); while ((nr = read(from, buf, sizeof(buf))) > 0) for (off = 0; nr > 0; nr -= nw, off += nw) - if ((nw = write(to, buf + off, nr)) < 0) + if ((nw = write(to, buf + off, nr)) == -1) pw_error(_PATH_MASTERPASSWD_LOCK, 1, 1); - if (nr < 0) + if (nr == -1) pw_error(_PATH_MASTERPASSWD, 1, 1); ts[0] = sb->st_atim; diff --git a/usr.sbin/vmd/priv.c b/usr.sbin/vmd/priv.c index 54db0b66b63..6ced20244ea 100644 --- a/usr.sbin/vmd/priv.c +++ b/usr.sbin/vmd/priv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: priv.c,v 1.14 2018/11/21 12:31:47 reyk Exp $ */ +/* $OpenBSD: priv.c,v 1.15 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2016 Reyk Floeter <reyk@openbsd.org> @@ -124,13 +124,13 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) /* Set the interface description */ strlcpy(ifr.ifr_name, vfr.vfr_name, sizeof(ifr.ifr_name)); ifr.ifr_data = (caddr_t)vfr.vfr_value; - if (ioctl(env->vmd_fd, SIOCSIFDESCR, &ifr) < 0) + if (ioctl(env->vmd_fd, SIOCSIFDESCR, &ifr) == -1) log_warn("SIOCSIFDESCR"); break; case IMSG_VMDOP_PRIV_IFRDOMAIN: strlcpy(ifr.ifr_name, vfr.vfr_name, sizeof(ifr.ifr_name)); ifr.ifr_rdomainid = vfr.vfr_id; - if (ioctl(env->vmd_fd, SIOCSIFRDOMAIN, &ifr) < 0) + if (ioctl(env->vmd_fd, SIOCSIFRDOMAIN, &ifr) == -1) log_warn("SIOCSIFRDOMAIN"); break; case IMSG_VMDOP_PRIV_IFADD: @@ -143,14 +143,14 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) sizeof(ifbr.ifbr_name)); strlcpy(ifbr.ifbr_ifsname, vfr.vfr_value, sizeof(ifbr.ifbr_ifsname)); - if (ioctl(env->vmd_fd, SIOCBRDGADD, &ifbr) < 0 && + if (ioctl(env->vmd_fd, SIOCBRDGADD, &ifbr) == -1 && errno != EEXIST) log_warn("SIOCBRDGADD"); break; case IMSG_VMDOP_PRIV_IFEXISTS: /* Determine if bridge/switch exists */ strlcpy(ifr.ifr_name, vfr.vfr_name, sizeof(ifr.ifr_name)); - if (ioctl(env->vmd_fd, SIOCGIFFLAGS, &ifr) < 0) + if (ioctl(env->vmd_fd, SIOCGIFFLAGS, &ifr) == -1) fatalx("%s: bridge \"%s\" does not exist", __func__, vfr.vfr_name); break; @@ -158,7 +158,7 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) case IMSG_VMDOP_PRIV_IFDOWN: /* Set the interface status */ strlcpy(ifr.ifr_name, vfr.vfr_name, sizeof(ifr.ifr_name)); - if (ioctl(env->vmd_fd, SIOCGIFFLAGS, &ifr) < 0) { + if (ioctl(env->vmd_fd, SIOCGIFFLAGS, &ifr) == -1) { log_warn("SIOCGIFFLAGS"); break; } @@ -166,7 +166,7 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) ifr.ifr_flags |= IFF_UP; else ifr.ifr_flags &= ~IFF_UP; - if (ioctl(env->vmd_fd, SIOCSIFFLAGS, &ifr) < 0) + if (ioctl(env->vmd_fd, SIOCSIFFLAGS, &ifr) == -1) log_warn("SIOCSIFFLAGS"); break; case IMSG_VMDOP_PRIV_IFGROUP: @@ -179,7 +179,7 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) sizeof(ifgr.ifgr_group)) >= sizeof(ifgr.ifgr_group)) fatalx("%s: group name too long", __func__); - if (ioctl(env->vmd_fd, SIOCAIFGROUP, &ifgr) < 0 && + if (ioctl(env->vmd_fd, SIOCAIFGROUP, &ifgr) == -1 && errno != EEXIST) log_warn("SIOCAIFGROUP"); break; @@ -202,7 +202,7 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) memcpy(&ifra.ifra_mask, &vfr.vfr_mask, ifra.ifra_mask.sa_len); - if (ioctl(env->vmd_fd, SIOCAIFADDR, &ifra) < 0) + if (ioctl(env->vmd_fd, SIOCAIFADDR, &ifra) == -1) log_warn("SIOCAIFADDR"); break; case IMSG_VMDOP_PRIV_IFADDR6: @@ -217,7 +217,7 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) strlcpy(ifar.ifar_name, vfr.vfr_name, sizeof(ifar.ifar_name)); ifar.ifar_af = AF_INET6; - if (ioctl(env->vmd_fd, SIOCIFAFATTACH, (caddr_t)&ifar) < 0) + if (ioctl(env->vmd_fd, SIOCIFAFATTACH, (caddr_t)&ifar) == -1) log_warn("SIOCIFAFATTACH"); /* Set the interface address */ @@ -237,11 +237,11 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) in6_ifra.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME; in6_ifra.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; - if (ioctl(env->vmd_fd6, SIOCDIFADDR_IN6, &in6_ifra) < 0 && + if (ioctl(env->vmd_fd6, SIOCDIFADDR_IN6, &in6_ifra) == -1 && errno != EADDRNOTAVAIL) log_warn("SIOCDIFADDR_IN6"); - if (ioctl(env->vmd_fd6, SIOCAIFADDR_IN6, &in6_ifra) < 0) + if (ioctl(env->vmd_fd6, SIOCAIFADDR_IN6, &in6_ifra) == -1) log_warn("SIOCAIFADDR_IN6"); break; case IMSG_VMDOP_CONFIG: diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c index 72b2e379ac3..16683af31cb 100644 --- a/usr.sbin/vmd/vm.c +++ b/usr.sbin/vmd/vm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm.c,v 1.49 2019/05/28 03:20:59 pd Exp $ */ +/* $OpenBSD: vm.c,v 1.50 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -571,7 +571,7 @@ send_vm(int fd, struct vm_create_params *vcp) goto err; vtp.vtp_vm_id = vcp->vcp_id; - if (ioctl(env->vmd_fd, VMM_IOC_TERM, &vtp) < 0) { + if (ioctl(env->vmd_fd, VMM_IOC_TERM, &vtp) == -1) { log_warnx("%s: term IOC error: %d, %d", __func__, errno, ENOENT); } @@ -746,7 +746,7 @@ vcpu_reset(uint32_t vmid, uint32_t vcpu_id, struct vcpu_reg_state *vrs) log_debug("%s: resetting vcpu %d for vm %d", __func__, vcpu_id, vmid); - if (ioctl(env->vmd_fd, VMM_IOC_RESETCPU, &vrp) < 0) + if (ioctl(env->vmd_fd, VMM_IOC_RESETCPU, &vrp) == -1) return (errno); return (0); @@ -897,7 +897,7 @@ vmm_create_vm(struct vm_create_params *vcp) if (vcp->vcp_nnics > VMM_MAX_NICS_PER_VM) return (EINVAL); - if (ioctl(env->vmd_fd, VMM_IOC_CREATE, vcp) < 0) + if (ioctl(env->vmd_fd, VMM_IOC_CREATE, vcp) == -1) return (errno); return (0); @@ -1157,7 +1157,7 @@ run_vm(int child_cdrom, int child_disks[][VM_MAX_BASE_PER_DISK], vregsp.vrwp_regs = *vrs; vregsp.vrwp_mask = VM_RWREGS_ALL; if ((ret = ioctl(env->vmd_fd, VMM_IOC_WRITEREGS, - &vregsp)) < 0) { + &vregsp)) == -1) { log_warn("%s: writeregs failed", __func__); return (ret); } @@ -1355,7 +1355,7 @@ vcpu_run_loop(void *arg) } } - if (ioctl(env->vmd_fd, VMM_IOC_RUN, vrp) < 0) { + if (ioctl(env->vmd_fd, VMM_IOC_RUN, vrp) == -1) { /* If run ioctl failed, exit */ ret = errno; log_warn("%s: vm %d / vcpu %d run ioctl failed", @@ -1399,7 +1399,7 @@ vcpu_pic_intr(uint32_t vm_id, uint32_t vcpu_id, uint8_t intr) vip.vip_vcpu_id = vcpu_id; /* XXX always 0? */ vip.vip_intr = intr; - if (ioctl(env->vmd_fd, VMM_IOC_INTR, &vip) < 0) + if (ioctl(env->vmd_fd, VMM_IOC_INTR, &vip) == -1) return (errno); return (0); diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index 01eeba77f27..23c34dd6dd1 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.113 2019/05/20 17:04:24 jasper Exp $ */ +/* $OpenBSD: vmd.c,v 1.114 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -1736,7 +1736,7 @@ vm_opentty(struct vmd_vm *vm) * We use user ioctl(2) mode to pass break commands. */ on = 1; - if (ioctl(ptm.cfd, TIOCUCNTL, &on)) + if (ioctl(ptm.cfd, TIOCUCNTL, &on) == -1) fatal("could not enable user ioctl mode"); vm->vm_tty = ptm.cfd; diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c index 1cb70b6989a..ab01e2589ce 100644 --- a/usr.sbin/vmd/vmm.c +++ b/usr.sbin/vmd/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.92 2019/05/11 19:55:14 jasper Exp $ */ +/* $OpenBSD: vmm.c,v 1.93 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -769,7 +769,7 @@ get_info_vm(struct privsep *ps, struct imsg *imsg, int terminate) memset(&vir, 0, sizeof(vir)); /* First ioctl to see how many bytes needed (vip.vip_size) */ - if (ioctl(env->vmd_fd, VMM_IOC_INFO, &vip) < 0) + if (ioctl(env->vmd_fd, VMM_IOC_INFO, &vip) == -1) return (errno); if (vip.vip_info_ct != 0) @@ -781,7 +781,7 @@ get_info_vm(struct privsep *ps, struct imsg *imsg, int terminate) /* Second ioctl to get the actual list */ vip.vip_info = info; - if (ioctl(env->vmd_fd, VMM_IOC_INFO, &vip) < 0) { + if (ioctl(env->vmd_fd, VMM_IOC_INFO, &vip) == -1) { ret = errno; free(info); return (ret); diff --git a/usr.sbin/wsfontload/wsfontload.c b/usr.sbin/wsfontload/wsfontload.c index 97f2242220e..1cdc1bf50af 100644 --- a/usr.sbin/wsfontload/wsfontload.c +++ b/usr.sbin/wsfontload/wsfontload.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsfontload.c,v 1.20 2017/08/23 09:15:33 fcambus Exp $ */ +/* $OpenBSD: wsfontload.c,v 1.21 2019/06/28 13:32:51 deraadt Exp $ */ /* $NetBSD: wsfontload.c,v 1.2 2000/01/05 18:46:43 ad Exp $ */ /* @@ -136,7 +136,7 @@ main(int argc, char *argv[]) usage(); wsfd = open(wsdev, O_RDWR, 0); - if (wsfd < 0) + if (wsfd == -1) err(2, "open %s", wsdev); if (list) { @@ -167,7 +167,7 @@ main(int argc, char *argv[]) if (argc > 0) { infile = argv[0]; ffd = open(infile, O_RDONLY, 0); - if (ffd < 0) + if (ffd == -1) err(4, "open %s", infile); if (!*f.name) strlcpy(f.name, infile, WSFONT_NAME_SIZE); @@ -229,7 +229,7 @@ main(int argc, char *argv[]) if (!buf) errx(1, "malloc"); res = read(ffd, buf, len); - if (res < 0) + if (res == -1) err(4, "read %s", infile); if (res != len) errx(4, "short read on %s", infile); @@ -237,7 +237,7 @@ main(int argc, char *argv[]) f.data = buf; res = ioctl(wsfd, WSDISPLAYIO_LDFONT, &f); - if (res < 0) + if (res == -1) err(3, "WSDISPLAYIO_LDFONT"); return (0); diff --git a/usr.sbin/wsmoused/mouse_protocols.c b/usr.sbin/wsmoused/mouse_protocols.c index 2caf4b10a14..81ab3f713be 100644 --- a/usr.sbin/wsmoused/mouse_protocols.c +++ b/usr.sbin/wsmoused/mouse_protocols.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mouse_protocols.c,v 1.16 2014/05/14 18:28:22 shadchin Exp $ */ +/* $OpenBSD: mouse_protocols.c,v 1.17 2019/06/28 13:32:51 deraadt Exp $ */ /* * Copyright (c) 2001 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon @@ -189,7 +189,7 @@ SetMouseSpeed(int old, unsigned int cflag) struct termios tty; char *c; - if (tcgetattr(mouse.mfd, &tty) < 0) { + if (tcgetattr(mouse.mfd, &tty) == -1) { debug("Warning: %s unable to get status of mouse fd (%s)\n", mouse.portname, strerror(errno)); return; @@ -220,7 +220,7 @@ SetMouseSpeed(int old, unsigned int cflag) cfsetospeed(&tty, B1200); } - if (tcsetattr(mouse.mfd, TCSADRAIN, &tty) < 0) + if (tcsetattr(mouse.mfd, TCSADRAIN, &tty) == -1) logerr(1, "unable to get mouse status. Exiting...\n"); c = "*n"; @@ -233,7 +233,7 @@ SetMouseSpeed(int old, unsigned int cflag) } usleep(100000); - if (tcsetattr(mouse.mfd, TCSADRAIN, &tty) < 0) + if (tcsetattr(mouse.mfd, TCSADRAIN, &tty) == -1) logerr(1, "unable to get mouse status. Exiting...\n"); } diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c index 944daef08d2..a4ce3f62ff1 100644 --- a/usr.sbin/ypbind/ypbind.c +++ b/usr.sbin/ypbind/ypbind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypbind.c,v 1.72 2018/04/26 15:55:14 guenther Exp $ */ +/* $OpenBSD: ypbind.c,v 1.73 2019/06/28 13:32:52 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt <deraadt@openbsd.org> @@ -470,7 +470,7 @@ main(int argc, char *argv[]) } } - if ((rpcsock = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0)) < 0) { + if ((rpcsock = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0)) == -1) { perror("socket"); return -1; } @@ -480,7 +480,7 @@ main(int argc, char *argv[]) sin.sin_port = 0; bindresvport(rpcsock, &sin); - if ((pingsock = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0)) < 0) { + if ((pingsock = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0)) == -1) { perror("socket"); return -1; } @@ -653,7 +653,7 @@ ping(struct _dom_binding *ypdb) ypdb->dom_alive = 2; if (sendto(pingsock, buf, outlen, 0, (struct sockaddr *)&ypdb->dom_server_addr, - (socklen_t)sizeof ypdb->dom_server_addr) < 0) + (socklen_t)sizeof ypdb->dom_server_addr) == -1) perror("sendto"); return 0; @@ -732,7 +732,7 @@ pings(struct _dom_binding *ypdb) bindsin.sin_port = htons(PMAPPORT); bindsin.sin_addr = ypdb->dom_server_addr.sin_addr; if (sendto(rpcsock, buf, outlen, 0, (struct sockaddr *)&bindsin, - (socklen_t)sizeof bindsin) < 0) + (socklen_t)sizeof bindsin) == -1) perror("sendto"); } if (ypdb->dom_servlistfp) @@ -779,7 +779,7 @@ broadcast(struct _dom_binding *ypdb, char *buf, int outlen) bindsin.sin_addr = in; if (sendto(rpcsock, buf, outlen, 0, (struct sockaddr *)&bindsin, - (socklen_t)bindsin.sin_len) < 0) + (socklen_t)bindsin.sin_len) == -1) perror("sendto"); } freeifaddrs(ifap); @@ -836,7 +836,7 @@ direct(struct _dom_binding *ypdb, char *buf, int outlen) hp->h_length); if (sendto(rpcsock, buf, outlen, 0, (struct sockaddr *)&bindsin, - (socklen_t)sizeof bindsin) < 0) { + (socklen_t)sizeof bindsin) == -1) { perror("sendto"); continue; } @@ -867,7 +867,7 @@ try_again: fromlen = sizeof (struct sockaddr); inlen = recvfrom(rpcsock, buf, sizeof buf, 0, (struct sockaddr *)&raddr, &fromlen); - if (inlen < 0) { + if (inlen == -1) { if (errno == EINTR) goto try_again; return RPC_CANTRECV; @@ -919,7 +919,7 @@ try_again: fromlen = sizeof (struct sockaddr); inlen = recvfrom(pingsock, buf, sizeof buf, 0, (struct sockaddr *)&raddr, &fromlen); - if (inlen < 0) { + if (inlen == -1) { if (errno == EINTR) goto try_again; return RPC_CANTRECV; diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c index 82b640ce19c..473986a8c5e 100644 --- a/usr.sbin/ypldap/ldapclient.c +++ b/usr.sbin/ypldap/ldapclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapclient.c,v 1.42 2018/11/27 12:06:39 martijn Exp $ */ +/* $OpenBSD: ldapclient.c,v 1.43 2019/06/28 13:32:52 deraadt Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> @@ -77,7 +77,7 @@ client_aldap_open(struct ypldap_addr_list *addr) sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) errx(1, "could not get numeric hostname"); - if ((fd = socket(sa->sa_family, SOCK_STREAM, 0)) < 0) + if ((fd = socket(sa->sa_family, SOCK_STREAM, 0)) == -1) return NULL; if (connect(fd, sa, SA_LEN(sa)) == 0) |