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 /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 'sbin')
76 files changed, 552 insertions, 553 deletions
diff --git a/sbin/badsect/badsect.c b/sbin/badsect/badsect.c index b9f2723e2f0..497cee7c6e2 100644 --- a/sbin/badsect/badsect.c +++ b/sbin/badsect/badsect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: badsect.c,v 1.27 2015/11/12 22:33:07 deraadt Exp $ */ +/* $OpenBSD: badsect.c,v 1.28 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: badsect.c,v 1.10 1995/03/18 14:54:28 cgd Exp $ */ /* @@ -87,7 +87,7 @@ main(int argc, char *argv[]) fprintf(stderr, "usage: badsect bbdir sector ...\n"); exit(1); } - if (chdir(argv[1]) < 0 || stat(".", &stbuf) < 0) + if (chdir(argv[1]) == -1 || stat(".", &stbuf) == -1) err(2, "%s", argv[1]); strlcpy(name, _PATH_DEV, sizeof name); @@ -97,7 +97,7 @@ main(int argc, char *argv[]) while ((dp = readdir(dirp)) != NULL) { strlcpy(&name[len], dp->d_name, sizeof name - len); - if (stat(name, &devstat) < 0) + if (stat(name, &devstat) == -1) err(4, "%s", name); if (stbuf.st_dev == devstat.st_rdev && @@ -119,7 +119,7 @@ main(int argc, char *argv[]) err(5, "Cannot find dev 0%o corresponding to %s", stbuf.st_rdev, argv[1]); - if ((fsi = open(name, O_RDONLY)) < 0) + if ((fsi = open(name, O_RDONLY)) == -1) err(6, "%s", name); fs = &sblock; diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index f21dd2f6d57..0353928f1ef 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioctl.c,v 1.142 2019/05/11 20:24:55 krw Exp $ */ +/* $OpenBSD: bioctl.c,v 1.143 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Marco Peereboom @@ -233,7 +233,7 @@ main(int argc, char *argv[]) memset(&bl, 0, sizeof(bl)); bl.bl_name = devicename; - if (ioctl(devh, BIOCLOCATE, &bl)) + if (ioctl(devh, BIOCLOCATE, &bl) == -1) errx(1, "Can't locate %s device via %s", bl.bl_name, "/dev/bio"); @@ -397,7 +397,7 @@ bio_inq(char *name) bi.bi_bio.bio_cookie = bio_cookie; - if (ioctl(devh, BIOCINQ, &bi)) { + if (ioctl(devh, BIOCINQ, &bi) == -1) { if (errno == ENOTTY) bio_diskinq(name); else @@ -415,7 +415,7 @@ bio_inq(char *name) bv.bv_percent = -1; bv.bv_seconds = 0; - if (ioctl(devh, BIOCVOL, &bv)) + if (ioctl(devh, BIOCVOL, &bv) == -1) err(1, "BIOCVOL"); bio_status(&bv.bv_bio.bio_status); @@ -515,7 +515,7 @@ bio_inq(char *name) bd.bd_patrol.bdp_percent = -1; bd.bd_patrol.bdp_seconds = 0; - if (ioctl(devh, BIOCDISK, &bd)) + if (ioctl(devh, BIOCDISK, &bd) == -1) err(1, "BIOCDISK"); bio_status(&bd.bd_bio.bio_status); @@ -626,7 +626,7 @@ bio_alarm(char *arg) errx(1, "invalid alarm function: %s", arg); } - if (ioctl(devh, BIOCALARM, &ba)) + if (ioctl(devh, BIOCALARM, &ba) == -1) err(1, "BIOCALARM"); bio_status(&ba.ba_bio.bio_status); @@ -645,7 +645,7 @@ bio_getvolbyname(char *name) memset(&bi, 0, sizeof(bi)); bi.bi_bio.bio_cookie = bio_cookie; - if (ioctl(devh, BIOCINQ, &bi)) + if (ioctl(devh, BIOCINQ, &bi) == -1) err(1, "BIOCINQ"); bio_status(&bi.bi_bio.bio_status); @@ -654,7 +654,7 @@ bio_getvolbyname(char *name) memset(&bv, 0, sizeof(bv)); bv.bv_bio.bio_cookie = bio_cookie; bv.bv_volid = i; - if (ioctl(devh, BIOCVOL, &bv)) + if (ioctl(devh, BIOCVOL, &bv) == -1) err(1, "BIOCVOL"); bio_status(&bv.bv_bio.bio_status); @@ -701,7 +701,7 @@ bio_setstate(char *arg, int status, char *devicename) errx(1, "invalid device %s", devicename); } - if (ioctl(devh, BIOCSETSTATE, &bs)) + if (ioctl(devh, BIOCSETSTATE, &bs) == -1) err(1, "BIOCSETSTATE"); bio_status(&bs.bs_bio.bio_status); @@ -742,7 +742,7 @@ bio_setblink(char *name, char *arg, int blink) memset(&bi, 0, sizeof(bi)); bi.bi_bio.bio_cookie = bio_cookie; - if (ioctl(devh, BIOCINQ, &bi)) + if (ioctl(devh, BIOCINQ, &bi) == -1) err(1, "BIOCINQ"); bio_status(&bi.bi_bio.bio_status); @@ -751,7 +751,7 @@ bio_setblink(char *name, char *arg, int blink) memset(&bv, 0, sizeof(bv)); bv.bv_bio.bio_cookie = bio_cookie; bv.bv_volid = v; - if (ioctl(devh, BIOCVOL, &bv)) + if (ioctl(devh, BIOCVOL, &bv) == -1) err(1, "BIOCVOL"); bio_status(&bv.bv_bio.bio_status); @@ -765,7 +765,7 @@ bio_setblink(char *name, char *arg, int blink) bd.bd_volid = v; bd.bd_diskid = d; - if (ioctl(devh, BIOCDISK, &bd)) + if (ioctl(devh, BIOCDISK, &bd) == -1) err(1, "BIOCDISK"); bio_status(&bd.bd_bio.bio_status); @@ -800,7 +800,7 @@ bio_blink(char *enclosure, int target, int blinktype) memset(&bl, 0, sizeof(bl)); bl.bl_name = enclosure; - if (ioctl(bioh, BIOCLOCATE, &bl)) + if (ioctl(bioh, BIOCLOCATE, &bl) == -1) errx(1, "Can't locate %s device via %s", enclosure, "/dev/bio"); memset(&blink, 0, sizeof(blink)); @@ -808,7 +808,7 @@ bio_blink(char *enclosure, int target, int blinktype) blink.bb_status = blinktype; blink.bb_target = target; - if (ioctl(bioh, BIOCBLINK, &blink)) + if (ioctl(bioh, BIOCBLINK, &blink) == -1) err(1, "BIOCBLINK"); bio_status(&blink.bb_bio.bio_status); @@ -883,7 +883,7 @@ bio_createraid(u_int16_t level, char *dev_list, char *key_disk) create.bc_opaque_flags = BIOC_SOOUT; /* try to get KDF hint */ - if (ioctl(devh, BIOCCREATERAID, &create)) + if (ioctl(devh, BIOCCREATERAID, &create) == -1) err(1, "ioctl"); bio_status(&create.bc_bio.bio_status); @@ -1074,7 +1074,7 @@ bio_deleteraid(char *dev) bd.bd_bio.bio_cookie = bio_cookie; /* XXX make this a dev_t instead of a string */ strlcpy(bd.bd_dev, dev, sizeof bd.bd_dev); - if (ioctl(devh, BIOCDELETERAID, &bd)) + if (ioctl(devh, BIOCDELETERAID, &bd) == -1) err(1, "BIOCDELETERAID"); bio_status(&bd.bd_bio.bio_status); @@ -1100,7 +1100,7 @@ bio_changepass(char *dev) bd.bd_size = sizeof(kdfhint); bd.bd_data = &kdfhint; - if (ioctl(devh, BIOCDISCIPLINE, &bd)) + if (ioctl(devh, BIOCDISCIPLINE, &bd) == -1) err(1, "BIOCDISCIPLINE"); bio_status(&bd.bd_bio.bio_status); @@ -1133,7 +1133,7 @@ bio_changepass(char *dev) explicit_bzero(&kdfinfo1, sizeof(kdfinfo1)); explicit_bzero(&kdfinfo2, sizeof(kdfinfo2)); - if (rv) + if (rv == -1) err(1, "BIOCDISCIPLINE"); bio_status(&bd.bd_bio.bio_status); @@ -1217,7 +1217,7 @@ bio_patrol(char *arg) break; } - if (ioctl(devh, BIOCPATROL, &bp)) + if (ioctl(devh, BIOCPATROL, &bp) == -1) err(1, "BIOCPATROL"); bio_status(&bp.bp_bio.bio_status); diff --git a/sbin/clri/clri.c b/sbin/clri/clri.c index 972796a19a6..60f58cfaf6b 100644 --- a/sbin/clri/clri.c +++ b/sbin/clri/clri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clri.c,v 1.19 2016/03/07 21:47:04 natano Exp $ */ +/* $OpenBSD: clri.c,v 1.20 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: clri.c,v 1.19 2005/01/20 15:50:47 xtraeme Exp $ */ /* @@ -77,7 +77,7 @@ main(int argc, char *argv[]) sbp = NULL; /* get the superblock. */ - if ((fd = opendev(fs, O_RDWR, 0, NULL)) < 0) + if ((fd = opendev(fs, O_RDWR, 0, NULL)) == -1) err(1, "%s", fs); if (pledge("stdio", NULL) == -1) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index c7df8d40cea..2d05eb7bfa3 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.635 2019/05/22 12:56:31 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.636 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -1856,7 +1856,7 @@ write_option_db(char *name, struct client_lease *offered, else if (fprintf(optionDB, "%s", leasestr) == -1) log_warn("optionDB 'effective' fprintf()"); - if (fflush(optionDB) == -1) + if (fflush(optionDB) == EOF) log_warn("optionDB fflush()"); else if (fsync(fileno(optionDB)) == -1) log_warn("optionDB fsync()"); diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 3307f54478c..45d7e6c944a 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.234 2019/04/02 01:47:49 krw Exp $ */ +/* $OpenBSD: disklabel.c,v 1.235 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 1987, 1993 @@ -203,7 +203,7 @@ main(int argc, char *argv[]) dkname = argv[0]; f = opendev(dkname, (op == READ ? O_RDONLY : O_RDWR), OPENDEV_PART, &specname); - if (f < 0) + if (f == -1) err(4, "%s", specname); if (op != WRITE || aflag || dflag) { diff --git a/sbin/dump/dumprmt.c b/sbin/dump/dumprmt.c index 108bd9ae4d0..9cf7b6e09a0 100644 --- a/sbin/dump/dumprmt.c +++ b/sbin/dump/dumprmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumprmt.c,v 1.29 2015/01/16 06:39:57 deraadt Exp $ */ +/* $OpenBSD: dumprmt.c,v 1.30 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: dumprmt.c,v 1.17 1997/06/05 16:10:47 mrg Exp $ */ /*- @@ -148,7 +148,7 @@ rmtgetconn(void) /* Leave some space for rmt request/response protocol */ size += 2 * 1024; while (size > TP_BSIZE && - setsockopt(rmtape, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) < 0) + setsockopt(rmtape, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) == -1) size -= TP_BSIZE; (void)setsockopt(rmtape, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c index ac60ea907d0..4ab4bfe3406 100644 --- a/sbin/dump/itime.c +++ b/sbin/dump/itime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: itime.c,v 1.23 2015/12/22 21:03:58 mmcc Exp $ */ +/* $OpenBSD: itime.c,v 1.24 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: itime.c,v 1.4 1997/04/15 01:09:50 lukem Exp $ */ /*- @@ -172,7 +172,7 @@ putdumptime(void) dthead = NULL; ddates_in = 0; readdumptimes(df); - if (fseek(df, 0L, SEEK_SET) < 0) + if (fseek(df, 0L, SEEK_SET) == -1) quit("fseek: %s\n", strerror(errno)); spcl.c_ddate = 0; ITITERATE(i, dtwalk) { diff --git a/sbin/dump/main.c b/sbin/dump/main.c index d5c85898819..93d74728782 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.60 2018/04/26 17:40:48 guenther Exp $ */ +/* $OpenBSD: main.c,v 1.61 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */ /*- @@ -382,11 +382,11 @@ main(int argc, char *argv[]) spcl.c_level = level - '0'; spcl.c_type = TS_TAPE; - if ((diskfd = open(disk, O_RDONLY)) < 0) { + if ((diskfd = open(disk, O_RDONLY)) == -1) { msg("Cannot open %s\n", disk); exit(X_STARTUP); } - if (ioctl(diskfd, DIOCGDINFO, (char *)&lab) < 0) + if (ioctl(diskfd, DIOCGDINFO, (char *)&lab) == -1) err(1, "ioctl (DIOCGDINFO)"); if (memcmp(lab.d_uid, &zero_uid, sizeof(lab.d_uid)) != 0) { @@ -416,7 +416,7 @@ main(int argc, char *argv[]) else msgtail("to %s\n", tape); - if (ioctl(diskfd, DIOCGPDINFO, (char *)&lab) < 0) + if (ioctl(diskfd, DIOCGPDINFO, (char *)&lab) == -1) err(1, "ioctl (DIOCGPDINFO)"); sync(); sblock = (struct fs *)sblock_buf; @@ -658,7 +658,7 @@ getduid(char *path) char *duid; if ((fd = opendev(path, O_RDONLY | O_NOFOLLOW, 0, NULL)) >= 0) { - if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { + if (ioctl(fd, DIOCGDINFO, (char *)&lab) == -1) { close(fd); warn("ioctl(DIOCGDINFO)"); return (NULL); diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c index 445a75df555..c0cc1b6021d 100644 --- a/sbin/dump/tape.c +++ b/sbin/dump/tape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tape.c,v 1.44 2017/12/08 17:04:15 deraadt Exp $ */ +/* $OpenBSD: tape.c,v 1.45 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $ */ /*- @@ -416,7 +416,7 @@ trewind(void) } (void) close(tapefd); - while ((f = open(tape, O_RDONLY)) < 0) + while ((f = open(tape, O_RDONLY)) == -1) sleep (10); (void) close(f); } @@ -577,7 +577,7 @@ restore_check_point: * All signals are inherited... */ childpid = fork(); - if (childpid < 0) { + if (childpid == -1) { msg("Context save fork fails in parent %d\n", parentpid); Exit(X_ABORT); } @@ -656,10 +656,10 @@ restore_check_point: } #ifdef RDUMP while ((tapefd = (host ? rmtopen(tape, O_WRONLY|O_CREAT) : - pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666))) < 0) + pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666))) == -1) #else while ((tapefd = (pipeout ? 1 : - open(tape, O_WRONLY|O_CREAT, 0666))) < 0) + open(tape, O_WRONLY|O_CREAT, 0666))) == -1) #endif { msg("Cannot open output \"%s\".\n", tape); @@ -751,8 +751,8 @@ enslave(void) caught = 0; } - if (socketpair(AF_UNIX, SOCK_STREAM, 0, cmd) < 0 || - (slaves[i].pid = fork()) < 0) + if (socketpair(AF_UNIX, SOCK_STREAM, 0, cmd) == -1 || + (slaves[i].pid = fork()) == -1) quit("too many slaves, %d (recompile smaller): %s\n", i, strerror(errno)); @@ -804,7 +804,7 @@ doslave(int cmd, int slave_number) * Need our own seek pointer. */ (void) close(diskfd); - if ((diskfd = open(disk, O_RDONLY)) < 0) + if ((diskfd = open(disk, O_RDONLY)) == -1) quit("slave couldn't reopen disk: %s\n", strerror(errno)); /* diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c index 8f16d2c99fd..908092560e0 100644 --- a/sbin/dumpfs/dumpfs.c +++ b/sbin/dumpfs/dumpfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumpfs.c,v 1.33 2015/11/23 19:19:29 deraadt Exp $ */ +/* $OpenBSD: dumpfs.c,v 1.34 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 2002 Networks Associates Technology, Inc. @@ -128,7 +128,7 @@ open_disk(const char *name) ssize_t n; /* XXX - should retry w/raw device on failure */ - if ((fd = opendev(name, O_RDONLY, 0, NULL)) < 0) { + if ((fd = opendev(name, O_RDONLY, 0, NULL)) == -1) { warn("%s", name); return(-1); } diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c index 7b6132032f4..09475f346d3 100644 --- a/sbin/fsck/fsck.c +++ b/sbin/fsck/fsck.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.c,v 1.39 2018/09/24 21:26:00 deraadt Exp $ */ +/* $OpenBSD: fsck.c,v 1.40 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: fsck.c,v 1.7 1996/10/03 20:06:30 christos Exp $ */ /* @@ -102,7 +102,7 @@ main(int argc, char *argv[]) rl.rlim_cur = rl.rlim_max = RLIM_INFINITY; else rl.rlim_cur = rl.rlim_max; - if (setrlimit(RLIMIT_DATA, &rl) < 0) + if (setrlimit(RLIMIT_DATA, &rl) == -1) warn("Can't set resource limit to max data size"); } else warn("Can't get resource limit for data size"); @@ -339,7 +339,7 @@ checkfs(const char *vfstype, const char *spec, const char *mntpt, void *auxarg, return 0; } - if (waitpid(pid, &status, 0) < 0) { + if (waitpid(pid, &status, 0) == -1) { warn("waitpid"); return (1); } diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c index f0b88684058..6d4e96f93d1 100644 --- a/sbin/fsck/fsutil.c +++ b/sbin/fsck/fsutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsutil.c,v 1.23 2018/09/24 21:26:00 deraadt Exp $ */ +/* $OpenBSD: fsutil.c,v 1.24 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: fsutil.c,v 1.2 1996/10/03 20:06:31 christos Exp $ */ /* @@ -58,7 +58,7 @@ struct stat stslash; void checkroot(void) { - if (stat("/", &stslash) < 0) { + if (stat("/", &stslash) == -1) { xperror("/"); printf("Can't stat root\n"); } @@ -164,7 +164,7 @@ unrawname(char *name) if ((dp = strrchr(name, '/')) == NULL) return (name); - if (stat(name, &stb) < 0) + if (stat(name, &stb) == -1) return (name); if (!S_ISCHR(stb.st_mode)) return (name); @@ -201,14 +201,14 @@ blockcheck(char *origname) hot = 0; newname = origname; retry: - if (stat(newname, &stblock) < 0) + if (stat(newname, &stblock) == -1) return (origname); if (S_ISBLK(stblock.st_mode)) { if (stslash.st_dev == stblock.st_rdev) hot++; raw = rawname(newname); - if (stat(raw, &stchar) < 0) { + if (stat(raw, &stchar) == -1) { xperror(raw); printf("Can't stat %s\n", raw); return (origname); diff --git a/sbin/fsck_ext2fs/setup.c b/sbin/fsck_ext2fs/setup.c index 785e488dd4c..716aa76edc9 100644 --- a/sbin/fsck_ext2fs/setup.c +++ b/sbin/fsck_ext2fs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.31 2017/08/26 06:32:06 otto Exp $ */ +/* $OpenBSD: setup.c,v 1.32 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: setup.c,v 1.1 1997/06/11 11:22:01 bouyer Exp $ */ /* @@ -76,7 +76,7 @@ setup(char *dev) havesb = 0; fswritefd = -1; doskipclean = skipclean; - if (stat(dev, &statb) < 0) { + if (stat(dev, &statb) == -1) { printf("Can't stat %s: %s\n", dev, strerror(errno)); return (0); } @@ -85,13 +85,13 @@ setup(char *dev) if (reply("CONTINUE") == 0) return (0); } - if ((fsreadfd = open(dev, O_RDONLY)) < 0) { + if ((fsreadfd = open(dev, O_RDONLY)) == -1) { printf("Can't open %s: %s\n", dev, strerror(errno)); return (0); } if (preen == 0) printf("** %s", dev); - if (nflag || (fswritefd = open(dev, O_WRONLY)) < 0) { + if (nflag || (fswritefd = open(dev, O_WRONLY)) == -1) { fswritefd = -1; if (preen) pfatal("NO WRITE ACCESS"); @@ -487,7 +487,7 @@ getdisklabel(char *s, int fd) { static struct disklabel lab; - if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { + if (ioctl(fd, DIOCGDINFO, (char *)&lab) == -1) { if (s == NULL) return (NULL); pwarn("ioctl (GCINFO): %s\n", strerror(errno)); diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 0d2a9dcf574..d8a97c63ecf 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.65 2018/09/24 21:26:02 deraadt Exp $ */ +/* $OpenBSD: setup.c,v 1.66 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */ /* @@ -93,7 +93,7 @@ setup(char *dev, int isfsdb) havesb = 0; fswritefd = fsreadfd = -1; doskipclean = skipclean; - if ((fsreadfd = opendev(dev, O_RDONLY, 0, &realdev)) < 0) { + if ((fsreadfd = opendev(dev, O_RDONLY, 0, &realdev)) == -1) { printf("Can't open %s: %s\n", dev, strerror(errno)); return (0); } @@ -111,7 +111,7 @@ setup(char *dev, int isfsdb) } } - if (fstat(fsreadfd, &statb) < 0) { + if (fstat(fsreadfd, &statb) == -1) { printf("Can't stat %s: %s\n", realdev, strerror(errno)); close(fsreadfd); return (0); @@ -128,7 +128,7 @@ setup(char *dev, int isfsdb) if (strncmp(dev, realdev, PATH_MAX) != 0) printf(" (%s)", dev); } - if (nflag || (fswritefd = opendev(dev, O_WRONLY, 0, NULL)) < 0) { + if (nflag || (fswritefd = opendev(dev, O_WRONLY, 0, NULL)) == -1) { fswritefd = -1; if (preen) pfatal("NO WRITE ACCESS"); @@ -662,7 +662,7 @@ getdisklabel(char *s, int fd) { static struct disklabel lab; - if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { + if (ioctl(fd, DIOCGDINFO, (char *)&lab) == -1) { if (s == NULL) return (NULL); pwarn("ioctl (GCINFO): %s\n", strerror(errno)); diff --git a/sbin/fsck_msdos/check.c b/sbin/fsck_msdos/check.c index a5d972d49f0..4a2f07f1131 100644 --- a/sbin/fsck_msdos/check.c +++ b/sbin/fsck_msdos/check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check.c,v 1.19 2018/09/24 21:26:02 deraadt Exp $ */ +/* $OpenBSD: check.c,v 1.20 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: check.c,v 1.8 1997/10/17 11:19:29 ws Exp $ */ /* @@ -60,11 +60,11 @@ checkfilesys(const char *fname) rdonly = alwaysno; dosfs = opendev(fname, rdonly ? O_RDONLY : O_RDWR, 0, &realdev); - if (dosfs < 0 && !rdonly) { + if (dosfs == -1 && !rdonly) { dosfs = opendev(fname, O_RDONLY, 0, &realdev); rdonly = 1; } - if (dosfs < 0) { + if (dosfs == -1) { xperror("Can't open"); return (8); } @@ -78,7 +78,7 @@ checkfilesys(const char *fname) printf("\n"); } - if (ioctl(dosfs, DIOCGDINFO, (char *)&lab) < 0) + if (ioctl(dosfs, DIOCGDINFO, (char *)&lab) == -1) pfatal("can't read disk label for %s\n", fname); if (pledge("stdio", NULL) == -1) diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c index 10df61497c0..8f2d15a9e7d 100644 --- a/sbin/fsirand/fsirand.c +++ b/sbin/fsirand/fsirand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsirand.c,v 1.40 2019/01/25 00:19:26 millert Exp $ */ +/* $OpenBSD: fsirand.c,v 1.41 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <millert@openbsd.org> @@ -74,7 +74,7 @@ main(int argc, char *argv[]) /* Increase our data size to the max */ 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 resource limit to max data size"); } else warn("Can't get resource limit for data size"); @@ -107,14 +107,14 @@ fsirand(char *device) struct disklabel label; if ((devfd = opendev(device, printonly ? O_RDONLY : O_RDWR, - 0, &devpath)) < 0) { + 0, &devpath)) == -1) { warn("Can't open %s", devpath); return (1); } /* Get block size (usually 512) from disklabel if possible */ if (!ignorelabel) { - if (ioctl(devfd, DIOCGDINFO, &label) < 0) + if (ioctl(devfd, DIOCGDINFO, &label) == -1) warn("Can't read disklabel, using sector size of %d", bsize); else @@ -180,7 +180,7 @@ fsirand(char *device) tmpsblock = (struct fs *)&sbuftmp; for (cg = 0; cg < sblock->fs_ncg; cg++) { dblk = fsbtodb(sblock, cgsblock(sblock, cg)); - if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) { + if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) == -1) { warn("Can't seek to %lld", (long long)dblk * bsize); return (1); } else if ((n = read(devfd, tmpsblock, SBSIZE)) != SBSIZE) { @@ -247,7 +247,7 @@ fsirand(char *device) if ((sblock->fs_inodefmt >= FS_44INODEFMT) && !printonly) { dblk = fsbtodb(sblock, cgsblock(sblock, cg)); if (lseek(devfd, (off_t)dblk * bsize, - SEEK_SET) < 0) { + SEEK_SET) == -1) { warn("Can't seek to %lld", (long long)dblk * bsize); return (1); @@ -262,7 +262,7 @@ fsirand(char *device) /* Read in inodes, then print or randomize generation nums */ dblk = fsbtodb(sblock, ino_to_fsba(sblock, inumber)); - if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) { + if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) == -1) { warn("Can't seek to %lld", (long long)dblk * bsize); return (1); } else if ((n = read(devfd, inodebuf, ibufsize)) != ibufsize) { @@ -291,7 +291,7 @@ fsirand(char *device) /* Write out modified inodes */ if (!printonly) { - if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) { + if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) == -1) { warn("Can't seek to %lld", (long long)dblk * bsize); return (1); diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c index cbbd4c29e7c..9a91ebabd73 100644 --- a/sbin/growfs/growfs.c +++ b/sbin/growfs/growfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: growfs.c,v 1.51 2016/05/28 20:40:23 tb Exp $ */ +/* $OpenBSD: growfs.c,v 1.52 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. @@ -1386,7 +1386,7 @@ rdfs(daddr_t bno, size_t size, void *bf, int fsi) if (bno < 0) { err(32, "rdfs: attempting to read negative block number"); } - if (lseek(fsi, (off_t)bno * DEV_BSIZE, SEEK_SET) < 0) { + if (lseek(fsi, (off_t)bno * DEV_BSIZE, SEEK_SET) == -1) { err(33, "rdfs: seek error: %jd", (intmax_t)bno); } n = read(fsi, bf, size); @@ -1406,7 +1406,7 @@ wtfs(daddr_t bno, size_t size, void *bf, int fso, unsigned int Nflag) if (Nflag) return; - if (lseek(fso, (off_t)bno * DEV_BSIZE, SEEK_SET) < 0) + if (lseek(fso, (off_t)bno * DEV_BSIZE, SEEK_SET) == -1) err(35, "wtfs: seek error: %ld", (long)bno); n = write(fso, bf, size); if (n != (ssize_t)size) @@ -1753,7 +1753,7 @@ main(int argc, char **argv) * Rather than guessing, use opendev() to get the device * name, which we open for reading. */ - if ((fsi = opendev(*argv, O_RDONLY, 0, &device)) < 0) + if ((fsi = opendev(*argv, O_RDONLY, 0, &device)) == -1) err(1, "%s", *argv); /* @@ -1763,7 +1763,7 @@ main(int argc, char **argv) fso = -1; } else { fso = open(device, O_WRONLY); - if (fso < 0) + if (fso == -1) err(1, "%s", device); } @@ -1771,7 +1771,7 @@ main(int argc, char **argv) * Now we have a file descriptor for our device, fstat() it to * figure out the partition number. */ - if (fstat(fsi, &st) != 0) + if (fstat(fsi, &st) == -1) err(1, "%s: fstat()", device); /* @@ -1979,7 +1979,7 @@ return_disklabel(int fd, struct disklabel *lp, unsigned int Nflag) sum ^= *ptr++; lp->d_checksum = sum; - if (ioctl(fd, DIOCWDINFO, (char *)lp) < 0) + if (ioctl(fd, DIOCWDINFO, (char *)lp) == -1) errx(1, "DIOCWDINFO failed"); } free(lp); diff --git a/sbin/ifconfig/brconfig.c b/sbin/ifconfig/brconfig.c index 53bbcd3e241..9cf97841f65 100644 --- a/sbin/ifconfig/brconfig.c +++ b/sbin/ifconfig/brconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: brconfig.c,v 1.21 2019/05/10 01:29:31 guenther Exp $ */ +/* $OpenBSD: brconfig.c,v 1.22 2019/06/28 13:32:44 deraadt Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -202,7 +202,7 @@ addlocal(const char *ifsname, int d) /* Add local */ strlcpy(breq.ifbr_name, name, sizeof(breq.ifbr_name)); strlcpy(breq.ifbr_ifsname, ifsname, sizeof(breq.ifbr_ifsname)); - if (ioctl(s, SIOCBRDGADDL, (caddr_t)&breq) < 0) { + if (ioctl(s, SIOCBRDGADDL, (caddr_t)&breq) == -1) { if (errno == EEXIST) return; else @@ -217,12 +217,12 @@ bridge_ifsetflag(const char *ifsname, u_int32_t flag) strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name)); strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname)); - if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)&req) < 0) + if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)&req) == -1) err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname); req.ifbr_ifsflags |= flag & ~IFBIF_RO_MASK; - if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)&req) < 0) + if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)&req) == -1) err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname); } @@ -234,12 +234,12 @@ bridge_ifclrflag(const char *ifsname, u_int32_t flag) strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name)); strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname)); - if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)&req) < 0) + if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)&req) == -1) err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname); req.ifbr_ifsflags &= ~(flag | IFBIF_RO_MASK); - if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)&req) < 0) + if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)&req) == -1) err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname); } @@ -250,7 +250,7 @@ bridge_flushall(const char *val, int p) strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name)); req.ifbr_ifsflags = IFBF_FLUSHALL; - if (ioctl(s, SIOCBRDGFLUSH, &req) < 0) + if (ioctl(s, SIOCBRDGFLUSH, &req) == -1) err(1, "%s", name); } @@ -261,7 +261,7 @@ bridge_flush(const char *val, int p) strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name)); req.ifbr_ifsflags = IFBF_FLUSHDYN; - if (ioctl(s, SIOCBRDGFLUSH, &req) < 0) + if (ioctl(s, SIOCBRDGFLUSH, &req) == -1) err(1, "%s", name); } @@ -323,7 +323,7 @@ bridge_list(char *delim) err(1, "malloc"); bifc.ifbic_buf = inbuf = inb; strlcpy(bifc.ifbic_name, name, sizeof(bifc.ifbic_name)); - if (ioctl(s, SIOCBRDGIFS, &bifc) < 0) { + if (ioctl(s, SIOCBRDGIFS, &bifc) == -1) { if (errno == ENOTTY) return; err(1, "%s SIOCBRDGIFS", name); @@ -371,7 +371,7 @@ bridge_add(const char *ifn, int d) strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name)); strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname)); - if (ioctl(s, SIOCBRDGADD, &req) < 0) { + if (ioctl(s, SIOCBRDGADD, &req) == -1) { if (errno == EEXIST) return; err(1, "%s: %s", name, ifn); @@ -385,7 +385,7 @@ bridge_delete(const char *ifn, int d) strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name)); strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname)); - if (ioctl(s, SIOCBRDGDEL, &req) < 0) + if (ioctl(s, SIOCBRDGDEL, &req) == -1) err(1, "%s: %s", name, ifn); } @@ -396,7 +396,7 @@ bridge_addspan(const char *ifn, int d) strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name)); strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname)); - if (ioctl(s, SIOCBRDGADDS, &req) < 0) { + if (ioctl(s, SIOCBRDGADDS, &req) == -1) { if (errno == EEXIST) return; err(1, "%s: %s", name, ifn); @@ -410,7 +410,7 @@ bridge_delspan(const char *ifn, int d) strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name)); strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname)); - if (ioctl(s, SIOCBRDGDELS, &req) < 0) + if (ioctl(s, SIOCBRDGDELS, &req) == -1) err(1, "%s: %s", name, ifn); } @@ -430,7 +430,7 @@ bridge_timeout(const char *arg, int d) strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); bp.ifbrp_ctime = newtime; - if (ioctl(s, SIOCBRDGSTO, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCBRDGSTO, (caddr_t)&bp) == -1) err(1, "%s", name); } @@ -449,7 +449,7 @@ bridge_maxage(const char *arg, int d) strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); bp.ifbrp_maxage = v; - if (ioctl(s, SIOCBRDGSMA, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCBRDGSMA, (caddr_t)&bp) == -1) err(1, "%s", name); } @@ -468,7 +468,7 @@ bridge_priority(const char *arg, int d) strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); bp.ifbrp_prio = v; - if (ioctl(s, SIOCBRDGSPRI, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCBRDGSPRI, (caddr_t)&bp) == -1) err(1, "%s", name); } @@ -500,7 +500,7 @@ bridge_protect(const char *ifname, const char *val) str = strtok(NULL, ","); } - if (ioctl(s, SIOCBRDGSIFPROT, (caddr_t)&breq) < 0) + if (ioctl(s, SIOCBRDGSIFPROT, (caddr_t)&breq) == -1) err(1, "%s: %s", name, val); free(optlist); @@ -516,7 +516,7 @@ bridge_unprotect(const char *ifname, int d) breq.ifbr_protected = 0; - if (ioctl(s, SIOCBRDGSIFPROT, (caddr_t)&breq) < 0) + if (ioctl(s, SIOCBRDGSIFPROT, (caddr_t)&breq) == -1) err(1, "%s: %d", name, 0); } @@ -536,7 +536,7 @@ bridge_proto(const char *arg, int d) strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); bp.ifbrp_prio = proto; - if (ioctl(s, SIOCBRDGSPROTO, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCBRDGSPROTO, (caddr_t)&bp) == -1) err(1, "%s", name); } @@ -555,7 +555,7 @@ bridge_fwddelay(const char *arg, int d) strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); bp.ifbrp_fwddelay = v; - if (ioctl(s, SIOCBRDGSFD, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCBRDGSFD, (caddr_t)&bp) == -1) err(1, "%s", name); } @@ -574,7 +574,7 @@ bridge_hellotime(const char *arg, int d) strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); bp.ifbrp_hellotime = v; - if (ioctl(s, SIOCBRDGSHT, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCBRDGSHT, (caddr_t)&bp) == -1) err(1, "%s", name); } @@ -593,7 +593,7 @@ bridge_maxaddr(const char *arg, int d) strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); bp.ifbrp_csize = newsize; - if (ioctl(s, SIOCBRDGSCACHE, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCBRDGSCACHE, (caddr_t)&bp) == -1) err(1, "%s", name); } @@ -610,7 +610,7 @@ bridge_deladdr(const char *addr, int d) bcopy(ea, &ifba.ifba_dst, sizeof(struct ether_addr)); - if (ioctl(s, SIOCBRDGDADDR, &ifba) < 0) + if (ioctl(s, SIOCBRDGDADDR, &ifba) == -1) err(1, "%s: %s", name, addr); } @@ -631,7 +631,7 @@ bridge_ifprio(const char *ifname, const char *val) err(1, "invalid arg for ifpriority: %s", val); breq.ifbr_priority = v; - if (ioctl(s, SIOCBRDGSIFPRIO, (caddr_t)&breq) < 0) + if (ioctl(s, SIOCBRDGSIFPRIO, (caddr_t)&breq) == -1) err(1, "%s: %s", name, val); } @@ -653,7 +653,7 @@ bridge_ifcost(const char *ifname, const char *val) breq.ifbr_path_cost = v; - if (ioctl(s, SIOCBRDGSIFCOST, (caddr_t)&breq) < 0) + if (ioctl(s, SIOCBRDGSIFCOST, (caddr_t)&breq) == -1) err(1, "%s: %s", name, val); } @@ -667,7 +667,7 @@ bridge_noifcost(const char *ifname, int d) breq.ifbr_path_cost = 0; - if (ioctl(s, SIOCBRDGSIFCOST, (caddr_t)&breq) < 0) + if (ioctl(s, SIOCBRDGSIFCOST, (caddr_t)&breq) == -1) err(1, "%s", name); } @@ -687,7 +687,7 @@ bridge_addaddr(const char *ifname, const char *addr) bcopy(ea, &ifba.ifba_dst, sizeof(struct ether_addr)); ifba.ifba_flags = IFBAF_STATIC; - if (ioctl(s, SIOCBRDGSADDR, &ifba) < 0) + if (ioctl(s, SIOCBRDGSADDR, &ifba) == -1) err(1, "%s: %s", name, addr); } @@ -714,7 +714,7 @@ bridge_addrs(const char *delim, int d) err(1, "malloc"); ifbac.ifbac_buf = inbuf = inb; strlcpy(ifbac.ifbac_name, name, sizeof(ifbac.ifbac_name)); - if (ioctl(s, SIOCBRDGRTS, &ifbac) < 0) { + if (ioctl(s, SIOCBRDGRTS, &ifbac) == -1) { if (errno == ENETDOWN) return; err(1, "%s", name); @@ -752,7 +752,7 @@ bridge_holdcnt(const char *value, int d) err(1, "holdcnt %s %s", value, errstr); strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); - if (ioctl(s, SIOCBRDGSTXHC, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCBRDGSTXHC, (caddr_t)&bp) == -1) err(1, "%s", name); } @@ -767,12 +767,12 @@ is_bridge(char *brdg) strlcpy(ifr.ifr_name, brdg, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) return (0); ifbac.ifbac_len = 0; strlcpy(ifbac.ifbac_name, brdg, sizeof(ifbac.ifbac_name)); - if (ioctl(s, SIOCBRDGRTS, (caddr_t)&ifbac) < 0) { + if (ioctl(s, SIOCBRDGRTS, (caddr_t)&ifbac) == -1) { if (errno == ENETDOWN) return (1); return (0); @@ -790,7 +790,7 @@ bridge_status(void) return; strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) return; bridge_cfg("\t"); @@ -801,11 +801,11 @@ bridge_status(void) return; strlcpy(bp1.ifbrp_name, name, sizeof(bp1.ifbrp_name)); - if (ioctl(s, SIOCBRDGGCACHE, (caddr_t)&bp1) < 0) + if (ioctl(s, SIOCBRDGGCACHE, (caddr_t)&bp1) == -1) return; strlcpy(bp2.ifbrp_name, name, sizeof(bp2.ifbrp_name)); - if (ioctl(s, SIOCBRDGGTO, (caddr_t)&bp2) < 0) + if (ioctl(s, SIOCBRDGGTO, (caddr_t)&bp2) == -1) return; printf("\tAddresses (max cache: %u, timeout: %u):\n", @@ -821,7 +821,7 @@ bridge_flushrule(const char *ifname, int d) strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name)); strlcpy(req.ifbr_ifsname, ifname, sizeof(req.ifbr_ifsname)); - if (ioctl(s, SIOCBRDGFRL, &req) < 0) + if (ioctl(s, SIOCBRDGFRL, &req) == -1) err(1, "%s: %s", name, ifname); } @@ -841,7 +841,7 @@ bridge_rules(const char *ifname, int usetab) ifc.ifbrl_buf = inbuf = inb; strlcpy(ifc.ifbrl_name, name, sizeof(ifc.ifbrl_name)); strlcpy(ifc.ifbrl_ifsname, ifname, sizeof(ifc.ifbrl_ifsname)); - if (ioctl(s, SIOCBRDGGRL, &ifc) < 0) + if (ioctl(s, SIOCBRDGGRL, &ifc) == -1) err(1, "ioctl(SIOCBRDGGRL)"); if (ifc.ifbrl_len + sizeof(*ifrp) < len) break; @@ -1020,7 +1020,7 @@ bridge_rule(int targc, char **targv, int ln) } } - if (ioctl(s, SIOCBRDGARL, &rule) < 0) { + if (ioctl(s, SIOCBRDGARL, &rule) == -1) { warn("%s", name); return (1); } @@ -1151,7 +1151,7 @@ is_switch(char *swname) struct ifbrparam bp; strlcpy(bp.ifbrp_name, swname, sizeof(bp.ifbrp_name)); - if (ioctl(s, SIOCSWGDPID, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCSWGDPID, (caddr_t)&bp) == -1) return (0); return (1); @@ -1163,19 +1163,19 @@ switch_cfg(char *delim) struct ifbrparam bp; strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); - if (ioctl(s, SIOCSWGDPID, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCSWGDPID, (caddr_t)&bp) == -1) err(1, "%s", name); printf("%sdatapath %#016llx", delim, bp.ifbrp_datapath); strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); - if (ioctl(s, SIOCSWGMAXFLOW, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCSWGMAXFLOW, (caddr_t)&bp) == -1) err(1, "%s", name); printf(" maxflow %d", bp.ifbrp_maxflow); strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); - if (ioctl(s, SIOCSWGMAXGROUP, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCSWGMAXGROUP, (caddr_t)&bp) == -1) err(1, "%s", name); printf(" maxgroup %d\n", bp.ifbrp_maxgroup); @@ -1190,7 +1190,7 @@ switch_status(void) return; strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) return; switch_cfg("\t"); @@ -1215,7 +1215,7 @@ switch_datapathid(const char *arg, int d) strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name)); bp.ifbrp_datapath = newdpid; - if (ioctl(s, SIOCSWSDPID, (caddr_t)&bp) < 0) + if (ioctl(s, SIOCSWSDPID, (caddr_t)&bp) == -1) err(1, "%s", name); } @@ -1235,7 +1235,7 @@ switch_portno(const char *ifname, const char *val) errx(1, "invalid arg for portidx: %s", val); breq.ifbr_portno = newportidx; - if (ioctl(s, SIOCSWSPORTNO, (caddr_t)&breq) < 0) { + if (ioctl(s, SIOCSWSPORTNO, (caddr_t)&breq) == -1) { if (errno == EEXIST) return; else diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 6189461ea49..80e123341cc 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.402 2019/05/10 01:29:31 guenther Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.403 2019/06/28 13:32:44 deraadt Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -923,7 +923,7 @@ nextarg: if (clearaddr) { (void) strlcpy(rafp->af_ridreq, name, sizeof(ifr.ifr_name)); - if (ioctl(s, rafp->af_difaddr, rafp->af_ridreq) < 0) { + if (ioctl(s, rafp->af_difaddr, rafp->af_ridreq) == -1) { if (errno == EADDRNOTAVAIL && (doalias >= 0)) { /* means no previous address for interface */ } else @@ -932,7 +932,7 @@ nextarg: } if (newaddr) { (void) strlcpy(rafp->af_addreq, name, sizeof(ifr.ifr_name)); - if (ioctl(s, rafp->af_aifaddr, rafp->af_addreq) < 0) + if (ioctl(s, rafp->af_aifaddr, rafp->af_addreq) == -1) err(1, "SIOCAIFADDR"); } return (0); @@ -948,7 +948,7 @@ getsock(int naf) if (oaf != -1) close(s); s = socket(naf, SOCK_DGRAM, 0); - if (s < 0) + if (s == -1) oaf = -1; else oaf = naf; @@ -959,45 +959,45 @@ getinfo(struct ifreq *ifr, int create) { getsock(af); - if (s < 0) + if (s == -1) err(1, "socket"); if (!isdigit((unsigned char)name[strlen(name) - 1])) return (-1); /* ignore groups here */ - if (ioctl(s, SIOCGIFFLAGS, (caddr_t)ifr) < 0) { + if (ioctl(s, SIOCGIFFLAGS, (caddr_t)ifr) == -1) { int oerrno = errno; if (!create) return (-1); - if (ioctl(s, SIOCIFCREATE, (caddr_t)ifr) < 0) { + if (ioctl(s, SIOCIFCREATE, (caddr_t)ifr) == -1) { errno = oerrno; return (-1); } - if (ioctl(s, SIOCGIFFLAGS, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFFLAGS, (caddr_t)ifr) == -1) return (-1); } flags = ifr->ifr_flags & 0xffff; - if (ioctl(s, SIOCGIFXFLAGS, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFXFLAGS, (caddr_t)ifr) == -1) ifr->ifr_flags = 0; xflags = ifr->ifr_flags; - if (ioctl(s, SIOCGIFMETRIC, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFMETRIC, (caddr_t)ifr) == -1) metric = 0; else metric = ifr->ifr_metric; #ifdef SMALL - if (ioctl(s, SIOCGIFMTU, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFMTU, (caddr_t)ifr) == -1) #else - if (is_bridge(name) || ioctl(s, SIOCGIFMTU, (caddr_t)ifr) < 0) + if (is_bridge(name) || ioctl(s, SIOCGIFMTU, (caddr_t)ifr) == -1) #endif mtu = 0; else mtu = ifr->ifr_mtu; #ifndef SMALL - if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)ifr) == -1) rdomainid = 0; else rdomainid = ifr->ifr_rdomainid; #endif - if (ioctl(s, SIOCGIFLLPRIO, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFLLPRIO, (caddr_t)ifr) == -1) llprio = 0; else llprio = ifr->ifr_llprio; @@ -1283,7 +1283,7 @@ setifrtlabel(const char *label, int d) ifr.ifr_data = (caddr_t)(const char *)""; else ifr.ifr_data = (caddr_t)label; - if (ioctl(s, SIOCSIFRTLABEL, &ifr) < 0) + if (ioctl(s, SIOCSIFRTLABEL, &ifr) == -1) warn("SIOCSIFRTLABEL"); } #endif @@ -1308,7 +1308,7 @@ void setifdesc(const char *val, int ignored) { ifr.ifr_data = (caddr_t)val; - if (ioctl(s, SIOCSIFDESCR, &ifr) < 0) + if (ioctl(s, SIOCSIFDESCR, &ifr) == -1) warn("SIOCSIFDESCR"); } @@ -1317,7 +1317,7 @@ void unsetifdesc(const char *noval, int ignored) { ifr.ifr_data = (caddr_t)(const char *)""; - if (ioctl(s, SIOCSIFDESCR, &ifr) < 0) + if (ioctl(s, SIOCSIFDESCR, &ifr) == -1) warn("SIOCSIFDESCR"); } @@ -1370,7 +1370,7 @@ setifflags(const char *vname, int value) bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq)); - if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) + if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) == -1) err(1, "SIOCGIFFLAGS"); (void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name)); flags = my_ifr.ifr_flags; @@ -1381,7 +1381,7 @@ setifflags(const char *vname, int value) } else flags |= value; my_ifr.ifr_flags = flags; - if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0) + if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) == -1) err(1, "SIOCSIFFLAGS"); } @@ -1393,7 +1393,7 @@ setifxflags(const char *vname, int value) bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq)); - if (ioctl(s, SIOCGIFXFLAGS, (caddr_t)&my_ifr) < 0) + if (ioctl(s, SIOCGIFXFLAGS, (caddr_t)&my_ifr) == -1) warn("SIOCGIFXFLAGS"); (void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name)); xflags = my_ifr.ifr_flags; @@ -1404,7 +1404,7 @@ setifxflags(const char *vname, int value) } else xflags |= value; my_ifr.ifr_flags = xflags; - if (ioctl(s, SIOCSIFXFLAGS, (caddr_t)&my_ifr) < 0) + if (ioctl(s, SIOCSIFXFLAGS, (caddr_t)&my_ifr) == -1) warn("SIOCSIFXFLAGS"); } @@ -1415,7 +1415,7 @@ addaf(const char *vname, int value) strlcpy(ifar.ifar_name, name, sizeof(ifar.ifar_name)); ifar.ifar_af = value; - if (ioctl(s, SIOCIFAFATTACH, (caddr_t)&ifar) < 0) + if (ioctl(s, SIOCIFAFATTACH, (caddr_t)&ifar) == -1) warn("SIOCIFAFATTACH"); } @@ -1426,7 +1426,7 @@ removeaf(const char *vname, int value) strlcpy(ifar.ifar_name, name, sizeof(ifar.ifar_name)); ifar.ifar_af = value; - if (ioctl(s, SIOCIFAFDETACH, (caddr_t)&ifar) < 0) + if (ioctl(s, SIOCIFAFDETACH, (caddr_t)&ifar) == -1) warn("SIOCIFAFDETACH"); } @@ -1538,7 +1538,7 @@ setifmetric(const char *val, int ignored) ifr.ifr_metric = strtonum(val, 0, INT_MAX, &errmsg); if (errmsg) errx(1, "metric %s: %s", val, errmsg); - if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) == -1) warn("SIOCSIFMETRIC"); } #endif @@ -1554,7 +1554,7 @@ setifmtu(const char *val, int d) ifr.ifr_mtu = strtonum(val, 0, INT_MAX, &errmsg); if (errmsg) errx(1, "mtu %s: %s", val, errmsg); - if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) == -1) warn("SIOCSIFMTU"); } @@ -1569,7 +1569,7 @@ setifllprio(const char *val, int d) ifr.ifr_llprio = strtonum(val, 0, UCHAR_MAX, &errmsg); if (errmsg) errx(1, "llprio %s: %s", val, errmsg); - if (ioctl(s, SIOCSIFLLPRIO, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFLLPRIO, (caddr_t)&ifr) == -1) warn("SIOCSIFLLPRIO"); } @@ -1743,7 +1743,7 @@ setifnwid(const char *val, int d) (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); (void)strlcpy(nwidname, nwid.i_nwid, sizeof(nwidname)); ifr.ifr_data = (caddr_t)&nwid; - if (ioctl(s, SIOCS80211NWID, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCS80211NWID, (caddr_t)&ifr) == -1) warn("SIOCS80211NWID"); } @@ -1755,7 +1755,7 @@ process_join_commands(void) return; ifr.ifr_data = (caddr_t)&join; - if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1) err(1, "SIOCS80211JOIN"); } @@ -1802,7 +1802,7 @@ delifjoin(const char *val, int d) if (d == -1) { ifr.ifr_data = (caddr_t)&join; - if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1) err(1, "SIOCS80211JOIN"); } @@ -1814,7 +1814,7 @@ delifjoin(const char *val, int d) join.i_flags |= IEEE80211_JOIN_ANY; (void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_data = (caddr_t)&join; - if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1) err(1, "SIOCS80211JOIN"); } @@ -1830,13 +1830,13 @@ delifjoinlist(const char *val, int d) if (d == -1) { ifr.ifr_data = (caddr_t)&join; - if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1) err(1, "SIOCS80211JOIN"); return; } ifr.ifr_data = (caddr_t)&join; - if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1) err(1, "SIOCS80211JOIN"); } @@ -1980,7 +1980,7 @@ setifwpa(const char *val, int d) return; } - if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCS80211WPAPARMS"); } @@ -2014,14 +2014,14 @@ setifwpaprotos(const char *val, int d) memset(&wpa, 0, sizeof(wpa)); (void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name)); - if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCG80211WPAPARMS"); wpa.i_protos = rval; /* Let the kernel set up the appropriate default ciphers. */ wpa.i_ciphers = 0; wpa.i_groupcipher = 0; - if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCS80211WPAPARMS"); } @@ -2057,13 +2057,13 @@ setifwpaakms(const char *val, int d) memset(&wpa, 0, sizeof(wpa)); (void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name)); - if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCG80211WPAPARMS"); wpa.i_akms = rval; /* Enable WPA for 802.1x here. PSK case is handled in setifwpakey(). */ wpa.i_enabled = ((rval & IEEE80211_WPA_AKM_8021X) != 0); - if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCS80211WPAPARMS"); } @@ -2118,11 +2118,11 @@ setifwpaciphers(const char *val, int d) memset(&wpa, 0, sizeof(wpa)); (void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name)); - if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCG80211WPAPARMS"); wpa.i_ciphers = rval; - if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCS80211WPAPARMS"); } @@ -2139,7 +2139,7 @@ setifwpagroupcipher(const char *val, int d) memset(&wpa, 0, sizeof(wpa)); (void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name)); - if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCG80211WPAPARMS"); wpa.i_groupcipher = cipher; @@ -2149,7 +2149,7 @@ setifwpagroupcipher(const char *val, int d) return; } - if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCS80211WPAPARMS"); } @@ -2177,7 +2177,7 @@ setifwpakey(const char *val, int d) } else { warnx("no nwid or join command, guessing nwid to use"); - if (ioctl(s, SIOCG80211NWID, (caddr_t)&ifr)) + if (ioctl(s, SIOCG80211NWID, (caddr_t)&ifr) == -1) err(1, "SIOCG80211NWID"); } @@ -2214,16 +2214,16 @@ setifwpakey(const char *val, int d) return; } - if (ioctl(s, SIOCS80211WPAPSK, (caddr_t)&psk) < 0) + if (ioctl(s, SIOCS80211WPAPSK, (caddr_t)&psk) == -1) err(1, "SIOCS80211WPAPSK"); /* And ... automatically enable or disable WPA */ memset(&wpa, 0, sizeof(wpa)); (void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name)); - if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCG80211WPAPARMS"); wpa.i_enabled = psk.i_enabled; - if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) < 0) + if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1) err(1, "SIOCS80211WPAPARMS"); } @@ -2762,7 +2762,7 @@ init_current_media(void) (void) memset(&ifmr, 0, sizeof(ifmr)); (void) strlcpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); - if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { + if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) { /* * If we get E2BIG, the kernel is telling us * that there are more, so we can ignore it. @@ -2798,7 +2798,7 @@ process_media_commands(void) (void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_media = media_current; - if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) == -1) err(1, "SIOCSIFMEDIA"); } @@ -3169,7 +3169,7 @@ phys_status(int force) memset(&req, 0, sizeof(req)); (void) strlcpy(req.iflr_name, name, sizeof(req.iflr_name)); - if (ioctl(s, SIOCGLIFPHYADDR, (caddr_t)&req) < 0) { + if (ioctl(s, SIOCGLIFPHYADDR, (caddr_t)&req) == -1) { if (errno != EADDRNOTAVAIL) return; @@ -3309,7 +3309,7 @@ status(int link, struct sockaddr_dl *sdl, int ls) (void) memset(&ifmr, 0, sizeof(ifmr)); (void) strlcpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); - if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { + if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) { /* * Interface doesn't support SIOC{G,S}IFMEDIA. */ @@ -3329,7 +3329,7 @@ status(int link, struct sockaddr_dl *sdl, int ls) err(1, "calloc"); ifmr.ifm_ulist = media_list; - if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) + if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) err(1, "SIOCGIFMEDIA"); printf("\tmedia: "); @@ -3440,7 +3440,7 @@ in_status(int force) struct sockaddr_in *sin, sin2; getsock(AF_INET); - if (s < 0) { + if (s == -1) { if (errno == EPROTONOSUPPORT) return; err(1, "socket"); @@ -3458,7 +3458,7 @@ in_status(int force) printf("\tinet %s", inet_ntoa(sin->sin_addr)); (void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCGIFNETMASK, (caddr_t)&ifr) < 0) { + if (ioctl(s, SIOCGIFNETMASK, (caddr_t)&ifr) == -1) { if (errno != EADDRNOTAVAIL) warn("SIOCGIFNETMASK"); memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr)); @@ -3467,7 +3467,7 @@ in_status(int force) ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr; if (flags & IFF_POINTOPOINT) { memcpy(&ifr.ifr_addr, &sin2, sizeof(sin2)); - if (ioctl(s, SIOCGIFDSTADDR, (caddr_t)&ifr) < 0) { + if (ioctl(s, SIOCGIFDSTADDR, (caddr_t)&ifr) == -1) { if (errno == EADDRNOTAVAIL) memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr)); else @@ -3480,7 +3480,7 @@ in_status(int force) printf(" netmask 0x%x", ntohl(netmask.sin_addr.s_addr)); if (flags & IFF_BROADCAST) { memcpy(&ifr.ifr_addr, &sin2, sizeof(sin2)); - if (ioctl(s, SIOCGIFBRDADDR, (caddr_t)&ifr) < 0) { + if (ioctl(s, SIOCGIFBRDADDR, (caddr_t)&ifr) == -1) { if (errno == EADDRNOTAVAIL) memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr)); else @@ -3527,7 +3527,7 @@ in6_alias(struct in6_ifreq *creq) /* Get the non-alias address for this interface. */ getsock(AF_INET6); - if (s < 0) { + if (s == -1) { if (errno == EPROTONOSUPPORT) return; err(1, "socket"); @@ -3546,7 +3546,7 @@ in6_alias(struct in6_ifreq *creq) (void) memset(&ifr6, 0, sizeof(ifr6)); (void) strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name)); ifr6.ifr_addr = creq->ifr_addr; - if (ioctl(s, SIOCGIFDSTADDR_IN6, (caddr_t)&ifr6) < 0) { + if (ioctl(s, SIOCGIFDSTADDR_IN6, (caddr_t)&ifr6) == -1) { if (errno != EADDRNOTAVAIL) warn("SIOCGIFDSTADDR_IN6"); (void) memset(&ifr6.ifr_addr, 0, sizeof(ifr6.ifr_addr)); @@ -3564,7 +3564,7 @@ in6_alias(struct in6_ifreq *creq) (void) memset(&ifr6, 0, sizeof(ifr6)); (void) strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name)); ifr6.ifr_addr = creq->ifr_addr; - if (ioctl(s, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) < 0) { + if (ioctl(s, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) == -1) { if (errno != EADDRNOTAVAIL) warn("SIOCGIFNETMASK_IN6"); } else { @@ -3576,7 +3576,7 @@ in6_alias(struct in6_ifreq *creq) (void) memset(&ifr6, 0, sizeof(ifr6)); (void) strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name)); ifr6.ifr_addr = creq->ifr_addr; - if (ioctl(s, SIOCGIFAFLAG_IN6, (caddr_t)&ifr6) < 0) { + if (ioctl(s, SIOCGIFAFLAG_IN6, (caddr_t)&ifr6) == -1) { if (errno != EADDRNOTAVAIL) warn("SIOCGIFAFLAG_IN6"); } else { @@ -3606,7 +3606,7 @@ in6_alias(struct in6_ifreq *creq) (void) strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name)); ifr6.ifr_addr = creq->ifr_addr; lifetime = &ifr6.ifr_ifru.ifru_lifetime; - if (ioctl(s, SIOCGIFALIFETIME_IN6, (caddr_t)&ifr6) < 0) { + if (ioctl(s, SIOCGIFALIFETIME_IN6, (caddr_t)&ifr6) == -1) { if (errno != EADDRNOTAVAIL) warn("SIOCGIFALIFETIME_IN6"); } else if (lifetime->ia6t_preferred || lifetime->ia6t_expire) { @@ -3677,7 +3677,7 @@ settunnel(const char *src, const char *dst) (void) strlcpy(req.iflr_name, name, sizeof(req.iflr_name)); memcpy(&req.addr, srcres->ai_addr, srcres->ai_addrlen); memcpy(&req.dstaddr, dstres->ai_addr, dstres->ai_addrlen); - if (ioctl(s, SIOCSLIFPHYADDR, &req) < 0) + if (ioctl(s, SIOCSLIFPHYADDR, &req) == -1) warn("SIOCSLIFPHYADDR"); freeaddrinfo(srcres); @@ -3712,7 +3712,7 @@ settunneladdr(const char *addr, int ignored) req.dstaddr.ss_len = 2; req.dstaddr.ss_family = AF_UNSPEC; - if (ioctl(s, SIOCSLIFPHYADDR, &req) < 0) + if (ioctl(s, SIOCSLIFPHYADDR, &req) == -1) warn("tunneladdr %s", addr); freeaddrinfo(res); @@ -3722,7 +3722,7 @@ settunneladdr(const char *addr, int ignored) void deletetunnel(const char *ignored, int alsoignored) { - if (ioctl(s, SIOCDIFPHYADDR, &ifr) < 0) + if (ioctl(s, SIOCDIFPHYADDR, &ifr) == -1) warn("SIOCDIFPHYADDR"); } @@ -3738,7 +3738,7 @@ settunnelinst(const char *id, int param) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_rdomainid = rdomainid; - if (ioctl(s, SIOCSLIFPHYRTABLE, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSLIFPHYRTABLE, (caddr_t)&ifr) == -1) warn("SIOCSLIFPHYRTABLE"); } @@ -3747,7 +3747,7 @@ unsettunnelinst(const char *ignored, int alsoignored) { strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_rdomainid = 0; - if (ioctl(s, SIOCSLIFPHYRTABLE, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSLIFPHYRTABLE, (caddr_t)&ifr) == -1) warn("SIOCSLIFPHYRTABLE"); } @@ -3767,7 +3767,7 @@ settunnelttl(const char *id, int param) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_ttl = ttl; - if (ioctl(s, SIOCSLIFPHYTTL, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSLIFPHYTTL, (caddr_t)&ifr) == -1) warn("SIOCSLIFPHYTTL"); } @@ -3776,7 +3776,7 @@ settunneldf(const char *ignored, int alsoignored) { strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_df = 1; - if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) == -1) warn("SIOCSLIFPHYDF"); } @@ -3785,7 +3785,7 @@ settunnelnodf(const char *ignored, int alsoignored) { strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_df = 0; - if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) == -1) warn("SIOCSLIFPHYDF"); } @@ -3794,7 +3794,7 @@ settunnelecn(const char *ignored, int alsoignored) { strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_metric = 1; - if (ioctl(s, SIOCSLIFPHYECN, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSLIFPHYECN, (caddr_t)&ifr) == -1) warn("SIOCSLIFPHYECN"); } @@ -3803,7 +3803,7 @@ settunnelnoecn(const char *ignored, int alsoignored) { strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_metric = 0; - if (ioctl(s, SIOCSLIFPHYECN, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSLIFPHYECN, (caddr_t)&ifr) == -1) warn("SIOCSLIFPHYECN"); } @@ -3815,7 +3815,7 @@ setvnetflowid(const char *ignored, int alsoignored) errx(1, "vnetflowid: name is too long"); ifr.ifr_vnetid = 1; - if (ioctl(s, SIOCSVNETFLOWID, &ifr) < 0) + if (ioctl(s, SIOCSVNETFLOWID, &ifr) == -1) warn("SIOCSVNETFLOWID"); } @@ -3827,7 +3827,7 @@ delvnetflowid(const char *ignored, int alsoignored) errx(1, "vnetflowid: name is too long"); ifr.ifr_vnetid = 0; - if (ioctl(s, SIOCSVNETFLOWID, &ifr) < 0) + if (ioctl(s, SIOCSVNETFLOWID, &ifr) == -1) warn("SIOCSVNETFLOWID"); } @@ -4095,7 +4095,7 @@ setvnetid(const char *id, int param) } ifr.ifr_vnetid = vnetid; - if (ioctl(s, SIOCSVNETID, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSVNETID, (caddr_t)&ifr) == -1) warn("SIOCSVNETID"); } @@ -4103,7 +4103,7 @@ setvnetid(const char *id, int param) void delvnetid(const char *ignored, int alsoignored) { - if (ioctl(s, SIOCDVNETID, &ifr) < 0) + if (ioctl(s, SIOCDVNETID, &ifr) == -1) warn("SIOCDVNETID"); } @@ -4144,7 +4144,7 @@ setifparent(const char *id, int param) sizeof(ifp.ifp_parent)) errx(1, "parent: parent too long"); - if (ioctl(s, SIOCSIFPARENT, (caddr_t)&ifp) < 0) + if (ioctl(s, SIOCSIFPARENT, (caddr_t)&ifp) == -1) warn("SIOCSIFPARENT"); } @@ -4152,7 +4152,7 @@ setifparent(const char *id, int param) void delifparent(const char *ignored, int alsoignored) { - if (ioctl(s, SIOCDIFPARENT, &ifr) < 0) + if (ioctl(s, SIOCDIFPARENT, &ifr) == -1) warn("SIOCDIFPARENT"); } @@ -4213,7 +4213,7 @@ settxprio(const char *val, int d) errx(1, "tx prio %s: %s", val, errmsg); } - if (ioctl(s, SIOCSTXHPRIO, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSTXHPRIO, (caddr_t)&ifr) == -1) warn("SIOCSTXHPRIO"); } @@ -4253,7 +4253,7 @@ setrxprio(const char *val, int d) errx(1, "rx prio %s: %s", val, errmsg); } - if (ioctl(s, SIOCSRXHPRIO, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSRXHPRIO, (caddr_t)&ifr) == -1) warn("SIOCSRXHPRIO"); } #endif @@ -4346,7 +4346,7 @@ settrunkport(const char *val, int d) strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname)); strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname)); - if (ioctl(s, SIOCSTRUNKPORT, &rp)) + if (ioctl(s, SIOCSTRUNKPORT, &rp) == -1) err(1, "SIOCSTRUNKPORT"); } @@ -4359,7 +4359,7 @@ unsettrunkport(const char *val, int d) strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname)); strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname)); - if (ioctl(s, SIOCSTRUNKDELPORT, &rp)) + if (ioctl(s, SIOCSTRUNKDELPORT, &rp) == -1) err(1, "SIOCSTRUNKDELPORT"); } @@ -5217,7 +5217,7 @@ pppoe_status(void) memset(&state, 0, sizeof(state)); strlcpy(parms.ifname, name, sizeof(parms.ifname)); - if (ioctl(s, PPPOEGETPARMS, &parms)) + if (ioctl(s, PPPOEGETPARMS, &parms) == -1) return; printf("\tdev: %s ", parms.eth_ifname); @@ -5228,7 +5228,7 @@ pppoe_status(void) printf("svc: %s ", parms.service_name); strlcpy(state.ifname, name, sizeof(state.ifname)); - if (ioctl(s, PPPOEGETSESSION, &state)) + if (ioctl(s, PPPOEGETSESSION, &state) == -1) err(1, "PPPOEGETSESSION"); printf("state: "); @@ -5284,12 +5284,12 @@ setpppoe_dev(const char *val, int d) struct pppoediscparms parms; strlcpy(parms.ifname, name, sizeof(parms.ifname)); - if (ioctl(s, PPPOEGETPARMS, &parms)) + if (ioctl(s, PPPOEGETPARMS, &parms) == -1) return; strlcpy(parms.eth_ifname, val, sizeof(parms.eth_ifname)); - if (ioctl(s, PPPOESETPARMS, &parms)) + if (ioctl(s, PPPOESETPARMS, &parms) == -1) err(1, "PPPOESETPARMS"); } @@ -5300,7 +5300,7 @@ setpppoe_svc(const char *val, int d) struct pppoediscparms parms; strlcpy(parms.ifname, name, sizeof(parms.ifname)); - if (ioctl(s, PPPOEGETPARMS, &parms)) + if (ioctl(s, PPPOEGETPARMS, &parms) == -1) return; if (d == 0) @@ -5308,7 +5308,7 @@ setpppoe_svc(const char *val, int d) else memset(parms.service_name, 0, sizeof(parms.service_name)); - if (ioctl(s, PPPOESETPARMS, &parms)) + if (ioctl(s, PPPOESETPARMS, &parms) == -1) err(1, "PPPOESETPARMS"); } @@ -5319,7 +5319,7 @@ setpppoe_ac(const char *val, int d) struct pppoediscparms parms; strlcpy(parms.ifname, name, sizeof(parms.ifname)); - if (ioctl(s, PPPOEGETPARMS, &parms)) + if (ioctl(s, PPPOEGETPARMS, &parms) == -1) return; if (d == 0) @@ -5327,7 +5327,7 @@ setpppoe_ac(const char *val, int d) else memset(parms.ac_name, 0, sizeof(parms.ac_name)); - if (ioctl(s, PPPOESETPARMS, &parms)) + if (ioctl(s, PPPOESETPARMS, &parms) == -1) err(1, "PPPOESETPARMS"); } @@ -5534,7 +5534,7 @@ setkeepalive(const char *timeout, const char *count) strlcpy(ikar.ikar_name, name, sizeof(ikar.ikar_name)); ikar.ikar_timeo = t; ikar.ikar_cnt = c; - if (ioctl(s, SIOCSETKALIVE, (caddr_t)&ikar) < 0) + if (ioctl(s, SIOCSETKALIVE, (caddr_t)&ikar) == -1) warn("SIOCSETKALIVE"); } @@ -5545,7 +5545,7 @@ unsetkeepalive(const char *val, int d) bzero(&ikar, sizeof(ikar)); strlcpy(ikar.ikar_name, name, sizeof(ikar.ikar_name)); - if (ioctl(s, SIOCSETKALIVE, (caddr_t)&ikar) < 0) + if (ioctl(s, SIOCSETKALIVE, (caddr_t)&ikar) == -1) warn("SIOCSETKALIVE"); } @@ -5561,7 +5561,7 @@ setifpriority(const char *id, int param) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_metric = prio; - if (ioctl(s, SIOCSIFPRIORITY, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFPRIORITY, (caddr_t)&ifr) == -1) warn("SIOCSIFPRIORITY"); } @@ -6288,7 +6288,7 @@ setiflladdr(const char *addr, int param) ifr.ifr_addr.sa_len = ETHER_ADDR_LEN; ifr.ifr_addr.sa_family = AF_LINK; bcopy(eap, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN); - if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) == -1) warn("SIOCSIFLLADDR"); } @@ -6305,7 +6305,7 @@ setrdomain(const char *id, int param) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_rdomainid = rdomainid; - if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) == -1) warn("SIOCSIFRDOMAIN"); } @@ -6314,7 +6314,7 @@ unsetrdomain(const char *ignored, int alsoignored) { strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_rdomainid = 0; - if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) == -1) warn("SIOCSIFRDOMAIN"); } #endif @@ -6328,7 +6328,7 @@ setpair(const char *val, int d) errno = ENOENT; err(1, "patch %s", val); } - if (ioctl(s, SIOCSIFPAIR, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFPAIR, (caddr_t)&ifr) == -1) warn("SIOCSIFPAIR"); } @@ -6337,7 +6337,7 @@ unsetpair(const char *val, int d) { ifr.ifr_index = 0; strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCSIFPAIR, (caddr_t)&ifr) < 0) + if (ioctl(s, SIOCSIFPAIR, (caddr_t)&ifr) == -1) warn("SIOCSIFPAIR"); } #endif diff --git a/sbin/iked/ocsp.c b/sbin/iked/ocsp.c index 827a501c0f0..f5a379d8a0b 100644 --- a/sbin/iked/ocsp.c +++ b/sbin/iked/ocsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp.c,v 1.8 2015/12/07 12:46:37 reyk Exp $ */ +/* $OpenBSD: ocsp.c,v 1.9 2019/06/28 13:32:44 deraadt Exp $ */ /* * Copyright (c) 2014 Markus Friedl @@ -88,7 +88,7 @@ ocsp_connect(struct iked *env) goto done; } - if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0)) < 0) { + if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0)) == -1) { log_debug("%s: socket failed", __func__); goto done; } @@ -159,7 +159,7 @@ ocsp_connect_cb(int fd, short event, void *arg) socklen_t len; len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) == -1) { log_warn("%s: getsockopt SOL_SOCKET SO_ERROR", __func__); } else if (error) { log_debug("%s: error while connecting: %s", __func__, diff --git a/sbin/iked/parse.y b/sbin/iked/parse.y index e6abde0a2fd..b47aff5dbe2 100644 --- a/sbin/iked/parse.y +++ b/sbin/iked/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.80 2019/05/11 16:30:23 patrick Exp $ */ +/* $OpenBSD: parse.y,v 1.81 2019/06/28 13:32:44 deraadt Exp $ */ /* * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de> @@ -1735,9 +1735,9 @@ parsekeyfile(char *filename, struct iked_auth *auth) int fd, ret; unsigned char *hex; - if ((fd = open(filename, O_RDONLY)) < 0) + if ((fd = open(filename, O_RDONLY)) == -1) err(1, "open %s", filename); - if (fstat(fd, &sb) < 0) + if (fstat(fd, &sb) == -1) err(1, "parsekeyfile: stat %s", filename); if ((sb.st_size > KEYSIZE_LIMIT) || (sb.st_size == 0)) errx(1, "%s: key too %s", filename, sb.st_size ? "large" : @@ -2187,7 +2187,7 @@ ifa_load(void) struct sockaddr_in *sa_in; struct sockaddr_in6 *sa_in6; - if (getifaddrs(&ifap) < 0) + if (getifaddrs(&ifap) == -1) err(1, "ifa_load: getifaddrs"); for (ifa = ifap; ifa; ifa = ifa->ifa_next) { diff --git a/sbin/init/init.c b/sbin/init/init.c index f854c6acc3a..b23c6fd1f48 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.68 2018/08/24 18:36:56 cheloha Exp $ */ +/* $OpenBSD: init.c,v 1.69 2019/06/28 13:32:44 deraadt Exp $ */ /* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */ /*- @@ -226,14 +226,14 @@ main(int argc, char *argv[]) /* * Create an initial session. */ - if (setsid() < 0) + if (setsid() == -1) warning("initial setsid() failed: %m"); /* * Establish an initial user so that programs running * single user do not freak out and die (like passwd). */ - if (setlogin("root") < 0) + if (setlogin("root") == -1) warning("setlogin() failed: %m"); /* @@ -967,7 +967,7 @@ start_window_system(session_t *sp) sigemptyset(&mask); sigprocmask(SIG_SETMASK, &mask, NULL); - if (setsid() < 0) + if (setsid() == -1) emergency("setsid failed (window) %m"); setprocresources(RESOURCE_WINDOW); diff --git a/sbin/ipsecctl/pfkey.c b/sbin/ipsecctl/pfkey.c index d49ad4e0d2c..1f7aa0c0522 100644 --- a/sbin/ipsecctl/pfkey.c +++ b/sbin/ipsecctl/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.60 2017/04/19 15:59:38 bluhm Exp $ */ +/* $OpenBSD: pfkey.c,v 1.61 2019/06/28 13:32:44 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Markus Friedl <markus@openbsd.org> @@ -1315,7 +1315,7 @@ pfkey_monitor(int opts) pfd[0].fd = fd; pfd[0].events = POLLIN; for (;;) { - if ((n = poll(pfd, 1, -1)) < 0) + if ((n = poll(pfd, 1, -1)) == -1) err(2, "poll"); if (n == 0) break; diff --git a/sbin/isakmpd/if.c b/sbin/isakmpd/if.c index e30cbffd41f..0c6fad48d79 100644 --- a/sbin/isakmpd/if.c +++ b/sbin/isakmpd/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.25 2005/04/08 22:32:10 cloder Exp $ */ +/* $OpenBSD: if.c,v 1.26 2019/06/28 13:32:44 deraadt Exp $ */ /* $EOM: if.c,v 1.12 1999/10/01 13:45:20 niklas Exp $ */ /* @@ -48,7 +48,7 @@ if_map(int (*func)(char *, struct sockaddr *, void *), void *arg) struct ifaddrs *ifap, *ifa; - if (getifaddrs(&ifap) < 0) + if (getifaddrs(&ifap) == -1) return -1; for (ifa = ifap; ifa; ifa = ifa->ifa_next) diff --git a/sbin/isakmpd/ike_auth.c b/sbin/isakmpd/ike_auth.c index 776ac32b143..8d8e26fc6f5 100644 --- a/sbin/isakmpd/ike_auth.c +++ b/sbin/isakmpd/ike_auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ike_auth.c,v 1.116 2018/01/15 09:54:48 mpi Exp $ */ +/* $OpenBSD: ike_auth.c,v 1.117 2019/06/28 13:32:44 deraadt Exp $ */ /* $EOM: ike_auth.c,v 1.59 2000/11/21 00:21:31 angelos Exp $ */ /* @@ -201,7 +201,7 @@ ike_auth_get_key(int type, char *id, char *local_id, size_t *keylen) goto ignorekeynote; } - if (fstat(fd, &sb) < 0) { + if (fstat(fd, &sb) == -1) { log_print("ike_auth_get_key: fstat failed"); free(keyfile); close(fd); @@ -276,7 +276,7 @@ ignorekeynote: keyfile = privkeyfile; fd = monitor_open(keyfile, O_RDONLY, 0); - if (fd < 0 && errno != ENOENT) { + if (fd == -1 && errno != ENOENT) { log_print("ike_auth_get_key: failed opening " "\"%s\"", keyfile); free(privkeyfile); @@ -285,13 +285,13 @@ ignorekeynote: } } - if (fd < 0) { + if (fd == -1) { /* No key found, try default key. */ keyfile = conf_get_str("X509-certificates", "Private-key"); fd = monitor_open(keyfile, O_RDONLY, 0); - if (fd < 0) { + if (fd == -1) { log_print("ike_auth_get_key: failed opening " "\"%s\"", keyfile); return 0; diff --git a/sbin/isakmpd/monitor.c b/sbin/isakmpd/monitor.c index 37cd7eac918..1510438d26c 100644 --- a/sbin/isakmpd/monitor.c +++ b/sbin/isakmpd/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.76 2018/01/15 09:54:48 mpi Exp $ */ +/* $OpenBSD: monitor.c,v 1.77 2019/06/28 13:32:44 deraadt Exp $ */ /* * Copyright (c) 2003 Håkan Olsson. All rights reserved. @@ -611,7 +611,7 @@ m_priv_bind(void) v = -1; } else { v = bind(sock, name, namelen); - if (v < 0) { + if (v == -1) { log_error("m_priv_bind: bind(%d,%p,%d) returned %d", sock, name, namelen, v); err = errno; diff --git a/sbin/isakmpd/policy.c b/sbin/isakmpd/policy.c index 6a717cd4660..ca45fc950f2 100644 --- a/sbin/isakmpd/policy.c +++ b/sbin/isakmpd/policy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: policy.c,v 1.99 2018/01/15 09:54:48 mpi Exp $ */ +/* $OpenBSD: policy.c,v 1.100 2019/06/28 13:32:44 deraadt Exp $ */ /* $EOM: policy.c,v 1.49 2000/10/24 13:33:39 niklas Exp $ */ /* @@ -2182,7 +2182,7 @@ keynote_cert_obtain(u_int8_t *id, size_t id_len, void *data, u_int8_t **cert, return 0; } - if (fstat(fd, &sb) < 0) { + if (fstat(fd, &sb) == -1) { LOG_DBG((LOG_POLICY, 30, "keynote_cert_obtain: " "failed to stat \"%s\"", file)); free(file); diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c index 7263465dacb..ad54be2b874 100644 --- a/sbin/isakmpd/util.c +++ b/sbin/isakmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.71 2019/01/22 09:25:29 krw Exp $ */ +/* $OpenBSD: util.c,v 1.72 2019/06/28 13:32:44 deraadt Exp $ */ /* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */ /* @@ -252,7 +252,7 @@ text2sockaddr(char *address, char *port, struct sockaddr **sa, sa_family_t af, rtm->rtm_addrs |= RTA_NETMASK|RTA_IFP|RTA_IFA; rtm->rtm_msglen = sizeof(*rtm) + sizeof(*sa2); - if ((b = write(fd, buf, rtm->rtm_msglen)) < 0) { + if ((b = write(fd, buf, rtm->rtm_msglen)) == -1) { close(fd); return -1; } diff --git a/sbin/isakmpd/virtual.c b/sbin/isakmpd/virtual.c index 4a7e672fa75..52a692a72c0 100644 --- a/sbin/isakmpd/virtual.c +++ b/sbin/isakmpd/virtual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtual.c,v 1.32 2015/08/20 22:02:21 deraadt Exp $ */ +/* $OpenBSD: virtual.c,v 1.33 2019/06/28 13:32:44 deraadt Exp $ */ /* * Copyright (c) 2004 Håkan Olsson. All rights reserved. @@ -419,7 +419,7 @@ virtual_bind_if(char *ifname, struct sockaddr *if_addr, void *arg) memset(&flags_ifr6, 0, sizeof(flags_ifr6)); strlcpy(flags_ifr6.ifr_name, ifname, sizeof flags_ifr6.ifr_name); flags_ifr6.ifr_addr = *(struct sockaddr_in6 *)if_addr; - if (ioctl(s, SIOCGIFAFLAG_IN6, (caddr_t)&flags_ifr6) < 0) { + if (ioctl(s, SIOCGIFAFLAG_IN6, (caddr_t)&flags_ifr6) == -1) { log_error("virtual_bind_if: " "ioctl (%d, SIOCGIFAFLAG_IN6, ...) failed", s); close(s); diff --git a/sbin/kbd/kbd_wscons.c b/sbin/kbd/kbd_wscons.c index 11828bdcb23..af25d2d0ffa 100644 --- a/sbin/kbd/kbd_wscons.c +++ b/sbin/kbd/kbd_wscons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kbd_wscons.c,v 1.32 2016/10/03 13:03:49 jca Exp $ */ +/* $OpenBSD: kbd_wscons.c,v 1.33 2019/06/28 13:32:44 deraadt Exp $ */ /* * Copyright (c) 2001 Mats O Jansson. All rights reserved. @@ -136,7 +136,7 @@ kbd_get_encs(int fd, struct wskbd_encoding_data *encs) encs->nencodings, sizeof(kbd_t)); if (encs->encodings == NULL) err(1, NULL); - if (ioctl(fd, WSKBDIO_GETENCODINGS, encs) < 0) + if (ioctl(fd, WSKBDIO_GETENCODINGS, encs) == -1) err(1, "WSKBDIO_GETENCODINGS"); if (encs->nencodings == nencodings) { nencodings *= 2; @@ -160,10 +160,10 @@ kbd_list(void) for (i = 0; i < NUM_KBD; i++) { (void) snprintf(device, sizeof device, "/dev/wskbd%d", i); fd = open(device, O_WRONLY); - if (fd < 0) + if (fd == -1) fd = open(device, O_RDONLY); if (fd >= 0) { - if (ioctl(fd, WSKBDIO_GTYPE, &kbtype) < 0) + if (ioctl(fd, WSKBDIO_GTYPE, &kbtype) == -1) err(1, "WSKBDIO_GTYPE"); switch (kbtype) { case WSKBD_TYPE_PC_XT: @@ -258,10 +258,10 @@ kbd_set(char *name, int verbose) for (i = 0; i < NUM_KBD; i++) { (void) snprintf(device, sizeof device, "/dev/wskbd%d", i); fd = open(device, O_WRONLY); - if (fd < 0) + if (fd == -1) fd = open(device, O_RDONLY); if (fd >= 0) { - if (ioctl(fd, WSKBDIO_SETENCODING, &map) < 0) { + if (ioctl(fd, WSKBDIO_SETENCODING, &map) == -1) { if (errno == EINVAL) { fprintf(stderr, "%s: unsupported encoding %s on %s\n", diff --git a/sbin/ldattach/ldattach.c b/sbin/ldattach/ldattach.c index c133d1d6bd6..042f119cefa 100644 --- a/sbin/ldattach/ldattach.c +++ b/sbin/ldattach/ldattach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldattach.c,v 1.17 2016/11/26 11:18:43 mpi Exp $ */ +/* $OpenBSD: ldattach.c,v 1.18 2019/06/28 13:32:44 deraadt Exp $ */ /* * Copyright (c) 2007, 2008 Marc Balmer <mbalmer@openbsd.org> @@ -210,7 +210,7 @@ main(int argc, char *argv[]) goto bail_out; } - if ((fd = open(dev, O_RDWR)) < 0) { + if ((fd = open(dev, O_RDWR)) == -1) { syslog(LOG_ERR, "can't open %s", dev); goto bail_out; } @@ -221,7 +221,7 @@ main(int argc, char *argv[]) * the line discipline (e.g. nmea has a default baudrate of * 4800 instead of 9600). */ - if (tcgetattr(fd, &tty) < 0) { + if (tcgetattr(fd, &tty) == -1) { if (ppid != 1) warnx("tcgetattr"); goto bail_out; @@ -258,9 +258,9 @@ main(int argc, char *argv[]) cfsetspeed(&tty, speed); /* setup common to all line disciplines */ - if (ioctl(fd, TIOCSDTR, 0) < 0) + if (ioctl(fd, TIOCSDTR, 0) == -1) warn("TIOCSDTR"); - if (ioctl(fd, TIOCSETD, &ldisc) < 0) { + if (ioctl(fd, TIOCSETD, &ldisc) == -1) { syslog(LOG_ERR, "can't attach %s line discipline on %s", disc, dev); goto bail_out; @@ -271,7 +271,7 @@ main(int argc, char *argv[]) case NMEADISC: case MSTSDISC: case ENDRUNDISC: - if (ioctl(fd, TIOCSTSTAMP, &tstamps) < 0) { + if (ioctl(fd, TIOCSTSTAMP, &tstamps) == -1) { warnx("TIOCSTSTAMP"); goto bail_out; } @@ -285,7 +285,7 @@ main(int argc, char *argv[]) } /* finally set the line attributes */ - if (tcsetattr(fd, TCSADRAIN, &tty) < 0) { + if (tcsetattr(fd, TCSADRAIN, &tty) == -1) { if (ppid != 1) warnx("tcsetattr"); goto bail_out; diff --git a/sbin/mknod/mknod.c b/sbin/mknod/mknod.c index f64b5edb252..2b80d6aeca5 100644 --- a/sbin/mknod/mknod.c +++ b/sbin/mknod/mknod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mknod.c,v 1.30 2016/10/20 10:24:40 schwarze Exp $ */ +/* $OpenBSD: mknod.c,v 1.31 2019/06/28 13:32:44 deraadt Exp $ */ /* $NetBSD: mknod.c,v 1.8 1995/08/11 00:08:18 jtc Exp $ */ /* @@ -196,7 +196,7 @@ domakenodes(struct node *node, int n) } r = mknod(node[i].name, node[i].mode, node[i].dev); - if (r < 0) { + if (r == -1) { warn("%s", node[i].name); rv = 1; } diff --git a/sbin/mount/getmntopts.c b/sbin/mount/getmntopts.c index 19e185f061e..105b3b46bc0 100644 --- a/sbin/mount/getmntopts.c +++ b/sbin/mount/getmntopts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getmntopts.c,v 1.12 2015/01/16 06:39:59 deraadt Exp $ */ +/* $OpenBSD: getmntopts.c,v 1.13 2019/06/28 13:32:44 deraadt Exp $ */ /* $NetBSD: getmntopts.c,v 1.3 1995/03/18 14:56:58 cgd Exp $ */ /*- @@ -114,7 +114,7 @@ getmntopt(char **optionp, union mntval *valuep, const struct mntopt *m0, if (m->m_oflags & MFLAG_INTVAL) { errno = 0; l = strtol(value, &endp, 10); - if (endp == value || l < 0 || l > INT_MAX || + if (endp == value || l == -1 || l > INT_MAX || (l == LONG_MAX && errno == ERANGE)) errx(1, "%s: illegal value '%s'", opt, value); diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index 3a43dc4324b..67bd625ec58 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.c,v 1.71 2017/02/06 17:15:56 tb Exp $ */ +/* $OpenBSD: mount.c,v 1.72 2019/06/28 13:32:44 deraadt Exp $ */ /* $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp $ */ /* @@ -380,7 +380,7 @@ mountfs(const char *vfstype, const char *spec, const char *name, if (!hasopt(optbuf, "update")) optbuf = catopt(optbuf, "update"); } else if (skipmounted) { - if (statfs(name, &sf) < 0) { + if (statfs(name, &sf) == -1) { warn("statfs %s", name); return (1); } @@ -446,7 +446,7 @@ mountfs(const char *vfstype, const char *spec, const char *name, free(optbuf); free(argv); - if (waitpid(pid, &status, 0) < 0) { + if (waitpid(pid, &status, 0) == -1) { warn("waitpid"); return (1); } @@ -460,7 +460,7 @@ mountfs(const char *vfstype, const char *spec, const char *name, } if (verbose) { - if (statfs(name, &sf) < 0) { + if (statfs(name, &sf) == -1) { warn("statfs %s", name); return (1); } diff --git a/sbin/mount_cd9660/mount_cd9660.c b/sbin/mount_cd9660/mount_cd9660.c index 9c6b59725e5..2bc61f70f75 100644 --- a/sbin/mount_cd9660/mount_cd9660.c +++ b/sbin/mount_cd9660/mount_cd9660.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_cd9660.c,v 1.21 2015/01/16 06:39:59 deraadt Exp $ */ +/* $OpenBSD: mount_cd9660.c,v 1.22 2019/06/28 13:32:44 deraadt Exp $ */ /* $NetBSD: mount_cd9660.c,v 1.3 1996/04/13 01:31:08 jtc Exp $ */ /* @@ -117,7 +117,7 @@ main(int argc, char *argv[]) args.flags = opts; args.sess = sess; - if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0) { + if (mount(MOUNT_CD9660, dir, mntflags, &args) == -1) { if (errno == EOPNOTSUPP) errx(1, "%s: Filesystem not supported by kernel", dir); else diff --git a/sbin/mount_ext2fs/mount_ext2fs.c b/sbin/mount_ext2fs/mount_ext2fs.c index 9e77a3edb85..261cf151f50 100644 --- a/sbin/mount_ext2fs/mount_ext2fs.c +++ b/sbin/mount_ext2fs/mount_ext2fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_ext2fs.c,v 1.18 2015/12/08 15:56:42 tedu Exp $ */ +/* $OpenBSD: mount_ext2fs.c,v 1.19 2019/06/28 13:32:44 deraadt Exp $ */ /* $NetBSD: mount_ffs.c,v 1.3 1996/04/13 01:31:19 jtc Exp $ */ /*- @@ -86,7 +86,7 @@ main(int argc, char *argv[]) else args.export_info.ex_flags = 0; - if (mount(MOUNT_EXT2FS, fs_name, mntflags, &args) < 0) { + if (mount(MOUNT_EXT2FS, fs_name, mntflags, &args) == -1) { switch (errno) { case EMFILE: errcause = "mount table full"; diff --git a/sbin/mount_ffs/mount_ffs.c b/sbin/mount_ffs/mount_ffs.c index 35fa8abf230..b3915ee27b8 100644 --- a/sbin/mount_ffs/mount_ffs.c +++ b/sbin/mount_ffs/mount_ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_ffs.c,v 1.24 2016/09/10 16:53:30 natano Exp $ */ +/* $OpenBSD: mount_ffs.c,v 1.25 2019/06/28 13:32:44 deraadt Exp $ */ /* $NetBSD: mount_ffs.c,v 1.3 1996/04/13 01:31:19 jtc Exp $ */ /*- @@ -96,7 +96,7 @@ main(int argc, char *argv[]) if (mntflags & MNT_NOPERM) mntflags |= MNT_NODEV | MNT_NOEXEC; - if (mount(MOUNT_FFS, fs_name, mntflags, &args) < 0) { + if (mount(MOUNT_FFS, fs_name, mntflags, &args) == -1) { switch (errno) { case EMFILE: errcause = "mount table full"; diff --git a/sbin/mount_msdos/mount_msdos.c b/sbin/mount_msdos/mount_msdos.c index 707adc8840e..4e4c042d5e9 100644 --- a/sbin/mount_msdos/mount_msdos.c +++ b/sbin/mount_msdos/mount_msdos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_msdos.c,v 1.33 2016/05/21 19:14:02 jmc Exp $ */ +/* $OpenBSD: mount_msdos.c,v 1.34 2019/06/28 13:32:45 deraadt Exp $ */ /* $NetBSD: mount_msdos.c,v 1.16 1996/10/24 00:12:50 cgd Exp $ */ /* @@ -129,7 +129,7 @@ main(int argc, char **argv) args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } - if (mount(MOUNT_MSDOS, dir, mntflags, &args) < 0) { + if (mount(MOUNT_MSDOS, dir, mntflags, &args) == -1) { switch (errno) { case EOPNOTSUPP: errcause = "filesystem not supported by kernel"; diff --git a/sbin/mount_ntfs/mount_ntfs.c b/sbin/mount_ntfs/mount_ntfs.c index 6737c123c32..9766cc4a402 100644 --- a/sbin/mount_ntfs/mount_ntfs.c +++ b/sbin/mount_ntfs/mount_ntfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_ntfs.c,v 1.16 2015/12/30 21:38:28 millert Exp $ */ +/* $OpenBSD: mount_ntfs.c,v 1.17 2019/06/28 13:32:45 deraadt Exp $ */ /* $NetBSD: mount_ntfs.c,v 1.9 2003/05/03 15:37:08 christos Exp $ */ /* @@ -121,7 +121,7 @@ main(int argc, char *argv[]) if (!set_mask) args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } - if (mount(MOUNT_NTFS, dir, mntflags, &args) < 0) + if (mount(MOUNT_NTFS, dir, mntflags, &args) == -1) err(1, "%s on %s", dev, dir); exit(0); diff --git a/sbin/mount_udf/mount_udf.c b/sbin/mount_udf/mount_udf.c index 121146b5b7f..124662568f2 100644 --- a/sbin/mount_udf/mount_udf.c +++ b/sbin/mount_udf/mount_udf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_udf.c,v 1.7 2015/01/16 06:39:59 deraadt Exp $ */ +/* $OpenBSD: mount_udf.c,v 1.8 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 2005 Pedro Martelletto <pedro@ambientworks.net> @@ -56,7 +56,7 @@ lastblock(char *dev) struct cd_toc_entry te; fd = open(dev, O_RDONLY, 0); - if (fd < 0) + if (fd == -1) err(1, "open"); t.address_format = CD_LBA_FORMAT; @@ -99,7 +99,7 @@ main(int argc, char **argv) if (realpath(argv[1], node) == NULL) err(1, "realpath %s", argv[1]); - if (mount(MOUNT_UDF, node, flags, &args) < 0) + if (mount(MOUNT_UDF, node, flags, &args) == -1) err(1, "mount"); exit(0); diff --git a/sbin/mount_vnd/mount_vnd.c b/sbin/mount_vnd/mount_vnd.c index 8b04f6307e9..f39db6cb048 100644 --- a/sbin/mount_vnd/mount_vnd.c +++ b/sbin/mount_vnd/mount_vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_vnd.c,v 1.21 2019/04/25 22:39:46 deraadt Exp $ */ +/* $OpenBSD: mount_vnd.c,v 1.22 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 1993 University of Utah. * Copyright (c) 1990, 1993 @@ -190,7 +190,7 @@ config(char *dev, char *file, struct disklabel *dp, char *key, size_t keylen) char *rdev; int fd, rv = -1; - if ((fd = opendev(dev, O_RDONLY, OPENDEV_PART, &rdev)) < 0) { + if ((fd = opendev(dev, O_RDONLY, OPENDEV_PART, &rdev)) == -1) { err(4, "%s", rdev); goto out; } diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index 0e09071a5df..40b09fc2cb7 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mountd.c,v 1.86 2018/04/28 09:56:21 guenther Exp $ */ +/* $OpenBSD: mountd.c,v 1.87 2019/06/28 13:32:45 deraadt Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* @@ -780,9 +780,9 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp) fprintf(stderr, "realpath failed on %s\n", rpcpath); strlcpy(dirpath, rpcpath, sizeof(dirpath)); - } else if (stat(dirpath, &stb) < 0 || + } else if (stat(dirpath, &stb) == -1 || (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) || - statfs(dirpath, &fsb) < 0) { + statfs(dirpath, &fsb) == -1) { if (debug) fprintf(stderr, "stat failed on %s\n", dirpath); bad = ENOENT; /* We will send error reply later */ @@ -2408,13 +2408,13 @@ check_dirpath(char *dirp) while (*cp && ret) { if (*cp == '/') { *cp = '\0'; - if (lstat(dirp, &sb) < 0 || !S_ISDIR(sb.st_mode)) + if (lstat(dirp, &sb) == -1 || !S_ISDIR(sb.st_mode)) ret = 0; *cp = '/'; } cp++; } - if (lstat(dirp, &sb) < 0 || + if (lstat(dirp, &sb) == -1 || (!S_ISDIR(sb.st_mode) && !S_ISREG(sb.st_mode))) ret = 0; return (ret); diff --git a/sbin/ncheck_ffs/ncheck_ffs.c b/sbin/ncheck_ffs/ncheck_ffs.c index 93a72900020..aa12a3a1736 100644 --- a/sbin/ncheck_ffs/ncheck_ffs.c +++ b/sbin/ncheck_ffs/ncheck_ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncheck_ffs.c,v 1.53 2016/05/28 23:46:06 tb Exp $ */ +/* $OpenBSD: ncheck_ffs.c,v 1.54 2019/06/28 13:32:45 deraadt Exp $ */ /*- * Copyright (c) 1995, 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com> @@ -571,7 +571,7 @@ main(int argc, char *argv[]) err(1, "cannot find real path for %s", disk); disk = rdisk; - if (stat(disk, &stblock) < 0) + if (stat(disk, &stblock) == -1) err(1, "cannot stat %s", disk); if (S_ISBLK(stblock.st_mode)) { @@ -582,13 +582,13 @@ main(int argc, char *argv[]) disk = rawname(fsp->fs_spec); } - if ((diskfd = opendev(disk, O_RDONLY, 0, NULL)) < 0) + if ((diskfd = opendev(disk, O_RDONLY, 0, NULL)) == -1) err(1, "cannot open %s", disk); gotdev: - if (ioctl(diskfd, DIOCGDINFO, (char *)&lab) < 0) + if (ioctl(diskfd, DIOCGDINFO, (char *)&lab) == -1) err(1, "ioctl (DIOCGDINFO)"); - if (ioctl(diskfd, DIOCGPDINFO, (char *)&lab) < 0) + if (ioctl(diskfd, DIOCGPDINFO, (char *)&lab) == -1) err(1, "ioctl (DIOCGPDINFO)"); if (pledge("stdio", NULL) == -1) diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 349e669a295..5276b791028 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.111 2018/11/25 17:12:10 krw Exp $ */ +/* $OpenBSD: newfs.c,v 1.112 2019/06/28 13:32:45 deraadt Exp $ */ /* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */ /* @@ -380,7 +380,7 @@ main(int argc, char *argv[]) fso = -1; } else { fso = opendev(special, O_WRONLY, 0, &realdev); - if (fso < 0) + if (fso == -1) fatal("%s: %s", special, strerror(errno)); special = realdev; @@ -413,9 +413,9 @@ main(int argc, char *argv[]) pp = &lp->d_partitions[1]; } else { fsi = opendev(special, O_RDONLY, 0, NULL); - if (fsi < 0) + if (fsi == -1) fatal("%s: %s", special, strerror(errno)); - if (fstat(fsi, &st) < 0) + if (fstat(fsi, &st) == -1) fatal("%s: %s", special, strerror(errno)); if (!mfs) { if (S_ISBLK(st.st_mode)) @@ -496,7 +496,7 @@ havelabel: if (mfs) { if (realpath(argv[1], node) == NULL) err(1, "realpath %s", argv[1]); - if (stat(node, &mountpoint) < 0) + if (stat(node, &mountpoint) == -1) err(ECANCELED, "stat %s", node); mfsuid = mountpoint.st_uid; mfsgid = mountpoint.st_gid; @@ -555,10 +555,10 @@ havelabel: args.fspec = mountfromname; if (pop != NULL) { int tmpflags = mntflags & ~MNT_RDONLY; - if (mount(MOUNT_MFS, tmpnode, tmpflags, &args) < 0) + if (mount(MOUNT_MFS, tmpnode, tmpflags, &args) == -1) exit(errno); /* parent prints message */ } - if (mount(MOUNT_MFS, node, mntflags, &args) < 0) + if (mount(MOUNT_MFS, node, mntflags, &args) == -1) exit(errno); /* parent prints message */ } #endif @@ -570,7 +570,7 @@ getdisklabel(char *s, int fd) { static struct disklabel lab; - if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { + if (ioctl(fd, DIOCGDINFO, (char *)&lab) == -1) { if (disktype != NULL) { struct disklabel *lp; @@ -595,7 +595,7 @@ rewritelabel(char *s, int fd, struct disklabel *lp) lp->d_checksum = 0; lp->d_checksum = dkcksum(lp); - if (ioctl(fd, DIOCWDINFO, (char *)lp) < 0) { + if (ioctl(fd, DIOCWDINFO, (char *)lp) == -1) { warn("ioctl (WDINFO)"); fatal("%s: can't rewrite disk label", s); } @@ -607,7 +607,7 @@ fatal(const char *fmt, ...) va_list ap; va_start(ap, fmt); - if (fcntl(STDERR_FILENO, F_GETFL) < 0) { + if (fcntl(STDERR_FILENO, F_GETFL) == -1) { openlog(__progname, LOG_CONS, LOG_DAEMON); vsyslog(LOG_ERR, fmt, ap); closelog(); @@ -669,7 +669,7 @@ waitformount(char *node, pid_t pid) * can mount a filesystem which hides our * ramdisk before we see the success. */ - if (statfs(node, &sf) < 0) + if (statfs(node, &sf) == -1) err(ECANCELED, "statfs %s", node); if (!strcmp(sf.f_mntfromname, mountfromname) && !strncmp(sf.f_mntonname, node, diff --git a/sbin/newfs_ext2fs/newfs_ext2fs.c b/sbin/newfs_ext2fs/newfs_ext2fs.c index 815e4942553..a22423490ae 100644 --- a/sbin/newfs_ext2fs/newfs_ext2fs.c +++ b/sbin/newfs_ext2fs/newfs_ext2fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs_ext2fs.c,v 1.26 2018/11/25 17:12:10 krw Exp $ */ +/* $OpenBSD: newfs_ext2fs.c,v 1.27 2019/06/28 13:32:45 deraadt Exp $ */ /* $NetBSD: newfs_ext2fs.c,v 1.8 2009/03/02 10:38:13 tsutsui Exp $ */ /* @@ -248,7 +248,7 @@ main(int argc, char *argv[]) err(EXIT_FAILURE, "can't fstat opened %s", special); } else { /* !Fflag */ fd = opendev(special, fl, 0, &special); - if (fd < 0 || fstat(fd, &sb) == -1) + if (fd == -1 || fstat(fd, &sb) == -1) err(EXIT_FAILURE, "%s: open", special); if (!Nflag) { @@ -464,7 +464,7 @@ getdisklabel(const char *s, int fd) { static struct disklabel lab; - if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { + if (ioctl(fd, DIOCGDINFO, (char *)&lab) == -1) { if (disktype != NULL) { struct disklabel *lp; @@ -491,7 +491,7 @@ getpartition(int fsi, const char *special, char *argv[], struct disklabel **dl) struct disklabel *lp; struct partition *pp; - if (fstat(fsi, &st) < 0) + if (fstat(fsi, &st) == -1) err(EXIT_FAILURE, "%s", special); if (S_ISBLK(st.st_mode)) errx(EXIT_FAILURE, "%s: block device", special); diff --git a/sbin/nfsd/nfsd.c b/sbin/nfsd/nfsd.c index 41448a2a301..56c3c04a8d2 100644 --- a/sbin/nfsd/nfsd.c +++ b/sbin/nfsd/nfsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfsd.c,v 1.38 2018/01/05 08:13:31 mpi Exp $ */ +/* $OpenBSD: nfsd.c,v 1.39 2019/06/28 13:32:45 deraadt Exp $ */ /* $NetBSD: nfsd.c,v 1.19 1996/02/18 23:18:56 mycroft Exp $ */ /* @@ -197,7 +197,7 @@ main(int argc, char *argv[]) setproctitle("server"); nsd.nsd_nfsd = NULL; - if (nfssvc(NFSSVC_NFSD, &nsd) < 0) { + if (nfssvc(NFSSVC_NFSD, &nsd) == -1) { syslog(LOG_ERR, "nfssvc: %s", strerror(errno)); return (1); } @@ -206,7 +206,7 @@ main(int argc, char *argv[]) /* If we are serving udp, set up the socket. */ if (udpflag) { - if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { syslog(LOG_ERR, "can't create udp socket"); return (1); } @@ -216,7 +216,7 @@ main(int argc, char *argv[]) inetaddr.sin_port = htons(NFS_PORT); inetaddr.sin_len = sizeof(inetaddr); if (bind(sock, (struct sockaddr *)&inetaddr, - sizeof(inetaddr)) < 0) { + sizeof(inetaddr)) == -1) { syslog(LOG_ERR, "can't bind udp addr"); return (1); } @@ -228,7 +228,7 @@ main(int argc, char *argv[]) nfsdargs.sock = sock; nfsdargs.name = NULL; nfsdargs.namelen = 0; - if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) { + if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) == -1) { syslog(LOG_ERR, "can't Add UDP socket"); return (1); } @@ -239,12 +239,12 @@ main(int argc, char *argv[]) on = 1; connect_type_cnt = 0; if (tcpflag) { - if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { syslog(LOG_ERR, "can't create tcp socket"); return (1); } if (setsockopt(tcpsock, - SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) + SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %s", strerror(errno)); memset(&inetaddr, 0, sizeof inetaddr); inetaddr.sin_family = AF_INET; @@ -252,11 +252,11 @@ main(int argc, char *argv[]) inetaddr.sin_port = htons(NFS_PORT); inetaddr.sin_len = sizeof(inetaddr); if (bind(tcpsock, (struct sockaddr *)&inetaddr, - sizeof (inetaddr)) < 0) { + sizeof (inetaddr)) == -1) { syslog(LOG_ERR, "can't bind tcp addr"); return (1); } - if (listen(tcpsock, 5) < 0) { + if (listen(tcpsock, 5) == -1) { syslog(LOG_ERR, "listen failed"); return (1); } @@ -298,7 +298,7 @@ main(int argc, char *argv[]) if (tcpflag) { len = sizeof(inetpeer); if ((msgsock = accept(tcpsock, - (struct sockaddr *)&inetpeer, &len)) < 0) { + (struct sockaddr *)&inetpeer, &len)) == -1) { if (errno == EWOULDBLOCK || errno == EINTR || errno == ECONNABORTED) continue; @@ -307,13 +307,13 @@ main(int argc, char *argv[]) } memset(inetpeer.sin_zero, 0, sizeof(inetpeer.sin_zero)); if (setsockopt(msgsock, SOL_SOCKET, - SO_KEEPALIVE, &on, sizeof(on)) < 0) + SO_KEEPALIVE, &on, sizeof(on)) == -1) syslog(LOG_ERR, "setsockopt SO_KEEPALIVE: %s", strerror(errno)); nfsdargs.sock = msgsock; nfsdargs.name = (caddr_t)&inetpeer; nfsdargs.namelen = sizeof(inetpeer); - if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) { + if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) == -1) { syslog(LOG_ERR, "can't Add TCP socket"); return (1); } diff --git a/sbin/nologin/nologin.c b/sbin/nologin/nologin.c index 15875cc1b0e..88bdd5f6fd7 100644 --- a/sbin/nologin/nologin.c +++ b/sbin/nologin/nologin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nologin.c,v 1.7 2018/08/14 18:13:11 cheloha Exp $ */ +/* $OpenBSD: nologin.c,v 1.8 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 1997, Jason Downs. All rights reserved. @@ -52,7 +52,7 @@ main(int argc, char *argv[]) err(1, "pledge"); nfd = open(_PATH_NOLOGIN_TXT, O_RDONLY); - if (nfd < 0) { + if (nfd == -1) { write(STDOUT_FILENO, DEFAULT_MESG, strlen(DEFAULT_MESG)); exit (1); } diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index f56f6f9e90b..5dbf64284b2 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl.c,v 1.373 2019/04/15 21:36:44 sashan Exp $ */ +/* $OpenBSD: pfctl.c,v 1.374 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -254,7 +254,7 @@ usage(void) int pfctl_enable(int dev, int opts) { - if (ioctl(dev, DIOCSTART)) { + if (ioctl(dev, DIOCSTART) == -1) { if (errno == EEXIST) errx(1, "pf already enabled"); else @@ -269,7 +269,7 @@ pfctl_enable(int dev, int opts) int pfctl_disable(int dev, int opts) { - if (ioctl(dev, DIOCSTOP)) { + if (ioctl(dev, DIOCSTOP) == -1) { if (errno == ENOENT) errx(1, "pf not enabled"); else @@ -291,7 +291,7 @@ pfctl_clear_stats(int dev, const char *iface, int opts) sizeof(pi.pfiio_name)) >= sizeof(pi.pfiio_name)) errx(1, "invalid interface: %s", iface); - if (ioctl(dev, DIOCCLRSTATUS, &pi)) + if (ioctl(dev, DIOCCLRSTATUS, &pi) == -1) err(1, "DIOCCLRSTATUS"); if ((opts & PF_OPT_QUIET) == 0) { fprintf(stderr, "pf: statistics cleared"); @@ -310,7 +310,7 @@ pfctl_clear_interface_flags(int dev, int opts) bzero(&pi, sizeof(pi)); pi.pfiio_flags = PFI_IFLAG_SKIP; - if (ioctl(dev, DIOCCLRIFFLAG, &pi)) + if (ioctl(dev, DIOCCLRIFFLAG, &pi) == -1) err(1, "DIOCCLRIFFLAG"); if ((opts & PF_OPT_QUIET) == 0) fprintf(stderr, "pf: interface flags reset\n"); @@ -335,7 +335,7 @@ pfctl_clear_rules(int dev, int opts, char *anchorname) void pfctl_clear_src_nodes(int dev, int opts) { - if (ioctl(dev, DIOCCLRSRCNODES)) + if (ioctl(dev, DIOCCLRSRCNODES) == -1) err(1, "DIOCCLRSRCNODES"); if ((opts & PF_OPT_QUIET) == 0) fprintf(stderr, "source tracking entries cleared\n"); @@ -351,7 +351,7 @@ pfctl_clear_states(int dev, const char *iface, int opts) sizeof(psk.psk_ifname)) >= sizeof(psk.psk_ifname)) errx(1, "invalid interface: %s", iface); - if (ioctl(dev, DIOCCLRSTATES, &psk)) + if (ioctl(dev, DIOCCLRSTATES, &psk) == -1) err(1, "DIOCCLRSTATES"); if ((opts & PF_OPT_QUIET) == 0) fprintf(stderr, "%d states cleared\n", psk.psk_killed); @@ -466,13 +466,13 @@ pfctl_kill_src_nodes(int dev, int opts) copy_satopfaddr(&psnk.psnk_src.addr.v.a.addr, resp[1]->ai_addr); - if (ioctl(dev, DIOCKILLSRCNODES, &psnk)) + if (ioctl(dev, DIOCKILLSRCNODES, &psnk) == -1) err(1, "DIOCKILLSRCNODES"); killed += psnk.psnk_killed; } freeaddrinfo(res[1]); } else { - if (ioctl(dev, DIOCKILLSRCNODES, &psnk)) + if (ioctl(dev, DIOCKILLSRCNODES, &psnk) == -1) err(1, "DIOCKILLSRCNODES"); killed += psnk.psnk_killed; } @@ -547,13 +547,13 @@ pfctl_net_kill_states(int dev, const char *iface, int opts, int rdomain) copy_satopfaddr(&psk.psk_src.addr.v.a.addr, resp[1]->ai_addr); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (ioctl(dev, DIOCKILLSTATES, &psk) == -1) err(1, "DIOCKILLSTATES"); killed += psk.psk_killed; } freeaddrinfo(res[1]); } else { - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (ioctl(dev, DIOCKILLSTATES, &psk) == -1) err(1, "DIOCKILLSTATES"); killed += psk.psk_killed; } @@ -586,7 +586,7 @@ pfctl_label_kill_states(int dev, const char *iface, int opts, int rdomain) psk.psk_rdomain = rdomain; - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (ioctl(dev, DIOCKILLSTATES, &psk) == -1) err(1, "DIOCKILLSTATES"); if ((opts & PF_OPT_QUIET) == 0) @@ -619,7 +619,7 @@ pfctl_id_kill_states(int dev, int opts) } psk.psk_pfcmp.id = htobe64(psk.psk_pfcmp.id); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (ioctl(dev, DIOCKILLSTATES, &psk) == -1) err(1, "DIOCKILLSTATES"); if ((opts & PF_OPT_QUIET) == 0) @@ -678,7 +678,7 @@ pfctl_key_kill_states(int dev, const char *iface, int opts, int rdomain) if (pfctl_parse_host(tokens[didx], &psk.psk_dst) == -1) errx(1, "invalid host: %s", tokens[didx]); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (ioctl(dev, DIOCKILLSTATES, &psk) == -1) err(1, "DIOCKILLSTATES"); if ((opts & PF_OPT_QUIET) == 0) @@ -813,7 +813,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, memcpy(pr.anchor, npath, sizeof(pr.anchor)); if (opts & PF_OPT_SHOWALL) { pr.rule.action = PF_PASS; - if (ioctl(dev, DIOCGETRULES, &pr)) { + if (ioctl(dev, DIOCGETRULES, &pr) == -1) { warn("DIOCGETRULES"); ret = -1; goto error; @@ -828,7 +828,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, pr.action = PF_GET_CLR_CNTR; pr.rule.action = PF_PASS; - if (ioctl(dev, DIOCGETRULES, &pr)) { + if (ioctl(dev, DIOCGETRULES, &pr) == -1) { warn("DIOCGETRULES"); ret = -1; goto error; @@ -847,7 +847,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, } for (; nr < mnr; ++nr) { pr.nr = nr; - if (ioctl(dev, DIOCGETRULE, &pr)) { + if (ioctl(dev, DIOCGETRULE, &pr) == -1) { warn("DIOCGETRULE"); ret = -1; goto error; @@ -918,7 +918,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, memset(&prs, 0, sizeof(prs)); memcpy(prs.path, npath, sizeof(prs.path)); - if (ioctl(dev, DIOCGETRULESETS, &prs)) { + if (ioctl(dev, DIOCGETRULESETS, &prs) == -1) { if (errno == EINVAL) fprintf(stderr, "Anchor '%s' " "not found.\n", anchorname); @@ -929,7 +929,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, for (nr = 0; nr < mnr; ++nr) { prs.nr = nr; - if (ioctl(dev, DIOCGETRULESET, &prs)) + if (ioctl(dev, DIOCGETRULESET, &prs) == -1) err(1, "DIOCGETRULESET"); INDENT(depth, !(opts & PF_OPT_VERBOSE)); printf("anchor \"%s\" all {\n", prs.name); @@ -966,7 +966,7 @@ pfctl_show_src_nodes(int dev, int opts) err(1, "realloc"); psn.psn_buf = inbuf = newinbuf; } - if (ioctl(dev, DIOCGETSRCNODES, &psn) < 0) { + if (ioctl(dev, DIOCGETSRCNODES, &psn) == -1) { warn("DIOCGETSRCNODES"); free(inbuf); return (-1); @@ -1011,7 +1011,7 @@ pfctl_show_states(int dev, const char *iface, int opts, long shownr) err(1, "realloc"); ps.ps_buf = inbuf = newinbuf; } - if (ioctl(dev, DIOCGETSTATES, &ps) < 0) { + if (ioctl(dev, DIOCGETSTATES, &ps) == -1) { warn("DIOCGETSTATES"); free(inbuf); return (-1); @@ -1049,11 +1049,11 @@ pfctl_show_status(int dev, int opts) struct pfctl_watermarks wats; struct pfioc_synflwats iocwats; - if (ioctl(dev, DIOCGETSTATUS, &status)) { + if (ioctl(dev, DIOCGETSTATUS, &status) == -1) { warn("DIOCGETSTATUS"); return (-1); } - if (ioctl(dev, DIOCGETSYNFLWATS, &iocwats)) { + if (ioctl(dev, DIOCGETSYNFLWATS, &iocwats) == -1) { warn("DIOCGETSYNFLWATS"); return (-1); } @@ -1076,7 +1076,7 @@ pfctl_show_timeouts(int dev, int opts) memset(&pt, 0, sizeof(pt)); for (i = 0; pf_timeouts[i].name; i++) { pt.timeout = pf_timeouts[i].timeout; - if (ioctl(dev, DIOCGETTIMEOUT, &pt)) + if (ioctl(dev, DIOCGETTIMEOUT, &pt) == -1) err(1, "DIOCGETTIMEOUT"); printf("%-20s %10d", pf_timeouts[i].name, pt.seconds); if (pf_timeouts[i].timeout >= PFTM_ADAPTIVE_START && @@ -1101,7 +1101,7 @@ pfctl_show_limits(int dev, int opts) memset(&pl, 0, sizeof(pl)); for (i = 0; pf_limits[i].name; i++) { pl.index = pf_limits[i].index; - if (ioctl(dev, DIOCGETLIMIT, &pl)) + if (ioctl(dev, DIOCGETLIMIT, &pl) == -1) err(1, "DIOCGETLIMIT"); printf("%-13s ", pf_limits[i].name); if (pl.limit == UINT_MAX) @@ -1246,7 +1246,7 @@ pfctl_load_queue(struct pfctl *pf, u_int32_t ticket, struct pfctl_qsitem *qi) q.ticket = ticket; bcopy(&qi->qs, &q.queue, sizeof(q.queue)); if ((pf->opts & PF_OPT_NOACTION) == 0) - if (ioctl(pf->dev, DIOCADDQUEUE, &q)) + if (ioctl(pf->dev, DIOCADDQUEUE, &q) == -1) err(1, "DIOCADDQUEUE"); if (pf->opts & PF_OPT_VERBOSE) print_queuespec(&qi->qs); @@ -1466,7 +1466,7 @@ pfctl_load_rule(struct pfctl *pf, char *path, struct pf_rule *r, int depth) if (r->anchor && strlcpy(pr.anchor_call, name, sizeof(pr.anchor_call)) >= sizeof(pr.anchor_call)) errx(1, "pfctl_load_rule: strlcpy"); - if (ioctl(pf->dev, DIOCADDRULE, &pr)) + if (ioctl(pf->dev, DIOCADDRULE, &pr) == -1) err(1, "DIOCADDRULE"); } @@ -1623,7 +1623,7 @@ pfctl_fopen(const char *name, const char *mode) fp = fopen(name, mode); if (fp == NULL) return (NULL); - if (fstat(fileno(fp), &st)) { + if (fstat(fileno(fp), &st) == -1) { fclose(fp); return (NULL); } @@ -1751,7 +1751,7 @@ pfctl_load_options(struct pfctl *pf) else { memset(&pl, 0, sizeof(pl)); pl.index = pf_limits[PF_LIMIT_STATES].index; - if (ioctl(dev, DIOCGETLIMIT, &pl)) + if (ioctl(dev, DIOCGETLIMIT, &pl) == -1) err(1, "DIOCGETLIMIT"); curlim = pl.limit; } @@ -1794,7 +1794,7 @@ pfctl_load_limit(struct pfctl *pf, unsigned int index, unsigned int limit) memset(&pl, 0, sizeof(pl)); pl.index = index; pl.limit = limit; - if (ioctl(pf->dev, DIOCSETLIMIT, &pl)) { + if (ioctl(pf->dev, DIOCSETLIMIT, &pl) == -1) { if (errno == EBUSY) warnx("Current pool size exceeds requested %s limit %u", pf_limits[index].name, limit); @@ -1839,7 +1839,7 @@ pfctl_load_timeout(struct pfctl *pf, unsigned int timeout, unsigned int seconds) memset(&pt, 0, sizeof(pt)); pt.timeout = timeout; pt.seconds = seconds; - if (ioctl(pf->dev, DIOCSETTIMEOUT, &pt)) { + if (ioctl(pf->dev, DIOCSETTIMEOUT, &pt) == -1) { warnx("DIOCSETTIMEOUT"); return (1); } @@ -1855,7 +1855,7 @@ pfctl_set_synflwats(struct pfctl *pf, u_int32_t lowat, u_int32_t hiwat) ps.hiwat = hiwat; ps.lowat = lowat; - if (ioctl(pf->dev, DIOCSETSYNFLWATS, &ps)) { + if (ioctl(pf->dev, DIOCSETSYNFLWATS, &ps) == -1) { warnx("Cannot set synflood detection watermarks"); return (1); } @@ -1982,7 +1982,7 @@ pfctl_load_logif(struct pfctl *pf, char *ifname) warnx("pfctl_load_logif: strlcpy"); return (1); } - if (ioctl(pf->dev, DIOCSETSTATUSIF, &pi)) { + if (ioctl(pf->dev, DIOCSETSTATUSIF, &pi) == -1) { warnx("DIOCSETSTATUSIF"); return (1); } @@ -2004,7 +2004,7 @@ pfctl_set_hostid(struct pfctl *pf, u_int32_t hostid) int pfctl_load_hostid(struct pfctl *pf, u_int32_t hostid) { - if (ioctl(dev, DIOCSETHOSTID, &hostid)) { + if (ioctl(dev, DIOCSETHOSTID, &hostid) == -1) { warnx("DIOCSETHOSTID"); return (1); } @@ -2014,7 +2014,7 @@ pfctl_load_hostid(struct pfctl *pf, u_int32_t hostid) int pfctl_load_reassembly(struct pfctl *pf, u_int32_t reassembly) { - if (ioctl(dev, DIOCSETREASS, &reassembly)) { + if (ioctl(dev, DIOCSETREASS, &reassembly) == -1) { warnx("DIOCSETREASS"); return (1); } @@ -2024,7 +2024,7 @@ pfctl_load_reassembly(struct pfctl *pf, u_int32_t reassembly) int pfctl_load_syncookies(struct pfctl *pf, u_int8_t val) { - if (ioctl(dev, DIOCSETSYNCOOKIES, &val)) { + if (ioctl(dev, DIOCSETSYNCOOKIES, &val) == -1) { warnx("DIOCSETSYNCOOKIES"); return (1); } @@ -2047,7 +2047,7 @@ pfctl_set_debug(struct pfctl *pf, char *d) pf->debug_set = 1; if ((pf->opts & PF_OPT_NOACTION) == 0) - if (ioctl(dev, DIOCSETDEBUG, &level)) + if (ioctl(dev, DIOCSETDEBUG, &level) == -1) err(1, "DIOCSETDEBUG"); if (pf->opts & PF_OPT_VERBOSE) @@ -2059,7 +2059,7 @@ pfctl_set_debug(struct pfctl *pf, char *d) int pfctl_load_debug(struct pfctl *pf, unsigned int level) { - if (ioctl(pf->dev, DIOCSETDEBUG, &level)) { + if (ioctl(pf->dev, DIOCSETDEBUG, &level) == -1) { warnx("DIOCSETDEBUG"); return (1); } @@ -2081,10 +2081,10 @@ pfctl_set_interface_flags(struct pfctl *pf, char *ifname, int flags, int how) if ((pf->opts & PF_OPT_NOACTION) == 0) { if (how == 0) { - if (ioctl(pf->dev, DIOCCLRIFFLAG, &pi)) + if (ioctl(pf->dev, DIOCCLRIFFLAG, &pi) == -1) err(1, "DIOCCLRIFFLAG"); } else { - if (ioctl(pf->dev, DIOCSETIFFLAG, &pi)) + if (ioctl(pf->dev, DIOCSETIFFLAG, &pi) == -1) err(1, "DIOCSETIFFLAG"); } } @@ -2099,7 +2099,7 @@ pfctl_debug(int dev, u_int32_t level, int opts) memset(&t, 0, sizeof(t)); t.pfrb_type = PFRB_TRANS; if (pfctl_trans(dev, &t, DIOCXBEGIN, 0) || - ioctl(dev, DIOCSETDEBUG, &level) || + ioctl(dev, DIOCSETDEBUG, &level) == -1|| pfctl_trans(dev, &t, DIOCXCOMMIT, 0)) err(1, "pfctl_debug ioctl"); @@ -2116,7 +2116,7 @@ pfctl_show_anchors(int dev, int opts, char *anchorname) memset(&pr, 0, sizeof(pr)); memcpy(pr.path, anchorname, sizeof(pr.path)); - if (ioctl(dev, DIOCGETRULESETS, &pr)) { + if (ioctl(dev, DIOCGETRULESETS, &pr) == -1) { if (errno == EINVAL) fprintf(stderr, "Anchor '%s' not found.\n", anchorname); @@ -2129,7 +2129,7 @@ pfctl_show_anchors(int dev, int opts, char *anchorname) char sub[PATH_MAX]; pr.nr = nr; - if (ioctl(dev, DIOCGETRULESET, &pr)) + if (ioctl(dev, DIOCGETRULESET, &pr) == -1) err(1, "DIOCGETRULESET"); if (!strcmp(pr.name, PF_RESERVED_ANCHOR)) continue; @@ -2186,7 +2186,7 @@ pfctl_state_store(int dev, const char *file) err(1, "realloc"); ps.ps_buf = inbuf = newinbuf; } - if (ioctl(dev, DIOCGETSTATES, &ps) < 0) + if (ioctl(dev, DIOCGETSTATES, &ps) == -1) err(1, "DIOCGETSTATES"); if (ps.ps_len + sizeof(struct pfioc_states) < len) @@ -2220,7 +2220,7 @@ pfctl_state_load(int dev, const char *file) err(1, "open: %s", file); while (fread(&ps.state, sizeof(ps.state), 1, f) == 1) { - if (ioctl(dev, DIOCADDSTATE, &ps) < 0) { + if (ioctl(dev, DIOCADDSTATE, &ps) == -1) { switch (errno) { case EEXIST: case EINVAL: diff --git a/sbin/pfctl/pfctl_optimize.c b/sbin/pfctl/pfctl_optimize.c index 3a0a334010e..9560f367898 100644 --- a/sbin/pfctl/pfctl_optimize.c +++ b/sbin/pfctl/pfctl_optimize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_optimize.c,v 1.41 2019/03/07 08:01:52 kn Exp $ */ +/* $OpenBSD: pfctl_optimize.c,v 1.42 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 2004 Mike Frantzen <frantzen@openbsd.org> @@ -869,7 +869,7 @@ load_feedback_profile(struct pfctl *pf, struct superblocks *superblocks) memset(&pr, 0, sizeof(pr)); pr.rule.action = PF_PASS; - if (ioctl(pf->dev, DIOCGETRULES, &pr)) { + if (ioctl(pf->dev, DIOCGETRULES, &pr) == -1) { warn("DIOCGETRULES"); return (1); } @@ -883,7 +883,7 @@ load_feedback_profile(struct pfctl *pf, struct superblocks *superblocks) return (1); } pr.nr = nr; - if (ioctl(pf->dev, DIOCGETRULE, &pr)) { + if (ioctl(pf->dev, DIOCGETRULE, &pr) == -1) { warn("DIOCGETRULES"); free(por); return (1); diff --git a/sbin/pfctl/pfctl_osfp.c b/sbin/pfctl/pfctl_osfp.c index 9c51d7462eb..79abfd1a7ab 100644 --- a/sbin/pfctl/pfctl_osfp.c +++ b/sbin/pfctl/pfctl_osfp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_osfp.c,v 1.25 2017/05/28 07:17:53 akfaew Exp $ */ +/* $OpenBSD: pfctl_osfp.c,v 1.26 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 2003 Mike Frantzen <frantzen@openbsd.org> @@ -259,7 +259,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"); } @@ -290,7 +290,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"); @@ -625,7 +625,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/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 351e7802d0f..c80f66f2587 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_parser.c,v 1.340 2019/03/30 02:45:14 kn Exp $ */ +/* $OpenBSD: pfctl_parser.c,v 1.341 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -1350,7 +1350,7 @@ ifa_load(void) struct ifaddrs *ifap, *ifa; struct node_host *n = NULL, *h = NULL; - if (getifaddrs(&ifap) < 0) + if (getifaddrs(&ifap) == -1) err(1, "getifaddrs"); for (ifa = ifap; ifa; ifa = ifa->ifa_next) { diff --git a/sbin/pfctl/pfctl_queue.c b/sbin/pfctl/pfctl_queue.c index 2b686defce7..399f0f75a1d 100644 --- a/sbin/pfctl/pfctl_queue.c +++ b/sbin/pfctl/pfctl_queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_queue.c,v 1.6 2017/07/19 12:51:30 mikeb Exp $ */ +/* $OpenBSD: pfctl_queue.c,v 1.7 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 2003 - 2013 Henning Brauer <henning@openbsd.org> @@ -123,7 +123,7 @@ pfctl_update_qstats(int dev) memset(&pq, 0, sizeof(pq)); memset(&pqs, 0, sizeof(pqs)); memset(&qstats, 0, sizeof(qstats)); - if (ioctl(dev, DIOCGETQUEUES, &pq)) { + if (ioctl(dev, DIOCGETQUEUES, &pq) == -1) { warn("DIOCGETQUEUES"); return (-1); } @@ -140,7 +140,7 @@ pfctl_update_qstats(int dev) pqs.ticket = pq.ticket; pqs.buf = &qstats.data; pqs.nbytes = sizeof(qstats.data); - if (ioctl(dev, DIOCGETQSTATS, &pqs)) { + if (ioctl(dev, DIOCGETQSTATS, &pqs) == -1) { warn("DIOCGETQSTATS"); return (-1); } diff --git a/sbin/pfctl/pfctl_radix.c b/sbin/pfctl/pfctl_radix.c index 632e3939121..408148a88da 100644 --- a/sbin/pfctl/pfctl_radix.c +++ b/sbin/pfctl/pfctl_radix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_radix.c,v 1.34 2017/08/11 22:30:38 benno Exp $ */ +/* $OpenBSD: pfctl_radix.c,v 1.35 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 2002 Cedric Berger @@ -65,7 +65,7 @@ pfr_clr_tables(struct pfr_table *filter, int *ndel, int flags) io.pfrio_flags = flags; if (filter != NULL) io.pfrio_table = *filter; - if (ioctl(dev, DIOCRCLRTABLES, &io)) + if (ioctl(dev, DIOCRCLRTABLES, &io) == -1) return (-1); if (ndel != NULL) *ndel = io.pfrio_ndel; @@ -86,7 +86,7 @@ pfr_add_tables(struct pfr_table *tbl, int size, int *nadd, int flags) io.pfrio_buffer = tbl; io.pfrio_esize = sizeof(*tbl); io.pfrio_size = size; - if (ioctl(dev, DIOCRADDTABLES, &io)) + if (ioctl(dev, DIOCRADDTABLES, &io) == -1) return (-1); if (nadd != NULL) *nadd = io.pfrio_nadd; @@ -107,7 +107,7 @@ pfr_del_tables(struct pfr_table *tbl, int size, int *ndel, int flags) io.pfrio_buffer = tbl; io.pfrio_esize = sizeof(*tbl); io.pfrio_size = size; - if (ioctl(dev, DIOCRDELTABLES, &io)) + if (ioctl(dev, DIOCRDELTABLES, &io) == -1) return (-1); if (ndel != NULL) *ndel = io.pfrio_ndel; @@ -131,7 +131,7 @@ pfr_get_tables(struct pfr_table *filter, struct pfr_table *tbl, int *size, io.pfrio_buffer = tbl; io.pfrio_esize = sizeof(*tbl); io.pfrio_size = *size; - if (ioctl(dev, DIOCRGETTABLES, &io)) + if (ioctl(dev, DIOCRGETTABLES, &io) == -1) return (-1); *size = io.pfrio_size; return (0); @@ -154,7 +154,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(dev, DIOCRGETTSTATS, &io)) + if (ioctl(dev, DIOCRGETTSTATS, &io) == -1) return (-1); *size = io.pfrio_size; return (0); @@ -172,7 +172,7 @@ pfr_clr_addrs(struct pfr_table *tbl, int *ndel, int flags) bzero(&io, sizeof io); io.pfrio_flags = flags; io.pfrio_table = *tbl; - if (ioctl(dev, DIOCRCLRADDRS, &io)) + if (ioctl(dev, DIOCRCLRADDRS, &io) == -1) return (-1); if (ndel != NULL) *ndel = io.pfrio_ndel; @@ -195,7 +195,7 @@ pfr_add_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size, io.pfrio_buffer = addr; io.pfrio_esize = sizeof(*addr); io.pfrio_size = size; - if (ioctl(dev, DIOCRADDADDRS, &io)) + if (ioctl(dev, DIOCRADDADDRS, &io) == -1) return (-1); if (nadd != NULL) *nadd = io.pfrio_nadd; @@ -218,7 +218,7 @@ pfr_del_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size, io.pfrio_buffer = addr; io.pfrio_esize = sizeof(*addr); io.pfrio_size = size; - if (ioctl(dev, DIOCRDELADDRS, &io)) + if (ioctl(dev, DIOCRDELADDRS, &io) == -1) return (-1); if (ndel != NULL) *ndel = io.pfrio_ndel; @@ -242,7 +242,7 @@ pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size, io.pfrio_esize = sizeof(*addr); io.pfrio_size = size; io.pfrio_size2 = (size2 != NULL) ? *size2 : 0; - if (ioctl(dev, DIOCRSETADDRS, &io)) + if (ioctl(dev, DIOCRSETADDRS, &io) == -1) return (-1); if (nadd != NULL) *nadd = io.pfrio_nadd; @@ -272,7 +272,7 @@ pfr_get_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int *size, io.pfrio_buffer = addr; io.pfrio_esize = sizeof(*addr); io.pfrio_size = *size; - if (ioctl(dev, DIOCRGETADDRS, &io)) + if (ioctl(dev, DIOCRGETADDRS, &io) == -1) return (-1); *size = io.pfrio_size; return (0); @@ -295,7 +295,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(dev, DIOCRGETASTATS, &io)) + if (ioctl(dev, DIOCRGETASTATS, &io) == -1) return (-1); *size = io.pfrio_size; return (0); @@ -315,7 +315,7 @@ pfr_clr_tstats(struct pfr_table *tbl, int size, int *nzero, int flags) io.pfrio_buffer = tbl; io.pfrio_esize = sizeof(*tbl); io.pfrio_size = size; - if (ioctl(dev, DIOCRCLRTSTATS, &io)) + if (ioctl(dev, DIOCRCLRTSTATS, &io) == -1) return (-1); if (nzero) *nzero = io.pfrio_nzero; @@ -338,7 +338,7 @@ pfr_tst_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size, io.pfrio_buffer = addr; io.pfrio_esize = sizeof(*addr); io.pfrio_size = size; - if (ioctl(dev, DIOCRTSTADDRS, &io)) + if (ioctl(dev, DIOCRTSTADDRS, &io) == -1) return (-1); if (nmatch) *nmatch = io.pfrio_nmatch; @@ -362,7 +362,7 @@ pfr_ina_define(struct pfr_table *tbl, struct pfr_addr *addr, int size, io.pfrio_esize = sizeof(*addr); io.pfrio_size = size; io.pfrio_ticket = ticket; - if (ioctl(dev, DIOCRINADEFINE, &io)) + if (ioctl(dev, DIOCRINADEFINE, &io) == -1) return (-1); if (nadd != NULL) *nadd = io.pfrio_nadd; @@ -392,7 +392,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(dev, DIOCIGETIFACES, &io)) + if (ioctl(dev, DIOCIGETIFACES, &io) == -1) return (-1); *size = io.pfiio_size; return (0); diff --git a/sbin/pflogd/pflogd.c b/sbin/pflogd/pflogd.c index e855bab910f..b8a8c8ae544 100644 --- a/sbin/pflogd/pflogd.c +++ b/sbin/pflogd/pflogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pflogd.c,v 1.59 2018/08/26 18:24:46 brynet Exp $ */ +/* $OpenBSD: pflogd.c,v 1.60 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 2001 Theo de Raadt @@ -213,7 +213,7 @@ init_pcap(void) set_pcap_filter(); /* lock */ - if (ioctl(pcap_fileno(hpcap), BIOCLOCK) < 0) { + if (ioctl(pcap_fileno(hpcap), BIOCLOCK) == -1) { logmsg(LOG_ERR, "BIOCLOCK: %s", strerror(errno)); return (-1); } diff --git a/sbin/pflogd/privsep.c b/sbin/pflogd/privsep.c index c0549727356..36cc0395f1d 100644 --- a/sbin/pflogd/privsep.c +++ b/sbin/pflogd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.32 2018/08/26 18:26:51 brynet Exp $ */ +/* $OpenBSD: privsep.c,v 1.33 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (c) 2003 Can Erkin Acar @@ -99,7 +99,7 @@ priv_init(int Pflag, int argc, char *argv[]) err(1, "socketpair() failed"); child_pid = fork(); - if (child_pid < 0) + if (child_pid == -1) err(1, "fork() failed"); if (!child_pid) { @@ -200,7 +200,7 @@ BROKEN if (pledge("stdio rpath wpath cpath sendfd proc bpf", NULL) == -1) 0600); olderrno = errno; send_fd(socks[0], bpfd); - if (bpfd < 0) + if (bpfd == -1) logmsg(LOG_NOTICE, "[priv]: failed to open %s: %s", filename, strerror(olderrno)); diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index d8fb0812ce7..b1cb3febd2d 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.235 2019/03/19 23:27:49 tedu Exp $ */ +/* $OpenBSD: ping.c,v 1.236 2019/06/28 13:32:45 deraadt Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -495,10 +495,10 @@ main(int argc, char *argv[]) if (!v6flag && IN_MULTICAST(ntohl(dst4.sin_addr.s_addr))) { if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, - &from4.sin_addr, sizeof(from4.sin_addr)) < 0) + &from4.sin_addr, sizeof(from4.sin_addr)) == -1) err(1, "setsockopt IP_MULTICAST_IF"); } else { - if (bind(s, from, from->sa_len) < 0) + if (bind(s, from, from->sa_len) == -1) err(1, "bind"); } } else if (options & F_VERBOSE) { @@ -509,7 +509,7 @@ main(int argc, char *argv[]) int dummy; socklen_t len = dst->sa_len; - if ((dummy = socket(dst->sa_family, SOCK_DGRAM, 0)) < 0) + if ((dummy = socket(dst->sa_family, SOCK_DGRAM, 0)) == -1) err(1, "UDP socket"); memcpy(from, dst, dst->sa_len); @@ -536,23 +536,23 @@ main(int argc, char *argv[]) if ((moptions & MULTICAST_NOLOOP) && setsockopt(dummy, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, - sizeof(loop)) < 0) + sizeof(loop)) == -1) err(1, "setsockopt IP_MULTICAST_LOOP"); if ((moptions & MULTICAST_TTL) && setsockopt(dummy, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, - sizeof(ttl)) < 0) + sizeof(ttl)) == -1) err(1, "setsockopt IP_MULTICAST_TTL"); } if (rtableid > 0 && setsockopt(dummy, SOL_SOCKET, SO_RTABLE, &rtableid, - sizeof(rtableid)) < 0) + sizeof(rtableid)) == -1) err(1, "setsockopt(SO_RTABLE)"); - if (connect(dummy, from, len) < 0) + if (connect(dummy, from, len) == -1) err(1, "UDP connect"); - if (getsockname(dummy, from, &len) < 0) + if (getsockname(dummy, from, &len) == -1) err(1, "getsockname"); close(dummy); @@ -593,10 +593,10 @@ main(int argc, char *argv[]) * size of both the send and receive buffers... */ maxsizelen = sizeof maxsize; - if (getsockopt(s, SOL_SOCKET, SO_SNDBUF, &maxsize, &maxsizelen) < 0) + if (getsockopt(s, SOL_SOCKET, SO_SNDBUF, &maxsize, &maxsizelen) == -1) err(1, "getsockopt"); if (maxsize < packlen && - setsockopt(s, SOL_SOCKET, SO_SNDBUF, &packlen, sizeof(maxsize)) < 0) + setsockopt(s, SOL_SOCKET, SO_SNDBUF, &packlen, sizeof(maxsize)) == -1) err(1, "setsockopt"); /* @@ -606,7 +606,7 @@ main(int argc, char *argv[]) * /etc/ethers. */ while (setsockopt(s, SOL_SOCKET, SO_RCVBUF, - &bufspace, sizeof(bufspace)) < 0) { + &bufspace, sizeof(bufspace)) == -1) { if ((bufspace -= 1024) <= 0) err(1, "Cannot set the receive buffer size"); } @@ -641,7 +641,7 @@ main(int argc, char *argv[]) if ((moptions & MULTICAST_NOLOOP) && setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, - &loop, sizeof(loop)) < 0) + &loop, sizeof(loop)) == -1) err(1, "setsockopt IPV6_MULTICAST_LOOP"); optval = IPV6_DEFHLIM; @@ -664,7 +664,7 @@ main(int argc, char *argv[]) } if (setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, - &filt, sizeof(filt)) < 0) + &filt, sizeof(filt)) == -1) err(1, "setsockopt(ICMP6_FILTER)"); if (hoplimit != -1) { @@ -683,23 +683,23 @@ main(int argc, char *argv[]) if (options & F_TOS) { optval = tos; if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, - &optval, sizeof(optval)) < 0) + &optval, sizeof(optval)) == -1) err(1, "setsockopt(IPV6_TCLASS)"); } if (df) { optval = 1; if (setsockopt(s, IPPROTO_IPV6, IPV6_DONTFRAG, - &optval, sizeof(optval)) < 0) + &optval, sizeof(optval)) == -1) err(1, "setsockopt(IPV6_DONTFRAG)"); } optval = 1; if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, - &optval, sizeof(optval)) < 0) + &optval, sizeof(optval)) == -1) err(1, "setsockopt(IPV6_RECVPKTINFO)"); if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, - &optval, sizeof(optval)) < 0) + &optval, sizeof(optval)) == -1) err(1, "setsockopt(IPV6_RECVHOPLIMIT)"); } else { u_char loop = 0; @@ -719,7 +719,7 @@ main(int argc, char *argv[]) struct ip *ip = (struct ip *)outpackhdr; if (setsockopt(s, IPPROTO_IP, IP_HDRINCL, - &optval, sizeof(optval)) < 0) + &optval, sizeof(optval)) == -1) err(1, "setsockopt(IP_HDRINCL)"); ip->ip_v = IPVERSION; ip->ip_hl = sizeof(struct ip) >> 2; @@ -745,17 +745,17 @@ main(int argc, char *argv[]) rspace[IPOPT_OLEN] = sizeof(rspace)-1; rspace[IPOPT_OFFSET] = IPOPT_MINOFF; if (setsockopt(s, IPPROTO_IP, IP_OPTIONS, - rspace, sizeof(rspace)) < 0) + rspace, sizeof(rspace)) == -1) err(1, "record route"); } if ((moptions & MULTICAST_NOLOOP) && setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, - &loop, sizeof(loop)) < 0) + &loop, sizeof(loop)) == -1) err(1, "setsockopt IP_MULTICAST_LOOP"); if ((moptions & MULTICAST_TTL) && setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, - &ttl, sizeof(ttl)) < 0) + &ttl, sizeof(ttl)) == -1) err(1, "setsockopt IP_MULTICAST_TTL"); } @@ -875,7 +875,7 @@ main(int argc, char *argv[]) m.msg_controllen = sizeof(cmsgbuf.buf); cc = recvmsg(s, &m, 0); - if (cc < 0) { + if (cc == -1) { if (errno != EINTR) { warn("recvmsg"); sleep(1); @@ -1116,8 +1116,8 @@ pinger(int s) i = sendmsg(s, &smsghdr, 0); - if (i < 0 || i != cc) { - if (i < 0) + if (i == -1 || i != cc) { + if (i == -1) warn("sendmsg"); printf("ping: wrote %s %d chars, ret=%d\n", hostname, cc, i); } diff --git a/sbin/quotacheck/quotacheck.c b/sbin/quotacheck/quotacheck.c index 11a388dd738..427b1282293 100644 --- a/sbin/quotacheck/quotacheck.c +++ b/sbin/quotacheck/quotacheck.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quotacheck.c,v 1.40 2018/09/26 03:03:39 deraadt Exp $ */ +/* $OpenBSD: quotacheck.c,v 1.41 2019/06/28 13:32:45 deraadt Exp $ */ /* $NetBSD: quotacheck.c,v 1.12 1996/03/30 22:34:25 mark Exp $ */ /* @@ -276,7 +276,7 @@ chkquota(const char *vfstype, const char *fsname, const char *mntpt, warn("fork"); return 1; case 0: /* child */ - if ((fi = opendev(fsname, O_RDONLY, 0, NULL)) < 0) + if ((fi = opendev(fsname, O_RDONLY, 0, NULL)) == -1) err(1, "%s", fsname); sync(); for (i = 0; sblock_try[i] != -1; i++) { @@ -377,7 +377,7 @@ chkquota(const char *vfstype, const char *fsname, const char *mntpt, *pidp = pid; return 0; } - if (waitpid(pid, &status, 0) < 0) { + if (waitpid(pid, &status, 0) == -1) { warn("waitpid"); return 1; } @@ -428,7 +428,7 @@ update(const char *fsname, const char *quotafile, int type) (void) fclose(qfo); return (1); } - if (quotactl(fsname, QCMD(Q_SYNC, type), 0, (caddr_t)0) < 0 && + if (quotactl(fsname, QCMD(Q_SYNC, type), 0, (caddr_t)0) == -1 && errno == EOPNOTSUPP && !warned && (flags&(CHECK_DEBUG|CHECK_VERBOSE))) { warned++; diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 174185615e2..1a25e7342c1 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dirs.c,v 1.41 2015/08/25 04:18:43 guenther Exp $ */ +/* $OpenBSD: dirs.c,v 1.42 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $ */ /* @@ -643,7 +643,7 @@ genliteraldir(char *name, ino_t ino) if (itp == NULL) panic("Cannot find directory inode %llu named %s\n", (unsigned long long)ino, name); - if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) { + if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) == -1) { warn("%s: cannot create file", name); return (FAIL); } diff --git a/sbin/restore/symtab.c b/sbin/restore/symtab.c index e7322dafb68..39d2b14a79e 100644 --- a/sbin/restore/symtab.c +++ b/sbin/restore/symtab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: symtab.c,v 1.22 2015/01/16 06:40:00 deraadt Exp $ */ +/* $OpenBSD: symtab.c,v 1.23 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: symtab.c,v 1.10 1997/03/19 08:42:54 lukem Exp $ */ /* @@ -536,11 +536,11 @@ initsymtable(char *filename) ep->e_flags |= NEW; return; } - if ((fd = open(filename, O_RDONLY, 0)) < 0) { + if ((fd = open(filename, O_RDONLY, 0)) == -1) { warn("open"); panic("cannot open symbol table file %s\n", filename); } - if (fstat(fd, &stbuf) < 0) { + if (fstat(fd, &stbuf) == -1) { warn("stat"); panic("cannot stat symbol table file %s\n", filename); } @@ -548,8 +548,8 @@ initsymtable(char *filename) base = calloc(tblsize, sizeof(char)); if (base == NULL) panic("cannot allocate space for symbol table\n"); - if (read(fd, base, tblsize) < 0 || - read(fd, &hdr, sizeof(struct symtableheader)) < 0) { + if (read(fd, base, tblsize) == -1 || + read(fd, &hdr, sizeof(struct symtableheader)) == -1) { warn("read"); panic("cannot read symbol table file %s\n", filename); } diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c index 8c0708adca9..324ec6378d8 100644 --- a/sbin/restore/tape.c +++ b/sbin/restore/tape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tape.c,v 1.50 2018/04/27 06:46:04 guenther Exp $ */ +/* $OpenBSD: tape.c,v 1.51 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: tape.c,v 1.26 1997/04/15 07:12:25 lukem Exp $ */ /* @@ -202,7 +202,7 @@ setup(void) mt = 0; else mt = open(magtape, O_RDONLY); - if (mt < 0) + if (mt == -1) err(1, "%s", magtape); volno = 1; setdumpnum(); @@ -234,7 +234,7 @@ setup(void) printdumpinfo(); dumptime = (time_t)spcl.c_ddate; dumpdate = (time_t)spcl.c_date; - if (stat(".", &stbuf) < 0) + if (stat(".", &stbuf) == -1) err(1, "cannot stat ."); if (stbuf.st_blksize > 0 && stbuf.st_blksize < TP_BSIZE ) fssize = TP_BSIZE; @@ -478,7 +478,7 @@ setdumpnum(void) rmtioctl(MTFSF, dumpnum - 1); else #endif - if (ioctl(mt, MTIOCTOP, (char *)&tcom) < 0) + if (ioctl(mt, MTIOCTOP, (char *)&tcom) == -1) warn("ioctl MTFSF"); } @@ -576,7 +576,7 @@ extractfile(char *name) skipfile(); return (GOOD); } - if (mknod(name, mode, (int)curfile.rdev) < 0) { + if (mknod(name, mode, (int)curfile.rdev) == -1) { warn("%s: cannot create special file", name); skipfile(); return (FAIL); @@ -596,7 +596,7 @@ extractfile(char *name) skipfile(); return (GOOD); } - if (mkfifo(name, mode) < 0) { + if (mkfifo(name, mode) == -1) { warn("%s: cannot create fifo", name); skipfile(); return (FAIL); @@ -617,7 +617,7 @@ extractfile(char *name) return (GOOD); } if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, - 0666)) < 0) { + 0666)) == -1) { warn("%s: cannot create file", name); skipfile(); return (FAIL); diff --git a/sbin/restore/utilities.c b/sbin/restore/utilities.c index 5f499464345..880086ea98c 100644 --- a/sbin/restore/utilities.c +++ b/sbin/restore/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.19 2015/11/07 21:52:55 guenther Exp $ */ +/* $OpenBSD: utilities.c,v 1.20 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: utilities.c,v 1.11 1997/03/19 08:42:56 lukem Exp $ */ /* @@ -119,7 +119,7 @@ gentempname(struct entry *ep) void renameit(char *from, char *to) { - if (!Nflag && rename(from, to) < 0) { + if (!Nflag && rename(from, to) == -1) { warn("cannot rename %s to %s", from, to); return; } @@ -137,7 +137,7 @@ newnode(struct entry *np) if (np->e_type != NODE) badentry(np, "newnode: not a node"); cp = myname(np); - if (!Nflag && mkdir(cp, 0777) < 0) { + if (!Nflag && mkdir(cp, 0777) == -1) { np->e_flags |= EXISTED; warn("%s", cp); return; @@ -160,7 +160,7 @@ removenode(struct entry *ep) ep->e_flags |= REMOVED; ep->e_flags &= ~TMPNAME; cp = myname(ep); - if (!Nflag && rmdir(cp) < 0) { + if (!Nflag && rmdir(cp) == -1) { warn("%s", cp); return; } @@ -180,7 +180,7 @@ removeleaf(struct entry *ep) ep->e_flags |= REMOVED; ep->e_flags &= ~TMPNAME; cp = myname(ep); - if (!Nflag && unlink(cp) < 0) { + if (!Nflag && unlink(cp) == -1) { warn("%s", cp); return; } @@ -195,14 +195,14 @@ linkit(char *existing, char *new, int type) { if (type == SYMLINK) { - if (!Nflag && symlink(existing, new) < 0) { + if (!Nflag && symlink(existing, new) == -1) { warn("cannot create symbolic link %s->%s", new, existing); return (FAIL); } } else if (type == HARDLINK) { if (!Nflag && linkat(AT_FDCWD, existing, AT_FDCWD, new, 0) - < 0) { + == -1) { warn("cannot create hard link %s->%s", new, existing); return (FAIL); diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index b5db8daddff..515c6c6052a 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -1,4 +1,4 @@ -/* $OpenBSD: savecore.c,v 1.61 2019/02/05 02:17:32 deraadt Exp $ */ +/* $OpenBSD: savecore.c,v 1.62 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */ /*- @@ -133,7 +133,7 @@ main(int argc, char *argv[]) /* Increase our data size to the max if we can. */ if (getrlimit(RLIMIT_DATA, &rl) == 0) { rl.rlim_cur = rl.rlim_max; - if (setrlimit(RLIMIT_DATA, &rl) < 0) + if (setrlimit(RLIMIT_DATA, &rl) == -1) syslog(LOG_WARNING, "can't set rlimit data size: %m"); } @@ -538,7 +538,7 @@ err2: syslog(LOG_WARNING, exit(1); } } - if (nr < 0) { + if (nr == -1) { syslog(LOG_ERR, "%s: %s", kernel ? kernel : _PATH_UNIX, strerror(errno)); syslog(LOG_WARNING, @@ -639,12 +639,12 @@ check_space(void) int fd; tkernel = kernel ? kernel : _PATH_UNIX; - if (stat(tkernel, &st) < 0) { + if (stat(tkernel, &st) == -1) { syslog(LOG_ERR, "%s: %m", tkernel); exit(1); } kernelsize = st.st_blocks * S_BLKSIZE; - if ((fd = open(dirn, O_RDONLY, 0)) < 0 || fstatfs(fd, &fsbuf) < 0) { + if ((fd = open(dirn, O_RDONLY, 0)) == -1 || fstatfs(fd, &fsbuf) == -1) { syslog(LOG_ERR, "%s: %m", dirn); exit(1); } diff --git a/sbin/scan_ffs/scan_ffs.c b/sbin/scan_ffs/scan_ffs.c index cb80daead4f..d1b673c4dca 100644 --- a/sbin/scan_ffs/scan_ffs.c +++ b/sbin/scan_ffs/scan_ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scan_ffs.c,v 1.22 2018/04/26 15:55:14 guenther Exp $ */ +/* $OpenBSD: scan_ffs.c,v 1.23 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 1998 Niklas Hallqvist, Tobias Weingartner @@ -61,9 +61,9 @@ ufsscan(int fd, daddr_t beg, daddr_t end, int flags) for (blk = beg; blk <= ((end<0)?blk:end); blk += (SBCOUNT*SBSIZE/512)){ memset(buf, 0, SBSIZE * SBCOUNT); - if (lseek(fd, (off_t)blk * 512, SEEK_SET) < 0) + if (lseek(fd, (off_t)blk * 512, SEEK_SET) == -1) err(1, "lseek"); - if (read(fd, buf, SBSIZE * SBCOUNT) < 0) + if (read(fd, buf, SBSIZE * SBCOUNT) == -1) err(1, "read"); for (n = 0; n < (SBSIZE * SBCOUNT); n += 512){ @@ -174,7 +174,7 @@ main(int argc, char *argv[]) usage(); fd = opendev(argv[0], O_RDONLY, OPENDEV_PART, NULL); - if (fd < 0) + if (fd == -1) err(1, "%s", argv[0]); if (pledge("stdio", NULL) == -1) diff --git a/sbin/slaacd/frontend.c b/sbin/slaacd/frontend.c index 408fd797a83..4f47ff90271 100644 --- a/sbin/slaacd/frontend.c +++ b/sbin/slaacd/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.26 2019/03/15 16:45:33 florian Exp $ */ +/* $OpenBSD: frontend.c,v 1.27 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -142,7 +142,7 @@ frontend(int debug, int verbose) setproctitle("%s", log_procnames[slaacd_process]); log_procinit(log_procnames[slaacd_process]); - 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 (setgroups(1, &pw->pw_gid) || @@ -466,7 +466,7 @@ get_flags(char *if_name) struct ifreq ifr; (void) strlcpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name)); - if (ioctl(ioctlsock, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) + if (ioctl(ioctlsock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) fatal("SIOCGIFFLAGS"); return ifr.ifr_flags; } @@ -477,7 +477,7 @@ get_xflags(char *if_name) struct ifreq ifr; (void) strlcpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name)); - if (ioctl(ioctlsock, SIOCGIFXFLAGS, (caddr_t)&ifr) < 0) + if (ioctl(ioctlsock, SIOCGIFXFLAGS, (caddr_t)&ifr) == -1) fatal("SIOCGIFXFLAGS"); return ifr.ifr_flags; } @@ -560,7 +560,7 @@ update_autoconf_addresses(uint32_t if_index, char* if_name) (void) strlcpy(ifr6.ifr_name, if_name, sizeof(ifr6.ifr_name)); memcpy(&ifr6.ifr_addr, sin6, sizeof(ifr6.ifr_addr)); - if (ioctl(ioctlsock, SIOCGIFAFLAG_IN6, (caddr_t)&ifr6) < 0) { + if (ioctl(ioctlsock, SIOCGIFAFLAG_IN6, (caddr_t)&ifr6) == -1) { log_warn("SIOCGIFAFLAG_IN6"); continue; } @@ -576,7 +576,7 @@ update_autoconf_addresses(uint32_t if_index, char* if_name) (void) strlcpy(ifr6.ifr_name, if_name, 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) { log_warn("SIOCGIFNETMASK_IN6"); continue; } @@ -589,8 +589,7 @@ update_autoconf_addresses(uint32_t if_index, char* if_name) memcpy(&ifr6.ifr_addr, sin6, sizeof(ifr6.ifr_addr)); lifetime = &ifr6.ifr_ifru.ifru_lifetime; - if (ioctl(ioctlsock, SIOCGIFALIFETIME_IN6, (caddr_t)&ifr6) < - 0) { + if (ioctl(ioctlsock, SIOCGIFALIFETIME_IN6, (caddr_t)&ifr6) == -1) { log_warn("SIOCGIFALIFETIME_IN6"); continue; } @@ -799,7 +798,7 @@ handle_route_message(struct rt_msghdr *rtm, struct sockaddr **rti_info) memcpy(&ifr6.ifr_addr, sin6, sizeof(ifr6.ifr_addr)); if (ioctl(ioctlsock, SIOCGIFAFLAG_IN6, (caddr_t)&ifr6) - < 0) { + == -1) { log_warn("SIOCGIFAFLAG_IN6"); break; } @@ -990,7 +989,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; } diff --git a/sbin/slaacd/slaacd.c b/sbin/slaacd/slaacd.c index 4d143b61edc..5d4eda9421f 100644 --- a/sbin/slaacd/slaacd.c +++ b/sbin/slaacd/slaacd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacd.c,v 1.37 2019/03/31 03:36:18 yasuoka Exp $ */ +/* $OpenBSD: slaacd.c,v 1.38 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -201,7 +201,7 @@ main(int argc, char *argv[]) log_procinit(log_procnames[slaacd_process]); if ((routesock = socket(AF_ROUTE, SOCK_RAW | SOCK_CLOEXEC | - SOCK_NONBLOCK, AF_INET6)) < 0) + SOCK_NONBLOCK, AF_INET6)) == -1) fatal("route socket"); shutdown(SHUT_RD, routesock); @@ -239,19 +239,19 @@ main(int argc, char *argv[]) if (main_imsg_send_ipc_sockets(&iev_frontend->ibuf, &iev_engine->ibuf)) fatal("could not establish imsg links"); - if ((ioctl_sock = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0)) < 0) + if ((ioctl_sock = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == -1) fatal("socket"); 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"); /* only router advertisements */ @@ -262,14 +262,14 @@ 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) | ROUTE_FILTER(RTM_PROPOSAL) | ROUTE_FILTER(RTM_DELETE) | ROUTE_FILTER(RTM_CHGADDRATTR); if (setsockopt(frontend_routesock, AF_ROUTE, ROUTE_MSGFILTER, - &rtfilter, sizeof(rtfilter)) < 0) + &rtfilter, sizeof(rtfilter)) == -1) fatal("setsockopt(ROUTE_MSGFILTER)"); #ifndef SMALL @@ -754,7 +754,7 @@ configure_interface(struct imsg_configure_address *address) log_debug("%s: %s", __func__, if_name); - if (ioctl(ioctl_sock, SIOCAIFADDR_IN6, &in6_addreq) < 0) + if (ioctl(ioctl_sock, SIOCAIFADDR_IN6, &in6_addreq) == -1) fatal("SIOCAIFADDR_IN6"); if (address->mtu) { @@ -765,7 +765,7 @@ configure_interface(struct imsg_configure_address *address) ifr.ifr_mtu = address->mtu; log_debug("Setting MTU to %d", ifr.ifr_mtu); - if (ioctl(ioctl_sock, SIOCSIFMTU, &ifr) < 0) + if (ioctl(ioctl_sock, SIOCSIFMTU, &ifr) == -1) log_warn("failed to set MTU"); } } diff --git a/sbin/swapctl/swapctl.c b/sbin/swapctl/swapctl.c index 2511419e961..05ff007bac0 100644 --- a/sbin/swapctl/swapctl.c +++ b/sbin/swapctl/swapctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swapctl.c,v 1.23 2016/03/17 19:40:43 krw Exp $ */ +/* $OpenBSD: swapctl.c,v 1.24 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: swapctl.c,v 1.9 1998/07/26 20:23:15 mycroft Exp $ */ /* @@ -300,7 +300,7 @@ void change_priority(char *path) { - if (swapctl(SWAP_CTL, path, pri) < 0) + if (swapctl(SWAP_CTL, path, pri) == -1) warn("%s", path); } @@ -311,7 +311,7 @@ void add_swap(char *path) { - if (swapctl(SWAP_ON, path, pri) < 0) + if (swapctl(SWAP_ON, path, pri) == -1) if (errno != EBUSY) err(1, "%s", path); } @@ -323,7 +323,7 @@ void del_swap(char *path) { - if (swapctl(SWAP_OFF, path, pri) < 0) + if (swapctl(SWAP_OFF, path, pri) == -1) err(1, "%s", path); } @@ -402,7 +402,7 @@ do_fstab(void) (char *)NULL); err(1, "execl"); } - while (waitpid(pid, &status, 0) < 0) + while (waitpid(pid, &status, 0) == -1) if (errno != EINTR) err(1, "waitpid"); if (status != 0) { @@ -422,7 +422,7 @@ do_fstab(void) if (strncmp("/dev/", spec, 5) != 0) continue; } - if (stat(spec, &st) < 0) { + if (stat(spec, &st) == -1) { warn("%s", spec); continue; } @@ -437,7 +437,7 @@ do_fstab(void) continue; } - if (swapctl(SWAP_ON, spec, (int)priority) < 0) { + if (swapctl(SWAP_ON, spec, (int)priority) == -1) { if (errno != EBUSY) warn("%s", spec); } else { diff --git a/sbin/swapctl/swaplist.c b/sbin/swapctl/swaplist.c index 1f915bd0f2b..66f093209f5 100644 --- a/sbin/swapctl/swaplist.c +++ b/sbin/swapctl/swaplist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swaplist.c,v 1.12 2015/12/10 17:27:00 mmcc Exp $ */ +/* $OpenBSD: swaplist.c,v 1.13 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: swaplist.c,v 1.8 1998/10/08 10:00:31 mrg Exp $ */ /* @@ -62,7 +62,7 @@ list_swap(int pri, int kflag, int pflag, int dolong) if (sep == NULL) err(1, "calloc"); rnswap = swapctl(SWAP_STATS, (void *)sep, nswap); - if (rnswap < 0) + if (rnswap == -1) err(1, "SWAP_STATS"); if (nswap != rnswap) warnx("SWAP_STATS different to SWAP_NSWAP (%d != %d)", diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 0bb29fc2266..4db2f2b661d 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.243 2019/06/16 09:30:15 mestre Exp $ */ +/* $OpenBSD: sysctl.c,v 1.244 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -1228,7 +1228,7 @@ vfsinit(void) mib[1] = VFS_GENERIC; mib[2] = VFS_MAXTYPENUM; buflen = 4; - if (sysctl(mib, 3, &maxtypenum, &buflen, NULL, 0) < 0) + if (sysctl(mib, 3, &maxtypenum, &buflen, NULL, 0) == -1) return; /* * We need to do 0..maxtypenum so add one, and then we offset them @@ -1250,7 +1250,7 @@ vfsinit(void) buflen = sizeof vfc; for (loc = lastused, cnt = 1; cnt < maxtypenum; cnt++) { mib[3] = cnt - 1; - if (sysctl(mib, 4, &vfc, &buflen, NULL, 0) < 0) { + if (sysctl(mib, 4, &vfc, &buflen, NULL, 0) == -1) { if (errno == EOPNOTSUPP) continue; warn("vfsinit"); @@ -1309,7 +1309,7 @@ sysctl_vfsgen(char *string, char **bufpp, int mib[], int flags, int *typep) mib[2] = VFS_CONF; mib[3] = indx; size = sizeof vfc; - if (sysctl(mib, 4, &vfc, &size, NULL, 0) < 0) { + if (sysctl(mib, 4, &vfc, &size, NULL, 0) == -1) { if (errno != EOPNOTSUPP) warn("vfs print"); return -1; @@ -1767,7 +1767,7 @@ sysctl_nchstats(char *string, char **bufpp, int mib[], int flags, int *typep) } if (keepvalue == 0) { size = sizeof(struct nchstats); - if (sysctl(mib, 2, &nch, &size, NULL, 0) < 0) + if (sysctl(mib, 2, &nch, &size, NULL, 0) == -1) return (-1); keepvalue = 1; } @@ -1863,7 +1863,7 @@ sysctl_forkstat(char *string, char **bufpp, int mib[], int flags, int *typep) } if (keepvalue == 0) { size = sizeof(struct forkstat); - if (sysctl(mib, 2, &fks, &size, NULL, 0) < 0) + if (sysctl(mib, 2, &fks, &size, NULL, 0) == -1) return (-1); keepvalue = 1; } @@ -1923,7 +1923,7 @@ sysctl_malloc(char *string, char **bufpp, int mib[], int flags, int *typep) stor = mib[2]; mib[2] = KERN_MALLOC_BUCKETS; buf = bufp; - if (sysctl(mib, 3, buf, &size, NULL, 0) < 0) + if (sysctl(mib, 3, buf, &size, NULL, 0) == -1) return (-1); mib[2] = stor; for (stor = 0, i = 0; i < size; i++) @@ -1953,7 +1953,7 @@ sysctl_malloc(char *string, char **bufpp, int mib[], int flags, int *typep) stor = mib[2]; mib[2] = KERN_MALLOC_KMEMNAMES; buf = bufp; - if (sysctl(mib, 3, buf, &size, NULL, 0) < 0) + if (sysctl(mib, 3, buf, &size, NULL, 0) == -1) return (-1); mib[2] = stor; if ((name = strsep(bufpp, ".")) == NULL) { @@ -2034,23 +2034,23 @@ sysctl_chipset(char *string, char **bufpp, int mib[], int flags, int *typep) case CPU_CHIPSET_PORTS: case CPU_CHIPSET_HAE_MASK: len = sizeof(void *); - if (sysctl(mib, 3, &q, &len, NULL, 0) < 0) + if (sysctl(mib, 3, &q, &len, NULL, 0) == -1) goto done; printf("%p", q); break; case CPU_CHIPSET_BWX: len = sizeof(int); - if (sysctl(mib, 3, &bwx, &len, NULL, 0) < 0) + if (sysctl(mib, 3, &bwx, &len, NULL, 0) == -1) goto done; printf("%d", bwx); break; case CPU_CHIPSET_TYPE: - if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0) + if (sysctl(mib, 3, NULL, &len, NULL, 0) == -1) goto done; p = malloc(len + 1); if (p == NULL) goto done; - if (sysctl(mib, 3, p, &len, NULL, 0) < 0) { + if (sysctl(mib, 3, p, &len, NULL, 0) == -1) { free(p); goto done; } diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c index 9f6d1323f97..c2eced0e384 100644 --- a/sbin/umount/umount.c +++ b/sbin/umount/umount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umount.c,v 1.28 2018/01/05 08:13:31 mpi Exp $ */ +/* $OpenBSD: umount.c,v 1.29 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: umount.c,v 1.16 1996/05/11 14:13:55 mycroft Exp $ */ /*- @@ -214,7 +214,7 @@ umountfs(char *oname) if (verbose) printf("%s: unmount from %s\n", name, mntpt); - if (unmount(mntpt, fflag) < 0) { + if (unmount(mntpt, fflag) == -1) { warn("%s", mntpt); return (1); } diff --git a/sbin/unwind/frontend.c b/sbin/unwind/frontend.c index fffb6fa3859..c108ade519a 100644 --- a/sbin/unwind/frontend.c +++ b/sbin/unwind/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.21 2019/05/14 14:51:31 florian Exp $ */ +/* $OpenBSD: frontend.c,v 1.22 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -648,7 +648,7 @@ udp_receive(int fd, short events, void *arg) uint8_t *queryp; char *str_from, *str, buf[1024], *bufp; - if ((len = recvmsg(fd, &udpev->rcvmhdr, 0)) < 0) { + if ((len = recvmsg(fd, &udpev->rcvmhdr, 0)) == -1) { log_warn("recvmsg"); return; } diff --git a/sbin/unwind/unwind.c b/sbin/unwind/unwind.c index 6d381d99961..4cd19f11e77 100644 --- a/sbin/unwind/unwind.c +++ b/sbin/unwind/unwind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unwind.c,v 1.28 2019/05/14 14:51:31 florian Exp $ */ +/* $OpenBSD: unwind.c,v 1.29 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -289,13 +289,13 @@ main(int argc, char *argv[]) fatalx("control socket setup failed"); if ((frontend_routesock = socket(AF_ROUTE, SOCK_RAW | SOCK_CLOEXEC, - AF_INET)) < 0) + AF_INET)) == -1) fatal("route socket"); rtfilter = ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_PROPOSAL) | ROUTE_FILTER(RTM_GET); if (setsockopt(frontend_routesock, AF_ROUTE, ROUTE_MSGFILTER, - &rtfilter, sizeof(rtfilter)) < 0) + &rtfilter, sizeof(rtfilter)) == -1) fatal("setsockopt(ROUTE_MSGFILTER)"); if ((ta_fd = open(TRUST_ANCHOR_FILE, O_RDWR | O_CREAT, 0644)) == -1) diff --git a/sbin/vnconfig/vnconfig.c b/sbin/vnconfig/vnconfig.c index 6a89df98f6d..cc179e08a74 100644 --- a/sbin/vnconfig/vnconfig.c +++ b/sbin/vnconfig/vnconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnconfig.c,v 1.4 2019/04/28 16:28:00 jmc Exp $ */ +/* $OpenBSD: vnconfig.c,v 1.5 2019/06/28 13:32:46 deraadt Exp $ */ /* * Copyright (c) 1993 University of Utah. * Copyright (c) 1990, 1993 @@ -238,7 +238,7 @@ getinfo(const char *vname, int *availp) } vd = opendev((char *)vname, O_RDONLY, OPENDEV_PART, NULL); - if (vd < 0) + if (vd == -1) err(1, "open: %s", vname); vnu.vnu_unit = -1; @@ -296,7 +296,7 @@ config(char *file, char *dev, struct disklabel *dp, char *key, size_t keylen) asprintf(&dev, "vnd%d", unit); } - if ((fd = opendev(dev, O_RDONLY, OPENDEV_PART, &rdev)) < 0) { + if ((fd = opendev(dev, O_RDONLY, OPENDEV_PART, &rdev)) == -1) { err(4, "%s", rdev); goto out; } @@ -324,7 +324,7 @@ config(char *file, char *dev, struct disklabel *dp, char *key, size_t keylen) out: if (key) explicit_bzero(key, keylen); - return (rv < 0); + return (rv == -1); } int @@ -334,7 +334,7 @@ unconfig(char *vnd) int fd, rv = -1, unit; char *rdev; - if ((fd = opendev(vnd, O_RDONLY, OPENDEV_PART, &rdev)) < 0) + if ((fd = opendev(vnd, O_RDONLY, OPENDEV_PART, &rdev)) == -1) err(4, "%s", rdev); memset(&vndio, 0, sizeof vndio); @@ -351,7 +351,7 @@ unconfig(char *vnd) close(fd); fflush(stdout); - return (rv < 0); + return (rv == -1); } __dead void diff --git a/sbin/wsconsctl/display.c b/sbin/wsconsctl/display.c index fba7f6cdaeb..47245bbd4a3 100644 --- a/sbin/wsconsctl/display.c +++ b/sbin/wsconsctl/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.21 2019/03/27 17:24:17 fcambus Exp $ */ +/* $OpenBSD: display.c,v 1.22 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: display.c,v 1.1 1998/12/28 14:01:16 hannken Exp $ */ /*- @@ -144,7 +144,7 @@ display_get_values(int fd) (cmd == WSDISPLAYIO_GBURNER && !bon) || (cmd == WSDISPLAYIO_GINFO && !fbon)) { errno = ENOTTY; - if (!cmd || ioctl(fd, cmd, ptr) < 0) { + if (!cmd || ioctl(fd, cmd, ptr) == -1) { if (errno == ENOTTY) { pf->flags |= FLG_DEAD; continue; @@ -265,7 +265,7 @@ display_put_values(int fd) } errno = ENOTTY; - if (!cmd || ioctl(fd, cmd, ptr) < 0) { + if (!cmd || ioctl(fd, cmd, ptr) == -1) { if (errno == ENOTTY) { pf->flags |= FLG_DEAD; continue; diff --git a/sbin/wsconsctl/keyboard.c b/sbin/wsconsctl/keyboard.c index d60261b5a06..50773c69c59 100644 --- a/sbin/wsconsctl/keyboard.c +++ b/sbin/wsconsctl/keyboard.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keyboard.c,v 1.13 2015/12/12 12:31:37 jung Exp $ */ +/* $OpenBSD: keyboard.c,v 1.14 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: keyboard.c 1.1 1998/12/28 14:01:17 hannken Exp $ */ /*- @@ -78,7 +78,7 @@ keyboard_get_values(int fd) struct field *pf; if (field_by_value(keyboard_field_tab, &kbtype)->flags & FLG_GET) - if (ioctl(fd, WSKBDIO_GTYPE, &kbtype) < 0) + if (ioctl(fd, WSKBDIO_GTYPE, &kbtype) == -1) warn("WSKBDIO_GTYPE"); bell.which = 0; @@ -88,7 +88,7 @@ keyboard_get_values(int fd) bell.which |= WSKBD_BELL_DOPERIOD; if (field_by_value(keyboard_field_tab, &bell.volume)->flags & FLG_GET) bell.which |= WSKBD_BELL_DOVOLUME; - if (bell.which != 0 && ioctl(fd, WSKBDIO_GETBELL, &bell) < 0) + if (bell.which != 0 && ioctl(fd, WSKBDIO_GETBELL, &bell) == -1) warn("WSKBDIO_GETBELL"); dfbell.which = 0; @@ -99,14 +99,14 @@ keyboard_get_values(int fd) if (field_by_value(keyboard_field_tab, &dfbell.volume)->flags & FLG_GET) dfbell.which |= WSKBD_BELL_DOVOLUME; if (dfbell.which != 0 && - ioctl(fd, WSKBDIO_GETDEFAULTBELL, &dfbell) < 0) + ioctl(fd, WSKBDIO_GETDEFAULTBELL, &dfbell) == -1) warn("WSKBDIO_GETDEFAULTBELL"); if (field_by_value(keyboard_field_tab, &kbmap)->flags & FLG_GET) { kbmap.maplen = KS_NUMKEYCODES; - if (ioctl(fd, WSKBDIO_GETMAP, &kbmap) < 0) + if (ioctl(fd, WSKBDIO_GETMAP, &kbmap) == -1) warn("WSKBDIO_GETMAP"); - if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) < 0) + if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) == -1) warn("WSKBDIO_GETENCODING"); ksymenc(kbdencoding); } @@ -117,7 +117,7 @@ keyboard_get_values(int fd) if (field_by_value(keyboard_field_tab, &repeat.delN)->flags & FLG_GET) repeat.which |= WSKBD_KEYREPEAT_DODELN; if (repeat.which != 0 && - ioctl(fd, WSKBDIO_GETKEYREPEAT, &repeat) < 0) + ioctl(fd, WSKBDIO_GETKEYREPEAT, &repeat) == -1) warn("WSKBDIO_GETKEYREPEAT"); dfrepeat.which = 0; @@ -126,21 +126,21 @@ keyboard_get_values(int fd) if (field_by_value(keyboard_field_tab, &dfrepeat.delN)->flags & FLG_GET) dfrepeat.which |= WSKBD_KEYREPEAT_DODELN; if (dfrepeat.which != 0 && - ioctl(fd, WSKBDIO_GETDEFAULTKEYREPEAT, &dfrepeat) < 0) + ioctl(fd, WSKBDIO_GETDEFAULTKEYREPEAT, &dfrepeat) == -1) warn("WSKBDIO_GETDEFAULTKEYREPEAT"); if (field_by_value(keyboard_field_tab, &ledstate)->flags & FLG_GET) - if (ioctl(fd, WSKBDIO_GETLEDS, &ledstate) < 0) + if (ioctl(fd, WSKBDIO_GETLEDS, &ledstate) == -1) warn("WSKBDIO_GETLEDS"); if (field_by_value(keyboard_field_tab, &kbdencoding)->flags & FLG_GET) - if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) < 0) + if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) == -1) warn("WSKBDIO_GETENCODING"); pf = field_by_value(keyboard_field_tab, &backlight); if (pf->flags & FLG_GET && !(pf->flags & FLG_DEAD)) { errno = ENOTTY; - if (ioctl(fd, WSKBDIO_GETBACKLIGHT, &kbl) < 0) { + if (ioctl(fd, WSKBDIO_GETBACKLIGHT, &kbl) == -1) { if (errno == ENOTTY) pf->flags |= FLG_DEAD; else @@ -166,7 +166,7 @@ keyboard_put_values(int fd) bell.which |= WSKBD_BELL_DOPERIOD; if (field_by_value(keyboard_field_tab, &bell.volume)->flags & FLG_SET) bell.which |= WSKBD_BELL_DOVOLUME; - if (bell.which != 0 && ioctl(fd, WSKBDIO_SETBELL, &bell) < 0) { + if (bell.which != 0 && ioctl(fd, WSKBDIO_SETBELL, &bell) == -1) { warn("WSKBDIO_SETBELL"); return 1; } @@ -179,13 +179,13 @@ keyboard_put_values(int fd) if (field_by_value(keyboard_field_tab, &dfbell.volume)->flags & FLG_SET) dfbell.which |= WSKBD_BELL_DOVOLUME; if (dfbell.which != 0 && - ioctl(fd, WSKBDIO_SETDEFAULTBELL, &dfbell) < 0) { + ioctl(fd, WSKBDIO_SETDEFAULTBELL, &dfbell) == -1) { warn("WSKBDIO_SETDEFAULTBELL"); return 1; } if (field_by_value(keyboard_field_tab, &kbmap)->flags & FLG_SET) { - if (ioctl(fd, WSKBDIO_SETMAP, &kbmap) < 0) { + if (ioctl(fd, WSKBDIO_SETMAP, &kbmap) == -1) { warn("WSKBDIO_SETMAP"); return 1; } @@ -197,7 +197,7 @@ keyboard_put_values(int fd) if (field_by_value(keyboard_field_tab, &repeat.delN)->flags & FLG_SET) repeat.which |= WSKBD_KEYREPEAT_DODELN; if (repeat.which != 0 && - ioctl(fd, WSKBDIO_SETKEYREPEAT, &repeat) < 0) { + ioctl(fd, WSKBDIO_SETKEYREPEAT, &repeat) == -1) { warn("WSKBDIO_SETKEYREPEAT"); return 1; } @@ -208,20 +208,20 @@ keyboard_put_values(int fd) if (field_by_value(keyboard_field_tab, &dfrepeat.delN)->flags & FLG_SET) dfrepeat.which |= WSKBD_KEYREPEAT_DODELN; if (dfrepeat.which != 0 && - ioctl(fd, WSKBDIO_SETDEFAULTKEYREPEAT, &dfrepeat) < 0) { + ioctl(fd, WSKBDIO_SETDEFAULTKEYREPEAT, &dfrepeat) == -1) { warn("WSKBDIO_SETDEFAULTKEYREPEAT"); return 1; } if (field_by_value(keyboard_field_tab, &ledstate)->flags & FLG_SET) { - if (ioctl(fd, WSKBDIO_SETLEDS, &ledstate) < 0) { + if (ioctl(fd, WSKBDIO_SETLEDS, &ledstate) == -1) { warn("WSKBDIO_SETLEDS"); return 1; } } if (field_by_value(keyboard_field_tab, &kbdencoding)->flags & FLG_SET) { - if (ioctl(fd, WSKBDIO_SETENCODING, &kbdencoding) < 0) { + if (ioctl(fd, WSKBDIO_SETENCODING, &kbdencoding) == -1) { warn("WSKBDIO_SETENCODING"); return 1; } @@ -233,7 +233,7 @@ keyboard_put_values(int fd) kbl.curval = backlight.cur; kbl.max = backlight.max; errno = ENOTTY; - if (ioctl(fd, WSKBDIO_SETBACKLIGHT, &kbl) < 0) { + if (ioctl(fd, WSKBDIO_SETBACKLIGHT, &kbl) == -1) { if (errno == ENOTTY) pf->flags |= FLG_DEAD; else { diff --git a/sbin/wsconsctl/mouse.c b/sbin/wsconsctl/mouse.c index a0ee9080f48..5fc70436eaa 100644 --- a/sbin/wsconsctl/mouse.c +++ b/sbin/wsconsctl/mouse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mouse.c,v 1.18 2018/05/07 22:15:36 bru Exp $ */ +/* $OpenBSD: mouse.c,v 1.19 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: mouse.c,v 1.3 1999/11/15 13:47:30 ad Exp $ */ /*- @@ -108,11 +108,11 @@ mouse_get_values(int fd) struct field *f; if (field_by_value(mouse_field_tab, &mstype)->flags & FLG_GET) - if (ioctl(fd, WSMOUSEIO_GTYPE, &mstype) < 0) + if (ioctl(fd, WSMOUSEIO_GTYPE, &mstype) == -1) warn("WSMOUSEIO_GTYPE"); if (field_by_value(mouse_field_tab, &rawmode)->flags & FLG_GET) { - if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) < 0) { + if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) == -1) { if (errno == ENOTTY) field_by_value(mouse_field_tab, &rawmode)->flags |= FLG_DEAD; @@ -123,7 +123,7 @@ mouse_get_values(int fd) } if (field_by_value(mouse_field_tab, &wmcoords)->flags & FLG_GET) - if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) < 0) { + if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) == -1) { if (errno == ENOTTY) field_by_value(mouse_field_tab, &wmcoords)->flags |= FLG_DEAD; @@ -148,14 +148,14 @@ mouse_put_values(int fd) struct field *f; if (field_by_value(mouse_field_tab, &resolution)->flags & FLG_SET) { - if (ioctl(fd, WSMOUSEIO_SRES, &resolution) < 0) { + if (ioctl(fd, WSMOUSEIO_SRES, &resolution) == -1) { warn("WSMOUSEIO_SRES"); return 1; } } if (field_by_value(mouse_field_tab, &rawmode)->flags & FLG_SET) { wmcoords.samplelen = rawmode; - if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) < 0) { + if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) == -1) { if (errno == ENOTTY) { field_by_value(mouse_field_tab, &rawmode)->flags |= FLG_DEAD; @@ -166,7 +166,7 @@ mouse_put_values(int fd) } } if (field_by_value(mouse_field_tab, &wmcoords)->flags & FLG_SET) { - if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords_save) < 0) { + if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords_save) == -1) { if (errno == ENOTTY) field_by_value(mouse_field_tab, &wmcoords)->flags |= FLG_DEAD; @@ -174,7 +174,7 @@ mouse_put_values(int fd) warn("WSMOUSEIO_GCALIBCOORDS"); } wmcoords.samplelen = wmcoords_save.samplelen; - if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) < 0) { + if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) == -1) { if (errno == ENOTTY) { field_by_value(mouse_field_tab, &wmcoords)->flags |= FLG_DEAD; diff --git a/sbin/wsconsctl/wsconsctl.c b/sbin/wsconsctl/wsconsctl.c index 1c62df8fe5d..efb3f17613b 100644 --- a/sbin/wsconsctl/wsconsctl.c +++ b/sbin/wsconsctl/wsconsctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsctl.c,v 1.31 2017/07/21 20:38:20 bru Exp $ */ +/* $OpenBSD: wsconsctl.c,v 1.32 2019/06/28 13:32:46 deraadt Exp $ */ /* $NetBSD: wsconsctl.c,v 1.2 1998/12/29 22:40:20 hannken Exp $ */ /*- @@ -120,8 +120,8 @@ main(int argc, char *argv[]) for (devidx = 0;; devidx++) { device = (*sw->nextdev)(devidx); if (!device || - ((devfd = open(device, O_WRONLY)) < 0 && - (devfd = open(device, O_RDONLY)) < 0)) { + ((devfd = open(device, O_WRONLY)) == -1 && + (devfd = open(device, O_RDONLY)) == -1)) { if (!device || errno != ENXIO) { if (device && errno != ENOENT) { warn("%s", device); @@ -170,8 +170,8 @@ main(int argc, char *argv[]) device = wdev; if (!device || - ((devfd = open(device, O_WRONLY)) < 0 && - (devfd = open(device, O_RDONLY)) < 0)) { + ((devfd = open(device, O_WRONLY)) == -1 && + (devfd = open(device, O_RDONLY)) == -1)) { if (!device) { const char *c = strchr(argv[i], '.'); int k; |