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/scan_ffs | |
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/scan_ffs')
-rw-r--r-- | sbin/scan_ffs/scan_ffs.c | 8 |
1 files changed, 4 insertions, 4 deletions
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) |