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/newfs/newfs.c | |
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/newfs/newfs.c')
-rw-r--r-- | sbin/newfs/newfs.c | 22 |
1 files changed, 11 insertions, 11 deletions
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, |