diff options
author | 2019-06-28 13:34:58 +0000 | |
---|---|---|
committer | 2019-06-28 13:34:58 +0000 | |
commit | 3aaa63eb46949490a39db9c6d82aacc8ee5d8551 (patch) | |
tree | ef48ea58ad350ab9d01fbfe32455a1df1fa2340c /usr.bin/diff/diffreg.c | |
parent | fputc/fputs return EOF on error (diff) | |
download | wireguard-openbsd-3aaa63eb46949490a39db9c6d82aacc8ee5d8551.tar.xz wireguard-openbsd-3aaa63eb46949490a39db9c6d82aacc8ee5d8551.zip |
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/diff/diffreg.c')
-rw-r--r-- | usr.bin/diff/diffreg.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 4f52365dd52..e834fd4aae3 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.92 2019/06/28 05:35:34 deraadt Exp $ */ +/* $OpenBSD: diffreg.c,v 1.93 2019/06/28 13:35:00 deraadt Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -315,7 +315,7 @@ diffreg(char *file1, char *file2, int flags) else { if (!S_ISREG(stb1.st_mode)) { if ((f1 = opentemp(file1)) == NULL || - fstat(fileno(f1), &stb1) < 0) { + fstat(fileno(f1), &stb1) == -1) { warn("%s", file1); status |= 2; goto closem; @@ -336,7 +336,7 @@ diffreg(char *file1, char *file2, int flags) else { if (!S_ISREG(stb2.st_mode)) { if ((f2 = opentemp(file2)) == NULL || - fstat(fileno(f2), &stb2) < 0) { + fstat(fileno(f2), &stb2) == -1) { warn("%s", file2); status |= 2; goto closem; @@ -452,7 +452,7 @@ opentemp(const char *file) if (strcmp(file, "-") == 0) ifd = STDIN_FILENO; - else if ((ifd = open(file, O_RDONLY, 0644)) < 0) + else if ((ifd = open(file, O_RDONLY, 0644)) == -1) return (NULL); (void)strlcpy(tempfile, _PATH_TMP "/diff.XXXXXXXX", sizeof(tempfile)); @@ -930,7 +930,7 @@ preadline(int fd, size_t rlen, off_t off) ssize_t nr; line = xmalloc(rlen + 1); - if ((nr = pread(fd, line, rlen, off)) < 0) + if ((nr = pread(fd, line, rlen, off)) == -1) err(2, "preadline"); if (nr > 0 && line[nr-1] == '\n') nr--; |