diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-06-28 13:35:06 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-06-28 13:35:06 +0000 |
commit | 61656abc7ff84215165af1bd464bc053b3b66158 (patch) | |
tree | c7eabb0c4fa9faa024e724e99c240c40da07ca42 /usr.bin/xinstall | |
parent | 18603ebf99fbb890ae9666cb0c4aa9f879e7edaa (diff) |
When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.
Diffstat (limited to 'usr.bin/xinstall')
-rw-r--r-- | usr.bin/xinstall/xinstall.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 02c5420aa91..0c7b8e10f25 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xinstall.c,v 1.72 2019/05/09 22:44:53 guenther Exp $ */ +/* $OpenBSD: xinstall.c,v 1.73 2019/06/28 13:35:05 deraadt Exp $ */ /* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */ /* @@ -256,7 +256,7 @@ install(char *from_name, char *to_name, u_long fset, u_int flags) } if (!devnull) { - if ((from_fd = open(from_name, O_RDONLY, 0)) < 0) + if ((from_fd = open(from_name, O_RDONLY, 0)) == -1) err(1, "%s", from_name); } @@ -276,7 +276,7 @@ install(char *from_name, char *to_name, u_long fset, u_int flags) * that does not work in-place -- like gnu binutils strip. */ close(to_fd); - if ((to_fd = open(tempfile, O_RDONLY, 0)) < 0) + if ((to_fd = open(tempfile, O_RDONLY, 0)) == -1) err(1, "stripping %s", to_name); } @@ -288,7 +288,7 @@ install(char *from_name, char *to_name, u_long fset, u_int flags) struct stat temp_sb; /* Re-open to_fd using the real target name. */ - if ((to_fd = open(to_name, O_RDONLY, 0)) < 0) + if ((to_fd = open(to_name, O_RDONLY, 0)) == -1) err(1, "%s", to_name); if (fstat(temp_fd, &temp_sb)) { @@ -377,14 +377,14 @@ install(char *from_name, char *to_name, u_long fset, u_int flags) (void)snprintf(backup, PATH_MAX, "%s%s", to_name, suffix); /* It is ok for the target file not to exist. */ - if (rename(to_name, backup) < 0 && errno != ENOENT) { + if (rename(to_name, backup) == -1 && errno != ENOENT) { serrno = errno; unlink(tempfile); errx(1, "rename: %s to %s: %s", to_name, backup, strerror(serrno)); } } - if (rename(tempfile, to_name) < 0 ) { + if (rename(tempfile, to_name) == -1 ) { serrno = errno; unlink(tempfile); errx(1, "rename: %s to %s: %s", tempfile, @@ -726,7 +726,7 @@ file_write(int fd, char *str, size_t cnt, int *rem, int *isempt, int sz) /* * skip, buf is empty so far */ - if (lseek(fd, (off_t)wcnt, SEEK_CUR) < 0) { + if (lseek(fd, (off_t)wcnt, SEEK_CUR) == -1) { warn("lseek"); return(-1); } @@ -772,12 +772,12 @@ file_flush(int fd, int isempt) /* * move back one byte and write a zero */ - if (lseek(fd, (off_t)-1, SEEK_CUR) < 0) { + if (lseek(fd, (off_t)-1, SEEK_CUR) == -1) { warn("Failed seek on file"); return; } - if (write(fd, blnk, 1) < 0) + if (write(fd, blnk, 1) == -1) warn("Failed write to file"); return; } |