Masato Asou <[email protected]> wrote:

> Incorrect checking the return value of malloc and system calls in
> /bin/cp.

The NULL vs ! checks, I cannot agree with those.  Their effect is
identical and it is commonplace to use either idiom.

As to precise-checks for system call return values of -1 or 0, vs
<, for that case I do not know how to proceed.

I actually have a diff lying around which does precise -1 checks for the
entire tree, in regards to section-2 system calls and some of the
thinner section-3 wrappers.

I wanted to know if there were any truly incorrect checks, and the
easiest way was to carefully adjust all the code, and then read the
diffs afterwards.  I found only two bugs, which I fixed a couple months
ago.  So this is the remainder.

In the following diff, I believe the <, <= and != 0 being converted
to precise == 0 and == -1 are more precise but without error, but I'm
not sure whether to proceed.  On some architectures, binaries will
grow minutely larger because a precise check uses a few more instruction
bytes than a relative range check.

BTW, there IS some opportunity for making mistakes with such a diff,
especially around the 64-bit system calls and thin wrappers.

So I don't think you should proceed with precise system call checks for
this one program, until we all discuss whether this idiom is valuable to
do for ALL programs.  Is precise -1 checking a more correct idiom, or is
it pointless?

(As I said, I'm ok with deleting my 1750 line diff since (1) I have
started thinking it is pointless, and (2) it was purely the side effort
of an audit procedure)

Index: usr.bin/biff/biff.c
===================================================================
RCS file: /cvs/src/usr.bin/biff/biff.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 biff.c
--- usr.bin/biff/biff.c 28 Jun 2019 13:35:00 -0000      1.17
+++ usr.bin/biff/biff.c 4 Jul 2019 17:00:26 -0000
@@ -66,7 +66,7 @@ main(int argc, char *argv[])
        if (pledge("stdio rpath fattr", NULL) == -1)
                err(2, "pledge");
 
-       if (stat(name, &sb))
+       if (stat(name, &sb) == -1)
                err(2, "stat");
 
        sb.st_mode &= ACCESSPERMS;
Index: usr.bin/calendar/calendar.c
===================================================================
RCS file: /cvs/src/usr.bin/calendar/calendar.c,v
retrieving revision 1.37
diff -u -p -u -r1.37 calendar.c
--- usr.bin/calendar/calendar.c 1 Feb 2019 16:22:53 -0000       1.37
+++ usr.bin/calendar/calendar.c 6 Jul 2019 15:40:49 -0000
@@ -167,21 +167,21 @@ main(int argc, char *argv[])
                         * we can chdir() we can stat(), unless the user is
                         * modifying permissions while this is running.
                         */
-                       if (chdir(pw->pw_dir)) {
+                       if (chdir(pw->pw_dir) == -1) {
                                if (errno == EACCES)
                                        acstat = 1;
                                else
                                        continue;
                        }
-                       if (stat(calendarFile, &sbuf) != 0) {
-                               if (chdir(calendarHome)) {
+                       if (stat(calendarFile, &sbuf) == -1) {
+                               if (chdir(calendarHome) == -1) {
                                        if (errno == EACCES)
                                                acstat = 1;
                                        else
                                                continue;
                                }
                                if (stat(calendarNoMail, &sbuf) == 0 ||
-                                   stat(calendarFile, &sbuf) != 0)
+                                   stat(calendarFile, &sbuf) == -1)
                                        continue;
                        }
                        sleeptime = USERTIMEOUT;
@@ -197,11 +197,11 @@ main(int argc, char *argv[])
                                        err(1, "unable to set user context (uid 
%u)",
                                            pw->pw_uid);
                                if (acstat) {
-                                       if (chdir(pw->pw_dir) ||
-                                           stat(calendarFile, &sbuf) != 0 ||
-                                           chdir(calendarHome) ||
+                                       if (chdir(pw->pw_dir) == -1 ||
+                                           stat(calendarFile, &sbuf) == -1 ||
+                                           chdir(calendarHome) == -1 ||
                                            stat(calendarNoMail, &sbuf) == 0 ||
-                                           stat(calendarFile, &sbuf) != 0)
+                                           stat(calendarFile, &sbuf) == -1)
                                                exit(0);
                                }
                                cal();
@@ -257,7 +257,7 @@ main(int argc, char *argv[])
                        warnx("%d child processes still running when "
                            "'calendar -a' finished", runningkids);
        } else if ((caldir = getenv("CALENDAR_DIR")) != NULL) {
-               if(!chdir(caldir))
+               if (chdir(caldir) == 0)
                        cal();
        } else
                cal();
Index: usr.bin/calendar/io.c
===================================================================
RCS file: /cvs/src/usr.bin/calendar/io.c,v
retrieving revision 1.49
diff -u -p -u -r1.49 io.c
--- usr.bin/calendar/io.c       28 Jun 2019 13:35:00 -0000      1.49
+++ usr.bin/calendar/io.c       6 Jul 2019 16:10:34 -0000
@@ -391,7 +391,7 @@ closecal(FILE *fp)
                return;
 
        (void)rewind(fp);
-       if (fstat(fileno(fp), &sbuf) || !sbuf.st_size)
+       if (fstat(fileno(fp), &sbuf) == -1 || !sbuf.st_size)
                goto done;
        if (pipe(pdes) == -1)
                goto done;
Index: usr.bin/chpass/edit.c
===================================================================
RCS file: /cvs/src/usr.bin/chpass/edit.c,v
retrieving revision 1.35
diff -u -p -u -r1.35 edit.c
--- usr.bin/chpass/edit.c       16 Jan 2015 06:40:06 -0000      1.35
+++ usr.bin/chpass/edit.c       4 Jul 2019 17:02:24 -0000
@@ -140,7 +140,7 @@ verify(char *tempname, struct passwd *pw
        if ((fd = open(tempname, O_RDONLY|O_NOFOLLOW)) == -1 ||
            (fp = fdopen(fd, "r")) == NULL)
                pw_error(tempname, 1, 1);
-       if (fstat(fd, &sb))
+       if (fstat(fd, &sb) == -1)
                pw_error(tempname, 1, 1);
        if (sb.st_size == 0 || sb.st_nlink != 1 || sb.st_uid != uid) {
                warnx("corrupted temporary file");
Index: usr.bin/compress/main.c
===================================================================
RCS file: /cvs/src/usr.bin/compress/main.c,v
retrieving revision 1.96
diff -u -p -u -r1.96 main.c
--- usr.bin/compress/main.c     28 Jun 2019 13:35:00 -0000      1.96
+++ usr.bin/compress/main.c     4 Jul 2019 17:03:04 -0000
@@ -786,7 +786,7 @@ setfile(const char *name, int fd, struct
                        warn("fchown: %s", name);
                fs->st_mode &= ~(S_ISUID|S_ISGID);
        }
-       if (fchmod(fd, fs->st_mode))
+       if (fchmod(fd, fs->st_mode) == -1)
                warn("fchmod: %s", name);
 
        if (fs->st_flags && fchflags(fd, fs->st_flags))
@@ -794,7 +794,7 @@ setfile(const char *name, int fd, struct
 
        ts[0] = fs->st_atim;
        ts[1] = fs->st_mtim;
-       if (futimens(fd, ts))
+       if (futimens(fd, ts) == -1)
                warn("futimens: %s", name);
 }
 
Index: usr.bin/diff/diff.c
===================================================================
RCS file: /cvs/src/usr.bin/diff/diff.c,v
retrieving revision 1.67
diff -u -p -u -r1.67 diff.c
--- usr.bin/diff/diff.c 28 Jun 2019 13:35:00 -0000      1.67
+++ usr.bin/diff/diff.c 6 Jul 2019 16:10:25 -0000
@@ -236,12 +236,12 @@ main(int argc, char **argv)
        if (strcmp(argv[0], "-") == 0) {
                fstat(STDIN_FILENO, &stb1);
                gotstdin = 1;
-       } else if (stat(argv[0], &stb1) != 0)
+       } else if (stat(argv[0], &stb1) == -1)
                err(2, "%s", argv[0]);
        if (strcmp(argv[1], "-") == 0) {
                fstat(STDIN_FILENO, &stb2);
                gotstdin = 1;
-       } else if (stat(argv[1], &stb2) != 0)
+       } else if (stat(argv[1], &stb2) == -1)
                err(2, "%s", argv[1]);
        if (gotstdin && (S_ISDIR(stb1.st_mode) || S_ISDIR(stb2.st_mode)))
                errx(2, "can't compare - to a directory");
Index: usr.bin/doas/doas.c
===================================================================
RCS file: /cvs/src/usr.bin/doas/doas.c,v
retrieving revision 1.80
diff -u -p -u -r1.80 doas.c
--- usr.bin/doas/doas.c 3 Jul 2019 03:24:02 -0000       1.80
+++ usr.bin/doas/doas.c 5 Jul 2019 12:52:46 -0000
@@ -212,7 +212,7 @@ authuser(char *myname, char *login_style
                errx(1, "Authorization failed");
        if (!challenge) {
                char host[HOST_NAME_MAX + 1];
-               if (gethostname(host, sizeof(host)))
+               if (gethostname(host, sizeof(host)) == -1)
                        snprintf(host, sizeof(host), "?");
                snprintf(cbuf, sizeof(cbuf),
                    "\rdoas (%.32s@%.32s) password: ", myname, host);
Index: usr.bin/find/function.c
===================================================================
RCS file: /cvs/src/usr.bin/find/function.c,v
retrieving revision 1.47
diff -u -p -u -r1.47 function.c
--- usr.bin/find/function.c     28 Jun 2019 13:35:01 -0000      1.47
+++ usr.bin/find/function.c     4 Jul 2019 17:05:17 -0000
@@ -859,7 +859,7 @@ f_fstype(PLAN *plan, FTSENT *entry)
                } else 
                        p = NULL;
 
-               if (statfs(entry->fts_accpath, &sb))
+               if (statfs(entry->fts_accpath, &sb) == -1)
                        err(1, "%s", entry->fts_accpath);
 
                if (p) {
@@ -1202,7 +1202,7 @@ c_newer(char *filename, char ***ignored,
     
        ftsoptions &= ~FTS_NOSTAT;
 
-       if (stat(filename, &sb))
+       if (stat(filename, &sb) == -1)
                err(1, "%s", filename);
        new = palloc(N_NEWER, f_newer);
        memcpy(&new->t_data, &sb.st_mtimespec, sizeof(struct timespec));
@@ -1233,7 +1233,7 @@ c_anewer(char *filename, char ***ignored
     
        ftsoptions &= ~FTS_NOSTAT;
 
-       if (stat(filename, &sb))
+       if (stat(filename, &sb) == -1)
                err(1, "%s", filename);
        new = palloc(N_NEWER, f_anewer);
        memcpy(&new->t_data, &sb.st_atimespec, sizeof(struct timespec));
@@ -1264,7 +1264,7 @@ c_cnewer(char *filename, char ***ignored
     
        ftsoptions &= ~FTS_NOSTAT;
 
-       if (stat(filename, &sb))
+       if (stat(filename, &sb) == -1)
                err(1, "%s", filename);
        new = palloc(N_NEWER, f_cnewer);
        memcpy(&new->t_data, &sb.st_ctimespec, sizeof(struct timespec));
Index: usr.bin/finger/util.c
===================================================================
RCS file: /cvs/src/usr.bin/finger/util.c,v
retrieving revision 1.36
diff -u -p -u -r1.36 util.c
--- usr.bin/finger/util.c       3 Jul 2019 03:24:02 -0000       1.36
+++ usr.bin/finger/util.c       6 Jul 2019 16:10:48 -0000
@@ -121,7 +121,7 @@ userinfo(PERSON *pn, struct passwd *pw)
        len = snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_MAILSPOOL,
            pw->pw_name);
        if (len >= 0 && len < sizeof(tbuf)) {
-               if (stat(tbuf, &sb) < 0) {
+               if (stat(tbuf, &sb) == -1) {
                        if (errno != ENOENT) {
                                warn("%s", tbuf);
                                return;
Index: usr.bin/fstat/fstat.c
===================================================================
RCS file: /cvs/src/usr.bin/fstat/fstat.c,v
retrieving revision 1.99
diff -u -p -u -r1.99 fstat.c
--- usr.bin/fstat/fstat.c       5 Feb 2019 02:17:32 -0000       1.99
+++ usr.bin/fstat/fstat.c       6 Jul 2019 16:10:42 -0000
@@ -884,7 +884,7 @@ getfname(char *filename)
        struct stat sb;
        struct filearg *cur;
 
-       if (stat(filename, &sb)) {
+       if (stat(filename, &sb) == -1) {
                warn("%s", filename);
                return (0);
        }
Index: usr.bin/hexdump/display.c
===================================================================
RCS file: /cvs/src/usr.bin/hexdump/display.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 display.c
--- usr.bin/hexdump/display.c   24 Aug 2016 03:13:45 -0000      1.25
+++ usr.bin/hexdump/display.c   4 Jul 2019 17:07:36 -0000
@@ -330,7 +330,7 @@ doskip(const char *fname, int statok)
        struct stat sb;
 
        if (statok) {
-               if (fstat(fileno(stdin), &sb))
+               if (fstat(fileno(stdin), &sb) == -1)
                        err(1, "fstat %s", fname);
                if (S_ISREG(sb.st_mode)) {
                        if (skip > sb.st_size) {
Index: usr.bin/ktrace/ktrace.c
===================================================================
RCS file: /cvs/src/usr.bin/ktrace/ktrace.c,v
retrieving revision 1.36
diff -u -p -u -r1.36 ktrace.c
--- usr.bin/ktrace/ktrace.c     28 Jun 2019 13:35:01 -0000      1.36
+++ usr.bin/ktrace/ktrace.c     4 Jul 2019 17:08:32 -0000
@@ -175,7 +175,7 @@ main(int argc, char *argv[])
        if (append) {
                if ((fd = open(tracefile, O_CREAT | O_WRONLY, DEFFILEMODE)) == 
-1)
                        err(1, "%s", tracefile);
-               if (fstat(fd, &sb) != 0 || sb.st_uid != getuid())
+               if (fstat(fd, &sb) == -1 || sb.st_uid != getuid())
                        errx(1, "Refuse to append to %s: not owned by you.",
                            tracefile);
        } else {
Index: usr.bin/last/last.c
===================================================================
RCS file: /cvs/src/usr.bin/last/last.c,v
retrieving revision 1.52
diff -u -p -u -r1.52 last.c
--- usr.bin/last/last.c 28 Jun 2019 13:35:01 -0000      1.52
+++ usr.bin/last/last.c 4 Jul 2019 17:08:51 -0000
@@ -508,7 +508,7 @@ hostconv(char *arg)
                return;
        if (first) {
                first = 0;
-               if (gethostname(name, sizeof(name)))
+               if (gethostname(name, sizeof(name)) == -1)
                        err(1, "gethostname");
                hostdot = strchr(name, '.');
        }
Index: usr.bin/lastcomm/lastcomm.c
===================================================================
RCS file: /cvs/src/usr.bin/lastcomm/lastcomm.c,v
retrieving revision 1.28
diff -u -p -u -r1.28 lastcomm.c
--- usr.bin/lastcomm/lastcomm.c 25 Jul 2019 13:13:53 -0000      1.28
+++ usr.bin/lastcomm/lastcomm.c 25 Jul 2019 18:58:09 -0000
@@ -85,7 +85,7 @@ main(int argc, char *argv[])
        argv += optind;
 
        /* Open the file. */
-       if ((fp = fopen(acctfile, "r")) == NULL || fstat(fileno(fp), &sb))
+       if ((fp = fopen(acctfile, "r")) == NULL || fstat(fileno(fp), &sb) == -1)
                err(1, "%s", acctfile);
 
        /*
Index: usr.bin/login/login.c
===================================================================
RCS file: /cvs/src/usr.bin/login/login.c,v
retrieving revision 1.71
diff -u -p -u -r1.71 login.c
--- usr.bin/login/login.c       28 Jun 2019 13:35:01 -0000      1.71
+++ usr.bin/login/login.c       4 Jul 2019 17:10:03 -0000
@@ -622,7 +622,7 @@ failed:
                        (void)printf("No home directory %s!\n", pwd->pw_dir);
                        quickexit(1);
                }
-               if (chdir("/"))
+               if (chdir("/") == -1)
                        quickexit(0);
        }
 
Index: usr.bin/mg/log.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/log.c,v
retrieving revision 1.11
diff -u -p -u -r1.11 log.c
--- usr.bin/mg/log.c    18 Jul 2019 10:50:24 -0000      1.11
+++ usr.bin/mg/log.c    23 Jul 2019 05:06:33 -0000
@@ -92,7 +92,7 @@ mglog_key(KEYMAP *map)
        FILE            *fd;
        PF              *pfp;
 
-       if(stat(mglogpath_key, &sb))
+       if(stat(mglogpath_key, &sb) == -1)
                 return (FALSE);
        fd = fopen(mglogpath_key, "a");
 
@@ -136,7 +136,7 @@ mglog_window(void)
        FILE            *fd;
        int              i;
 
-       if(stat(mglogpath_window, &sb))
+       if(stat(mglogpath_window, &sb) == -1)
                return (FALSE);
        fd = fopen(mglogpath_window, "a");
 
@@ -182,7 +182,7 @@ mglog_undo(void)
 
        jptr = "^J"; /* :) */
 
-       if(stat(mglogpath_undo, &sb))
+       if(stat(mglogpath_undo, &sb) == -1)
                return (FALSE);
        fd = fopen(mglogpath_undo, "a");
        
@@ -242,7 +242,7 @@ mglog_lines(PF funct)
 
        i = 0;
 
-       if(stat(mglogpath_lines, &sb))
+       if(stat(mglogpath_lines, &sb) == -1)
                return (FALSE);
 
        fd = fopen(mglogpath_lines, "a");
@@ -388,7 +388,7 @@ mgloginit(void)
        f_mode = 0777& ~oumask;
        dir_mode = f_mode | S_IWUSR | S_IXUSR;
 
-       if(stat(mglogdir, &sb)) {
+       if(stat(mglogdir, &sb) == -1) {
                if (mkdir(mglogdir, dir_mode) != 0)
                        return (FALSE);
                if (chmod(mglogdir, f_mode) == -1)
@@ -430,7 +430,7 @@ mglogfiles_create(char *mglogfile)
        if ((tmp2 = strndup(tmp, NFILEN)) == NULL)
                return (NULL);
 
-       if(stat(tmp2, &sb))
+       if(stat(tmp2, &sb) == -1)
                fd = open(tmp2, O_RDWR | O_CREAT | O_TRUNC, 0644);
        else
                fd = open(tmp2, O_RDWR | O_TRUNC, 0644);
@@ -453,7 +453,7 @@ mglog_?(void)
        struct stat      sb;
        FILE            *fd;
 
-       if(stat(mglogpath_?, &sb))
+       if(stat(mglogpath_?, &sb) == -1)
        fd = fopen(mglogpath_?, "a");
 
        if (fprintf(fd, "%?", ??) == -1) {
Index: usr.bin/newsyslog/newsyslog.c
===================================================================
RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.c,v
retrieving revision 1.112
diff -u -p -u -r1.112 newsyslog.c
--- usr.bin/newsyslog/newsyslog.c       28 Jun 2019 13:35:02 -0000      1.112
+++ usr.bin/newsyslog/newsyslog.c       4 Jul 2019 17:48:10 -0000
@@ -285,14 +285,14 @@ do_entry(struct conf_entry *ent)
        int modhours;
        off_t size;
 
-       if (lstat(ent->log, &sb) != 0)
+       if (lstat(ent->log, &sb) == -1)
                return;
        if (!S_ISREG(sb.st_mode) &&
            (!S_ISLNK(sb.st_mode) || !(ent->flags & CE_FOLLOW))) {
                DPRINTF(("--> not a regular file, skipping\n"));
                return;
        }
-       if (S_ISLNK(sb.st_mode) && stat(ent->log, &sb) != 0) {
+       if (S_ISLNK(sb.st_mode) && stat(ent->log, &sb) == -1) {
                DPRINTF(("--> link target does not exist, skipping\n"));
                return;
        }
@@ -394,7 +394,7 @@ send_signal(char *pidfile, int signal)
                warnx("%s pid file: %s", err, pidfile);
        else if (noaction)
                (void)printf("kill -%s %ld\n", sys_signame[signal], (long)pid);
-       else if (kill(pid, signal))
+       else if (kill(pid, signal) == -1)
                warnx("warning - could not send SIG%s to PID from pid file %s",
                    sys_signame[signal], pidfile);
 }
@@ -731,7 +731,7 @@ nextline:
                                *(working->logbase - 1) = '/';
                        }
                        /* Ignore arcdir if it doesn't exist. */
-                       if (stat(working->backdir, &sb) != 0 ||
+                       if (stat(working->backdir, &sb) == -1 ||
                            !S_ISDIR(sb.st_mode)) {
                                if (working->backdir != arcdir)
                                        free(working->backdir);
@@ -818,11 +818,11 @@ rotate(struct conf_entry *ent, const cha
                        printf("\tchmod %o %s\n", ent->permissions, file2);
                        printf("\tchown %u:%u %s\n", ent->uid, ent->gid, file2);
                } else {
-                       if (rename(file1, file2))
+                       if (rename(file1, file2) == -1)
                                warn("can't mv %s to %s", file1, file2);
-                       if (chmod(file2, ent->permissions))
+                       if (chmod(file2, ent->permissions) == -1)
                                warn("can't chmod %s", file2);
-                       if (chown(file2, ent->uid, ent->gid))
+                       if (chown(file2, ent->uid, ent->gid) == -1)
                                warn("can't chown %s", file2);
                }
        }
@@ -852,9 +852,9 @@ dotrim(struct conf_entry *ent)
        } else {
                if ((fd = mkstemp(file2)) == -1)
                        err(1, "can't start '%s' log", file2);
-               if (fchmod(fd, ent->permissions))
+               if (fchmod(fd, ent->permissions) == -1)
                        err(1, "can't chmod '%s' log file", file2);
-               if (fchown(fd, ent->uid, ent->gid))
+               if (fchown(fd, ent->uid, ent->gid) == -1)
                        err(1, "can't chown '%s' log file", file2);
                (void)close(fd);
                /* Add status message */
@@ -865,7 +865,7 @@ dotrim(struct conf_entry *ent)
        if (ent->numlogs == 0) {
                if (noaction)
                        printf("\trm %s\n", ent->log);
-               else if (unlink(ent->log))
+               else if (unlink(ent->log) == -1)
                        warn("can't rm %s", ent->log);
        } else {
                (void)snprintf(file1, sizeof(file1), "%s.0", oldlog);
@@ -881,7 +881,7 @@ dotrim(struct conf_entry *ent)
        /* Now move the new log file into place */
        if (noaction)
                printf("\tmv %s to %s\n", file2, ent->log);
-       else if (rename(file2, ent->log))
+       else if (rename(file2, ent->log) == -1)
                warn("can't mv %s to %s", file2, ent->log);
 }
 
@@ -1354,9 +1354,9 @@ movefile(char *from, char *to, uid_t own
 
        /* try rename(2) first */
        if (rename(from, to) == 0) {
-               if (chmod(to, perm))
+               if (chmod(to, perm) == -1)
                        warn("can't chmod %s", to);
-               if (chown(to, owner_uid, group_gid))
+               if (chown(to, owner_uid, group_gid) == -1)
                        warn("can't chown %s", to);
                return (0);
        } else if (errno != EXDEV)
@@ -1367,9 +1367,9 @@ movefile(char *from, char *to, uid_t own
                err(1, "can't fopen %s for reading", from);
        if ((dst = fopen(to, "w")) == NULL)
                err(1, "can't fopen %s for writing", to);
-       if (fchmod(fileno(dst), perm))
+       if (fchmod(fileno(dst), perm) == -1)
                err(1, "can't fchmod %s", to);
-       if (fchown(fileno(dst), owner_uid, group_gid))
+       if (fchown(fileno(dst), owner_uid, group_gid) == -1)
                err(1, "can't fchown %s", to);
 
        while ((i = getc(src)) != EOF) {
@@ -1383,7 +1383,7 @@ movefile(char *from, char *to, uid_t own
                err(1, "can't fclose %s", from);
        if ((fclose(dst)) != 0)
                err(1, "can't fclose %s", to);
-       if ((unlink(from)) != 0)
+       if ((unlink(from)) == -1)
                err(1, "can't unlink %s", from);
 
        return (0);
Index: usr.bin/nfsstat/nfsstat.c
===================================================================
RCS file: /cvs/src/usr.bin/nfsstat/nfsstat.c,v
retrieving revision 1.36
diff -u -p -u -r1.36 nfsstat.c
--- usr.bin/nfsstat/nfsstat.c   27 Aug 2016 04:07:42 -0000      1.36
+++ usr.bin/nfsstat/nfsstat.c   4 Jul 2019 17:48:27 -0000
@@ -135,7 +135,7 @@ main(int argc, char *argv[])
                mib[1] = VFS_GENERIC;
                mib[2] = VFS_MAXTYPENUM;
                len = sizeof(nfs_id);
-               if (sysctl(mib, 3, &nfs_id, &len, NULL, 0))
+               if (sysctl(mib, 3, &nfs_id, &len, NULL, 0) == -1)
                        err(1, "sysctl: VFS_MAXTYPENUM");
 
                for (; nfs_id; nfs_id--) {
@@ -147,7 +147,7 @@ main(int argc, char *argv[])
                        mib[3] = nfs_id;
 
                        len = sizeof(vfsc);
-                       if (sysctl(mib, 4, &vfsc, &len, NULL, 0))
+                       if (sysctl(mib, 4, &vfsc, &len, NULL, 0) == -1)
                                continue;
 
                        if (!strcmp(vfsc.vfc_name, MOUNT_NFS))
@@ -179,7 +179,7 @@ getnfsstats(struct nfsstats *p)
                mib[1] = nfs_id; /* 2 */
                mib[2] = NFS_NFSSTATS;
 
-               if (sysctl(mib, 3, p, &len, NULL, 0))
+               if (sysctl(mib, 3, p, &len, NULL, 0) == -1)
                        err(1, "sysctl");
        }
 }
Index: usr.bin/nice/nice.c
===================================================================
RCS file: /cvs/src/usr.bin/nice/nice.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 nice.c
--- usr.bin/nice/nice.c 28 Oct 2016 07:22:59 -0000      1.17
+++ usr.bin/nice/nice.c 4 Jul 2019 17:48:53 -0000
@@ -84,7 +84,7 @@ main(int argc, char *argv[])
        prio += getpriority(PRIO_PROCESS, 0);
        if (errno)
                err(1, "getpriority");
-       if (setpriority(PRIO_PROCESS, 0, prio))
+       if (setpriority(PRIO_PROCESS, 0, prio) == -1)
                warn("setpriority");
 
        if (pledge("stdio exec", NULL) == -1)
Index: usr.bin/patch/mkpath.c
===================================================================
RCS file: /cvs/src/usr.bin/patch/mkpath.c,v
retrieving revision 1.4
diff -u -p -u -r1.4 mkpath.c
--- usr.bin/patch/mkpath.c      20 May 2014 01:25:23 -0000      1.4
+++ usr.bin/patch/mkpath.c      6 Jul 2019 16:06:55 -0000
@@ -58,7 +58,7 @@ mkpath(char *path)
                done = (*slash == '\0');
                *slash = '\0';
 
-               if (stat(path, &sb)) {
+               if (stat(path, &sb) == -1) {
                        if (errno != ENOENT || (mkdir(path, 0777) &&
                            errno != EEXIST)) {
                                warn("%s", path);
Index: usr.bin/patch/pch.c
===================================================================
RCS file: /cvs/src/usr.bin/patch/pch.c,v
retrieving revision 1.60
diff -u -p -u -r1.60 pch.c
--- usr.bin/patch/pch.c 7 Apr 2018 14:55:13 -0000       1.60
+++ usr.bin/patch/pch.c 6 Jul 2019 16:08:56 -0000
@@ -111,7 +111,7 @@ open_patch_file(const char *filename)
        pfp = fopen(filename, "r");
        if (pfp == NULL)
                pfatal("patch file %s not found", filename);
-       if (fstat(fileno(pfp), &filestat))
+       if (fstat(fileno(pfp), &filestat) == -1)
                pfatal("can't stat %s", filename);
        p_filesize = filestat.st_size;
        next_intuit_at(0, 1L);  /* start at the beginning */
Index: usr.bin/rsync/mkpath.c
===================================================================
RCS file: /cvs/src/usr.bin/rsync/mkpath.c,v
retrieving revision 1.4
diff -u -p -u -r1.4 mkpath.c
--- usr.bin/rsync/mkpath.c      8 May 2019 21:30:11 -0000       1.4
+++ usr.bin/rsync/mkpath.c      6 Jul 2019 16:06:46 -0000
@@ -57,7 +57,7 @@ mkpath(char *path)
                done = (*slash == '\0');
                *slash = '\0';
 
-               if (stat(path, &sb)) {
+               if (stat(path, &sb) == -1) {
                        if (errno != ENOENT || (mkdir(path, 0777) &&
                            errno != EEXIST)) {
                                ERR("%s: stat", path);
Index: usr.bin/rwall/rwall.c
===================================================================
RCS file: /cvs/src/usr.bin/rwall/rwall.c,v
retrieving revision 1.13
diff -u -p -u -r1.13 rwall.c
--- usr.bin/rwall/rwall.c       16 Jan 2015 06:40:11 -0000      1.13
+++ usr.bin/rwall/rwall.c       6 Jul 2019 16:08:42 -0000
@@ -142,7 +142,7 @@ makemsg(char *fname)
                fputs(lbuf, fp);
        rewind(fp);
 
-       if (fstat(fd, &sbuf))
+       if (fstat(fd, &sbuf) == -1)
                err(1, "can't stat temporary file");
        mbufsize = sbuf.st_size;
        if (!(mbuf = malloc((u_int)mbufsize)))
Index: usr.bin/sdiff/common.c
===================================================================
RCS file: /cvs/src/usr.bin/sdiff/common.c,v
retrieving revision 1.4
diff -u -p -u -r1.4 common.c
--- usr.bin/sdiff/common.c      25 May 2006 03:20:32 -0000      1.4
+++ usr.bin/sdiff/common.c      4 Jul 2019 17:50:39 -0000
@@ -14,7 +14,7 @@
 void
 cleanup(const char *filename)
 {
-       if (unlink(filename))
+       if (unlink(filename) == -1)
                err(2, "could not delete: %s", filename);
        exit(2);
 }
Index: usr.bin/sdiff/edit.c
===================================================================
RCS file: /cvs/src/usr.bin/sdiff/edit.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 edit.c
--- usr.bin/sdiff/edit.c        26 Nov 2013 21:08:12 -0000      1.20
+++ usr.bin/sdiff/edit.c        4 Jul 2019 17:50:50 -0000
@@ -196,7 +196,7 @@ RIGHT:
        }
 
        /* We've reached the end of the temporary file, so remove it. */
-       if (unlink(filename))
+       if (unlink(filename) == -1)
                warn("could not delete: %s", filename);
        fclose(file);
 
Index: usr.bin/sdiff/sdiff.c
===================================================================
RCS file: /cvs/src/usr.bin/sdiff/sdiff.c,v
retrieving revision 1.37
diff -u -p -u -r1.37 sdiff.c
--- usr.bin/sdiff/sdiff.c       28 Sep 2018 18:21:52 -0000      1.37
+++ usr.bin/sdiff/sdiff.c       4 Jul 2019 17:51:25 -0000
@@ -309,7 +309,7 @@ main(int argc, char **argv)
                errx(2, "width is too large: %zu", width);
        line_width = width * 2 + 3;
 
-       if (pipe(fd))
+       if (pipe(fd) == -1)
                err(2, "pipe");
 
        switch(pid = fork()) {
@@ -355,10 +355,10 @@ main(int argc, char **argv)
 
        /* Delete and free unneeded temporary files. */
        if (tmp1)
-               if (unlink(tmp1))
+               if (unlink(tmp1) == -1)
                        warn("error deleting %s", tmp1);
        if (tmp2)
-               if (unlink(tmp2))
+               if (unlink(tmp2) == -1)
                        warn("error deleting %s", tmp2);
        free(tmp1);
        free(tmp2);
Index: usr.bin/sort/file.c
===================================================================
RCS file: /cvs/src/usr.bin/sort/file.c,v
retrieving revision 1.22
diff -u -p -u -r1.22 file.c
--- usr.bin/sort/file.c 15 May 2019 09:07:46 -0000      1.22
+++ usr.bin/sort/file.c 6 Jul 2019 16:07:36 -0000
@@ -537,10 +537,10 @@ file_reader_init(const char *fsrc)
                int fd;
 
                fd = open(fsrc, O_RDONLY);
-               if (fd < 0)
+               if (fd == -1)
                        err(2, "%s", fsrc);
 
-               if (fstat(fd, &stat_buf) < 0)
+               if (fstat(fd, &stat_buf) == -1)
                        err(2, "%s", fsrc);
                sz = stat_buf.st_size;
 
Index: usr.bin/ssh/scp.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/scp.c,v
retrieving revision 1.205
diff -u -p -u -r1.205 scp.c
--- usr.bin/ssh/scp.c   28 Jun 2019 13:35:04 -0000      1.205
+++ usr.bin/ssh/scp.c   6 Jul 2019 16:08:33 -0000
@@ -1602,7 +1602,7 @@ verifydir(char *cp)
 {
        struct stat stb;
 
-       if (!stat(cp, &stb)) {
+       if (stat(cp, &stb) == 0) {
                if (S_ISDIR(stb.st_mode))
                        return;
                errno = ENOTDIR;
Index: usr.bin/tail/tail.c
===================================================================
RCS file: /cvs/src/usr.bin/tail/tail.c,v
retrieving revision 1.22
diff -u -p -u -r1.22 tail.c
--- usr.bin/tail/tail.c 4 Jan 2019 15:04:28 -0000       1.22
+++ usr.bin/tail/tail.c 6 Jul 2019 16:04:02 -0000
@@ -155,7 +155,7 @@ main(int argc, char *argv[])
                for (i = 0; *argv; i++) {
                        tf[i].fname = *argv++;
                        if ((tf[i].fp = fopen(tf[i].fname, "r")) == NULL ||
-                           fstat(fileno(tf[i].fp), &(tf[i].sb))) {
+                           fstat(fileno(tf[i].fp), &(tf[i].sb)) == -1) {
                                ierr(tf[i].fname);
                                i--;
                                continue;
@@ -173,7 +173,7 @@ main(int argc, char *argv[])
                tf[0].fname = "stdin";
                tf[0].fp = stdin;
 
-               if (fstat(fileno(stdin), &(tf[0].sb))) {
+               if (fstat(fileno(stdin), &(tf[0].sb)) == -1) {
                        ierr(tf[0].fname);
                        exit(1);
                }
Index: usr.bin/tcpbench/tcpbench.c
===================================================================
RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.c,v
retrieving revision 1.59
diff -u -p -u -r1.59 tcpbench.c
--- usr.bin/tcpbench/tcpbench.c 28 Sep 2018 19:01:52 -0000      1.59
+++ usr.bin/tcpbench/tcpbench.c 4 Jul 2019 17:59:00 -0000
@@ -1226,7 +1226,7 @@ main(int argc, char **argv)
                err(1, "getrlimit");
        if (rl.rlim_cur < MAX_FD)
                rl.rlim_cur = MAX_FD;
-       if (setrlimit(RLIMIT_NOFILE, &rl))
+       if (setrlimit(RLIMIT_NOFILE, &rl) == -1)
                err(1, "setrlimit");
        if (getrlimit(RLIMIT_NOFILE, &rl) == -1)
                err(1, "getrlimit");
Index: usr.bin/telnet/sys_bsd.c
===================================================================
RCS file: /cvs/src/usr.bin/telnet/sys_bsd.c,v
retrieving revision 1.35
diff -u -p -u -r1.35 sys_bsd.c
--- usr.bin/telnet/sys_bsd.c    28 Jun 2019 13:35:04 -0000      1.35
+++ usr.bin/telnet/sys_bsd.c    11 Jul 2019 04:44:51 -0000
@@ -188,14 +188,15 @@ TerminalNewMode(int f)
 {
     static int prevmode = 0;
     struct termios tmp_tc;
-    int onoff;
-    int old;
+    int onoff, old, save_errno;
     cc_t esc;
 
     globalmode = f&~MODE_FORCE;
     if (prevmode == f)
        return;
 
+    save_errno = errno;
+
     /*
      * Write any outstanding data before switching modes
      * ttyflush() returns 0 only when there is no more data
@@ -360,6 +361,8 @@ TerminalNewMode(int f)
 
     ioctl(tin, FIONBIO, &onoff);
     ioctl(tout, FIONBIO, &onoff);
+
+    errno = save_errno;
 }
 
 void
Index: usr.bin/touch/touch.c
===================================================================
RCS file: /cvs/src/usr.bin/touch/touch.c,v
retrieving revision 1.26
diff -u -p -u -r1.26 touch.c
--- usr.bin/touch/touch.c       10 Mar 2019 15:11:52 -0000      1.26
+++ usr.bin/touch/touch.c       6 Jul 2019 16:06:34 -0000
@@ -123,7 +123,7 @@ main(int argc, char *argv[])
 
        for (rval = 0; *argv; ++argv) {
                /* Update the file's timestamp if it exists. */
-               if (! utimensat(AT_FDCWD, *argv, ts, 0))
+               if (utimensat(AT_FDCWD, *argv, ts, 0) == 0)
                        continue;
                if (errno != ENOENT) {
                        rval = 1;
@@ -268,7 +268,7 @@ stime_file(char *fname, struct timespec 
 {
        struct stat     sb;
 
-       if (stat(fname, &sb))
+       if (stat(fname, &sb) == -1)
                err(1, "%s", fname);
        tsp[0] = sb.st_atim;
        tsp[1] = sb.st_mtim;
Index: usr.bin/uuencode/uuencode.c
===================================================================
RCS file: /cvs/src/usr.bin/uuencode/uuencode.c,v
retrieving revision 1.15
diff -u -p -u -r1.15 uuencode.c
--- usr.bin/uuencode/uuencode.c 10 Mar 2019 20:49:24 -0000      1.15
+++ usr.bin/uuencode/uuencode.c 6 Jul 2019 16:08:18 -0000
@@ -104,7 +104,7 @@ main(int argc, char *argv[])
 
        switch(argc) {
        case 2:                 /* optional first argument is input file */
-               if (!freopen(*argv, "r", stdin) || fstat(fileno(stdin), &sb))
+               if (!freopen(*argv, "r", stdin) || fstat(fileno(stdin), &sb) == 
-1)
                        err(1, "%s", *argv);
 #define        RWX     (S_IRWXU|S_IRWXG|S_IRWXO)
                mode = sb.st_mode & RWX;
Index: usr.bin/w/w.c
===================================================================
RCS file: /cvs/src/usr.bin/w/w.c,v
retrieving revision 1.66
diff -u -p -u -r1.66 w.c
--- usr.bin/w/w.c       28 Jun 2019 13:35:05 -0000      1.66
+++ usr.bin/w/w.c       6 Jul 2019 16:04:41 -0000
@@ -495,7 +495,7 @@ ttystat(char *line)
        /* Note, line may not be NUL-terminated */
        (void)strlcpy(ttybuf, _PATH_DEV, sizeof(ttybuf));
        (void)strncat(ttybuf, line, sizeof(ttybuf) - 1 - strlen(ttybuf));
-       if (stat(ttybuf, &sb))
+       if (stat(ttybuf, &sb) == -1)
                return (NULL);
        return (&sb);
 }
Index: usr.bin/wall/wall.c
===================================================================
RCS file: /cvs/src/usr.bin/wall/wall.c,v
retrieving revision 1.34
diff -u -p -u -r1.34 wall.c
--- usr.bin/wall/wall.c 28 Jan 2019 20:17:51 -0000      1.34
+++ usr.bin/wall/wall.c 4 Jul 2019 19:06:31 -0000
@@ -244,7 +244,7 @@ makemsg(char *fname)
        (void)fprintf(fp, "%79s\r\n", " ");
        rewind(fp);
 
-       if (fstat(fd, &sbuf))
+       if (fstat(fd, &sbuf) == -1)
                err(1, "can't stat temporary file");
        mbufsize = sbuf.st_size;
        mbuf = malloc((u_int)mbufsize);
Index: usr.bin/wc/wc.c
===================================================================
RCS file: /cvs/src/usr.bin/wc/wc.c,v
retrieving revision 1.26
diff -u -p -u -r1.26 wc.c
--- usr.bin/wc/wc.c     28 Jun 2019 13:35:05 -0000      1.26
+++ usr.bin/wc/wc.c     6 Jul 2019 16:04:28 -0000
@@ -172,7 +172,7 @@ cnt(char *file)
                else if (dochar) {
                        mode_t ifmt;
 
-                       if (fstat(fd, &sbuf)) {
+                       if (fstat(fd, &sbuf) == -1) {
                                warn("%s", file);
                                rval = 1;
                        } else {
Index: usr.bin/xinstall/xinstall.c
===================================================================
RCS file: /cvs/src/usr.bin/xinstall/xinstall.c,v
retrieving revision 1.73
diff -u -p -u -r1.73 xinstall.c
--- usr.bin/xinstall/xinstall.c 28 Jun 2019 13:35:05 -0000      1.73
+++ usr.bin/xinstall/xinstall.c 4 Jul 2019 19:07:28 -0000
@@ -197,7 +197,7 @@ main(int argc, char *argv[])
                errx(1, "Target: %s", argv[argc-1]);
 
        if (!no_target) {
-               if (stat(*argv, &from_sb))
+               if (stat(*argv, &from_sb) == -1)
                        err(1, "%s", *argv);
                if (!S_ISREG(to_sb.st_mode))
                        errc(1, EFTYPE, "%s", to_name);
@@ -228,7 +228,7 @@ install(char *from_name, char *to_name, 
 
        /* If try to install NULL file to a directory, fails. */
        if (flags & DIRECTORY || strcmp(from_name, _PATH_DEVNULL)) {
-               if (stat(from_name, &from_sb))
+               if (stat(from_name, &from_sb) == -1)
                        err(1, "%s", from_name);
                if (!S_ISREG(from_sb.st_mode))
                        errc(1, EFTYPE, "%s", from_name);
@@ -291,7 +291,7 @@ install(char *from_name, char *to_name, 
                if ((to_fd = open(to_name, O_RDONLY, 0)) == -1)
                        err(1, "%s", to_name);
 
-               if (fstat(temp_fd, &temp_sb)) {
+               if (fstat(temp_fd, &temp_sb) == -1) {
                        serrno = errno;
                        (void)unlink(tempfile);
                        errc(1, serrno, "%s", tempfile);
@@ -576,7 +576,7 @@ install_dir(char *path, int mode)
                        *p = '\0';
                        if (mkdir(path, 0777)) {
                                int mkdir_errno = errno;
-                               if (stat(path, &sb)) {
+                               if (stat(path, &sb) == -1) {
                                        /* Not there; use mkdir()s errno */
                                        errc(1, mkdir_errno, "%s",
                                            path);
Index: usr.bin/vi/cl/cl_term.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
retrieving revision 1.28
diff -u -p -u -r1.28 cl_term.c
--- usr.bin/vi/cl/cl_term.c     20 Jul 2017 08:37:48 -0000      1.28
+++ usr.bin/vi/cl/cl_term.c     6 Jul 2019 15:53:26 -0000
@@ -259,7 +259,7 @@ cl_omesg(SCR *sp, CL_PRIVATE *clp, int o
                        msgq(sp, M_SYSERR, "stderr");
                return (1);
        }
-       if (stat(tty, &sb) < 0) {
+       if (stat(tty, &sb) == -1) {
                if (sp != NULL)
                        msgq(sp, M_SYSERR, "%s", tty);
                return (1);
@@ -272,14 +272,14 @@ cl_omesg(SCR *sp, CL_PRIVATE *clp, int o
 
        /* Toggle the permissions. */
        if (on) {
-               if (chmod(tty, sb.st_mode | S_IWGRP) < 0) {
+               if (chmod(tty, sb.st_mode | S_IWGRP) == -1) {
                        if (sp != NULL)
                                msgq(sp, M_SYSERR,
                                    "messages not turned on: %s", tty);
                        return (1);
                }
        } else
-               if (chmod(tty, sb.st_mode & ~S_IWGRP) < 0) {
+               if (chmod(tty, sb.st_mode & ~S_IWGRP) == -1) {
                        if (sp != NULL)
                                msgq(sp, M_SYSERR,
                                    "messages not turned off: %s", tty);
Index: usr.bin/vi/common/exf.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
retrieving revision 1.46
diff -u -p -u -r1.46 exf.c
--- usr.bin/vi/common/exf.c     26 Apr 2017 13:14:28 -0000      1.46
+++ usr.bin/vi/common/exf.c     6 Jul 2019 15:57:24 -0000
@@ -458,7 +458,7 @@ file_spath(SCR *sp, FREF *frp, struct st
        }
 
        /* Try . */
-       if (!stat(name, sbp)) {
+       if (stat(name, sbp) == 0) {
                *existsp = 1;
                return (0);
        }
@@ -474,7 +474,7 @@ file_spath(SCR *sp, FREF *frp, struct st
                                if (len >= sizeof(path))
                                        len = sizeof(path) - 1;
                                *p = savech;
-                               if (!stat(path, sbp)) {
+                               if (stat(path, sbp) == 0) {
                                        found = 1;
                                        break;
                                }
@@ -752,7 +752,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, 
        if (!LF_ISSET(FS_FORCE | FS_APPEND) && !O_ISSET(sp, O_WRITEANY)) {
                /* Don't overwrite anything but the original file. */
                if ((!noname || F_ISSET(frp, FR_NAMECHANGE)) &&
-                   !stat(name, &sb)) {
+                   stat(name, &sb) == 0) {
                        msgq_str(sp, M_ERR, name,
                            LF_ISSET(FS_POSSIBLE) ?
                            "%s exists, not written; use ! to override" :
@@ -764,7 +764,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, 
                 * Don't write part of any existing file.  Only test for the
                 * original file, the previous test catches anything else.
                 */
-               if (!LF_ISSET(FS_ALL) && noname && !stat(name, &sb)) {
+               if (!LF_ISSET(FS_ALL) && noname && stat(name, &sb) == 0) {
                        msgq(sp, M_ERR, LF_ISSET(FS_POSSIBLE) ?
                            "Partial file, not written; use ! to override" :
                            "Partial file, not written");
@@ -783,7 +783,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, 
         * and we have a saved modification time, object if the file changed
         * since we last edited or wrote it, and make them force it.
         */
-       if (stat(name, &sb))
+       if (stat(name, &sb) == -1)
                mtype = NEWFILE;
        else {
                if (noname && !LF_ISSET(FS_FORCE | FS_APPEND) &&
@@ -810,7 +810,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, 
 
        /* Open the file. */
        if ((fd = open(name, oflags,
-           S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0) {
+           S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1) {
                msgq_str(sp, M_SYSERR, name, "%s");
                return (1);
        }
@@ -852,7 +852,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, 
         * and rewrite without having to force it.
         */
        if (noname) {
-               if (stat(name, &sb))
+               if (stat(name, &sb) == -1)
                        (void)clock_gettime(CLOCK_REALTIME, &ep->mtim);
                else {
                        F_SET(ep, F_DEVSET);
@@ -977,7 +977,7 @@ file_backup(SCR *sp, char *name, char *b
         * up.
         */
        errno = 0;
-       if ((rfd = open(name, O_RDONLY, 0)) < 0) {
+       if ((rfd = open(name, O_RDONLY, 0)) == -1) {
                if (errno == ENOENT)
                        return (0);
                estr = name;
@@ -1085,8 +1085,8 @@ file_backup(SCR *sp, char *name, char *b
                flags = O_TRUNC;
        } else
                flags = O_CREAT | O_EXCL;
-       if ((wfd = open(wfname, flags | O_WRONLY, S_IRUSR | S_IWUSR)) < 0 ||
-           fchmod(wfd, S_IRUSR | S_IWUSR) < 0) {
+       if ((wfd = open(wfname, flags | O_WRONLY, S_IRUSR | S_IWUSR)) == -1 ||
+           fchmod(wfd, S_IRUSR | S_IWUSR) == -1) {
                if (wfd != -1) {
                        close(wfd);
                        (void)unlink(wfname);
@@ -1098,11 +1098,11 @@ file_backup(SCR *sp, char *name, char *b
        /* Copy the file's current contents to its backup value. */
        while ((nr = read(rfd, buf, sizeof(buf))) > 0)
                for (off = 0; nr != 0; nr -= nw, off += nw)
-                       if ((nw = write(wfd, buf + off, nr)) < 0) {
+                       if ((nw = write(wfd, buf + off, nr)) == -1) {
                                estr = wfname;
                                goto err;
                        }
-       if (nr < 0) {
+       if (nr == -1) {
                estr = name;
                goto err;
        }
Index: usr.bin/vi/common/main.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.41
diff -u -p -u -r1.41 main.c
--- usr.bin/vi/common/main.c    10 Nov 2017 18:31:36 -0000      1.41
+++ usr.bin/vi/common/main.c    6 Jul 2019 15:54:31 -0000
@@ -576,7 +576,7 @@ attach(GS *gp)
        int fd;
        char ch;
 
-       if ((fd = open(_PATH_TTY, O_RDONLY, 0)) < 0) {
+       if ((fd = open(_PATH_TTY, O_RDONLY, 0)) == -1) {
                warn("%s", _PATH_TTY);
                return;
        }
Index: usr.bin/vi/common/recover.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/recover.c,v
retrieving revision 1.30
diff -u -p -u -r1.30 recover.c
--- usr.bin/vi/common/recover.c 22 Jul 2019 12:39:02 -0000      1.30
+++ usr.bin/vi/common/recover.c 23 Jul 2019 05:06:35 -0000
@@ -135,7 +135,7 @@ rcv_tmp(SCR *sp, EXF *ep, char *name)
        if (opts_empty(sp, O_RECDIR, 0))
                goto err;
        dp = O_STR(sp, O_RECDIR);
-       if (stat(dp, &sb)) {
+       if (stat(dp, &sb) == -1) {
                if (!warned) {
                        warned = 1;
                        msgq(sp, M_SYSERR, "%s", dp);
@@ -568,7 +568,7 @@ rcv_list(SCR *sp)
                 * before deleting the email file.
                 */
                errno = 0;
-               if (stat(path + sizeof(VI_PHEADER) - 1, &sb) &&
+               if (stat(path + sizeof(VI_PHEADER) - 1, &sb) == -1 &&
                    errno == ENOENT) {
                        (void)unlinkat(dirfd(dirp), dp->d_name, 0);
                        goto next;
@@ -652,7 +652,7 @@ rcv_read(SCR *sp, FREF *frp)
                 * before deleting the email file.
                 */
                errno = 0;
-               if (stat(path + sizeof(VI_PHEADER) - 1, &sb) &&
+               if (stat(path + sizeof(VI_PHEADER) - 1, &sb) == -1 &&
                    errno == ENOENT) {
                        (void)unlink(dp->d_name);
                        goto next;
Index: usr.bin/vi/ex/ex_argv.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_argv.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 ex_argv.c
--- usr.bin/vi/ex/ex_argv.c     27 May 2016 09:18:12 -0000      1.20
+++ usr.bin/vi/ex/ex_argv.c     6 Jul 2019 15:55:27 -0000
@@ -610,7 +610,7 @@ argv_sexp(SCR *sp, char **bpp, size_t *b
         */
        ifp = NULL;
        std_output[0] = std_output[1] = -1;
-       if (pipe(std_output) < 0) {
+       if (pipe(std_output) == -1) {
                msgq(sp, M_SYSERR, "pipe");
                return (1);
        }
Index: usr.bin/vi/ex/ex_filter.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_filter.c,v
retrieving revision 1.15
diff -u -p -u -r1.15 ex_filter.c
--- usr.bin/vi/ex/ex_filter.c   1 Aug 2016 18:27:35 -0000       1.15
+++ usr.bin/vi/ex/ex_filter.c   6 Jul 2019 15:54:45 -0000
@@ -111,13 +111,13 @@ ex_filter(SCR *sp, EXCMD *cmdp, MARK *fm
                        msgq(sp, M_SYSERR, "lseek");
                        goto err;
                }
-       } else if (ftype != FILTER_READ && pipe(input) < 0) {
+       } else if (ftype != FILTER_READ && pipe(input) == -1) {
                msgq(sp, M_SYSERR, "pipe");
                goto err;
        }
 
        /* Open up utility output pipe. */
-       if (pipe(output) < 0) {
+       if (pipe(output) == -1) {
                msgq(sp, M_SYSERR, "pipe");
                goto err;
        }
Index: usr.bin/vi/ex/ex_init.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_init.c,v
retrieving revision 1.18
diff -u -p -u -r1.18 ex_init.c
--- usr.bin/vi/ex/ex_init.c     18 Apr 2017 01:45:35 -0000      1.18
+++ usr.bin/vi/ex/ex_init.c     6 Jul 2019 15:58:43 -0000
@@ -341,7 +341,7 @@ exrc_isok(SCR *sp, struct stat *sbp, int
        int nf1, nf2;
        char *a, *b, buf[PATH_MAX];
 
-       if ((*fdp = open(path, O_RDONLY, 0)) < 0) {
+       if ((*fdp = open(path, O_RDONLY, 0)) == -1) {
                if (errno == ENOENT)
                         /* This is the only case where ex_exrc()
                          * should silently try the next file, for
@@ -353,7 +353,7 @@ exrc_isok(SCR *sp, struct stat *sbp, int
                return (NOPERM);
        }
 
-       if (fstat(*fdp, sbp)) {
+       if (fstat(*fdp, sbp) == -1) {
                msgq_str(sp, M_SYSERR, path, "%s");
                close(*fdp);
                return (NOPERM);
Index: usr.bin/vi/ex/ex_mkexrc.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_mkexrc.c,v
retrieving revision 1.7
diff -u -p -u -r1.7 ex_mkexrc.c
--- usr.bin/vi/ex/ex_mkexrc.c   6 Jan 2016 22:28:52 -0000       1.7
+++ usr.bin/vi/ex/ex_mkexrc.c   6 Jul 2019 16:00:06 -0000
@@ -54,7 +54,7 @@ ex_mkexrc(SCR *sp, EXCMD *cmdp)
                abort();
        }
 
-       if (!FL_ISSET(cmdp->iflags, E_C_FORCE) && !stat(fname, &sb)) {
+       if (!FL_ISSET(cmdp->iflags, E_C_FORCE) && stat(fname, &sb) == 0) {
                msgq_str(sp, M_ERR, fname,
                    "%s exists, not written; use ! to override");
                return (1);
@@ -62,7 +62,7 @@ ex_mkexrc(SCR *sp, EXCMD *cmdp)
 
        /* Create with max permissions of rw-r--r--. */
        if ((fd = open(fname, O_CREAT | O_TRUNC | O_WRONLY,
-           S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
+           S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1) {
                msgq_str(sp, M_SYSERR, fname, "%s");
                return (1);
        }
Index: usr.bin/vi/ex/ex_source.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_source.c,v
retrieving revision 1.10
diff -u -p -u -r1.10 ex_source.c
--- usr.bin/vi/ex/ex_source.c   7 Dec 2015 20:39:19 -0000       1.10
+++ usr.bin/vi/ex/ex_source.c   6 Jul 2019 16:00:21 -0000
@@ -40,7 +40,7 @@ ex_sourcefd(SCR *sp, EXCMD *cmdp, int fd
        char *bp, *name;
 
        name = cmdp->argv[0]->bp;
-       if (fstat(fd, &sb))
+       if (fstat(fd, &sb) == -1)
                goto err;
 
        /*
@@ -93,7 +93,7 @@ ex_source(SCR *sp, EXCMD *cmdp)
        int fd;
 
        name = cmdp->argv[0]->bp;
-       if ((fd = open(name, O_RDONLY, 0)) >= 0)
+       if ((fd = open(name, O_RDONLY, 0)) != -1)
                return (ex_sourcefd(sp, cmdp, fd));
 
        msgq_str(sp, M_SYSERR, name, "%s");
Index: usr.bin/vi/ex/ex_tag.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_tag.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 ex_tag.c
--- usr.bin/vi/ex/ex_tag.c      18 Apr 2017 01:45:35 -0000      1.25
+++ usr.bin/vi/ex/ex_tag.c      6 Jul 2019 15:59:04 -0000
@@ -991,7 +991,7 @@ ctag_sfile(SCR *sp, TAGF *tfp, TAGQ *tqp
        int fd, i, nf1, nf2;
        char *back, *cname, *dname, *front, *map, *name, *p, *search, *t;
 
-       if ((fd = open(tfp->name, O_RDONLY, 0)) < 0) {
+       if ((fd = open(tfp->name, O_RDONLY, 0)) == -1) {
                tfp->errnum = errno;
                return (1);
        }
@@ -1127,7 +1127,7 @@ ctag_file(SCR *sp, TAGF *tfp, char *name
         */
        *dlenp = 0;
        if (name[0] != '/' &&
-           stat(name, &sb) && (p = strrchr(tfp->name, '/')) != NULL) {
+           stat(name, &sb) == -1 && (p = strrchr(tfp->name, '/')) != NULL) {
                *p = '\0';
                (void)snprintf(buf, sizeof(buf), "%s/%s", tfp->name, name);
                if (stat(buf, &sb) == 0) {
Index: usr.bin/vi/ex/ex_write.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_write.c,v
retrieving revision 1.13
diff -u -p -u -r1.13 ex_write.c
--- usr.bin/vi/ex/ex_write.c    6 Jan 2016 22:28:52 -0000       1.13
+++ usr.bin/vi/ex/ex_write.c    6 Jul 2019 15:59:51 -0000
@@ -331,7 +331,7 @@ ex_writefp(SCR *sp, char *name, FILE *fp
         * I don't trust NFS -- check to make sure that we're talking to
         * a regular file and sync so that NFS is forced to flush.
         */
-       if (!fstat(fileno(fp), &sb) &&
+       if (fstat(fileno(fp), &sb) == 0 &&
            S_ISREG(sb.st_mode) && fsync(fileno(fp)))
                goto err;
 
Index: usr.bin/vi/vi/v_txt.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_txt.c,v
retrieving revision 1.33
diff -u -p -u -r1.33 v_txt.c
--- usr.bin/vi/vi/v_txt.c       27 May 2016 09:18:12 -0000      1.33
+++ usr.bin/vi/vi/v_txt.c       6 Jul 2019 15:59:34 -0000
@@ -2019,7 +2019,7 @@ retry:            for (len = 0,
 
                /* If haven't done a directory test, do it now. */
                if (!trydir &&
-                   !stat(cmd.argv[0]->bp, &sb) && S_ISDIR(sb.st_mode)) {
+                   stat(cmd.argv[0]->bp, &sb) == 0 && S_ISDIR(sb.st_mode)) {
                        p += len;
                        goto isdir;
                }
@@ -2075,7 +2075,7 @@ retry:            for (len = 0,
        }
 
        /* If a single match and it's a directory, retry it. */
-       if (argc == 1 && !stat(cmd.argv[0]->bp, &sb) && S_ISDIR(sb.st_mode)) {
+       if (argc == 1 && stat(cmd.argv[0]->bp, &sb) == 0 && 
S_ISDIR(sb.st_mode)) {
 isdir:         if (tp->owrite == 0) {
                        off = p - tp->lb;
                        BINC_RET(sp, tp->lb, tp->lb_len, tp->len + 1);
Index: bin/cp/utils.c
===================================================================
RCS file: /cvs/src/bin/cp/utils.c,v
retrieving revision 1.48
diff -u -p -u -r1.48 utils.c
--- bin/cp/utils.c      28 Jun 2019 13:34:58 -0000      1.48
+++ bin/cp/utils.c      6 Jul 2019 16:18:16 -0000
@@ -139,7 +139,7 @@ copy_file(FTSENT *entp, int exists)
        {
                int skipholes = 0;
                struct stat tosb;
-               if (!fstat(to_fd, &tosb) && S_ISREG(tosb.st_mode))
+               if (fstat(to_fd, &tosb) == 0 && S_ISREG(tosb.st_mode))
                        skipholes = 1;
                while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
                        if (skipholes && memcmp(buf, zeroes, rcount) == 0)
@@ -176,7 +176,7 @@ copy_file(FTSENT *entp, int exists)
        (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
        if (!pflag && !exists &&
            fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) {
-               if (fstat(to_fd, &to_stat)) {
+               if (fstat(to_fd, &to_stat) == -1) {
                        warn("%s", to.p_path);
                        rval = 1;
                } else if (fs->st_gid == to_stat.st_gid &&
Index: bin/csh/exp.c
===================================================================
RCS file: /cvs/src/bin/csh/exp.c,v
retrieving revision 1.18
diff -u -p -u -r1.18 exp.c
--- bin/csh/exp.c       18 Sep 2018 06:56:09 -0000      1.18
+++ bin/csh/exp.c       6 Jul 2019 16:17:16 -0000
@@ -404,7 +404,7 @@ exp6(Char ***vp, bool ignore)
         * an error.  Even this check isn't quite right, since it doesn't take
         * globbing into account.
         */
-       if (isa(**vp, ANYOP) && stat(short2str(**vp), &stb))
+       if (isa(**vp, ANYOP) && stat(short2str(**vp), &stb) == -1)
            stderror(ERR_NAME | ERR_FILENAME);
 
        dp = *(*vp)++;
Index: bin/dd/dd.c
===================================================================
RCS file: /cvs/src/bin/dd/dd.c,v
retrieving revision 1.27
diff -u -p -u -r1.27 dd.c
--- bin/dd/dd.c 28 Jun 2019 13:34:59 -0000      1.27
+++ bin/dd/dd.c 6 Jul 2019 16:18:24 -0000
@@ -206,7 +206,7 @@ getfdtype(IO *io)
        struct mtget mt;
        struct stat sb;
 
-       if (fstat(io->fd, &sb))
+       if (fstat(io->fd, &sb) == -1)
                err(1, "%s", io->name);
        if (S_ISCHR(sb.st_mode))
                io->flags |= ioctl(io->fd, MTIOCGET, &mt) ? ISCHR : ISTAPE;
Index: bin/ed/main.c
===================================================================
RCS file: /cvs/src/bin/ed/main.c,v
retrieving revision 1.66
diff -u -p -u -r1.66 main.c
--- bin/ed/main.c       28 Jun 2019 13:34:59 -0000      1.66
+++ bin/ed/main.c       6 Jul 2019 16:16:41 -0000
@@ -166,7 +166,7 @@ top:
                struct stat sb;
 
                /* assert: pipes show up as fifo's when fstat'd */
-               if (fstat(STDIN_FILENO, &sb) || !S_ISFIFO(sb.st_mode)) {
+               if (fstat(STDIN_FILENO, &sb) == -1 || !S_ISFIFO(sb.st_mode)) {
                        if (lseek(STDIN_FILENO, 0, SEEK_CUR)) {
                                interactive = 1;
                                setvbuf(stdout, NULL, _IOLBF, 0);
Index: bin/ln/ln.c
===================================================================
RCS file: /cvs/src/bin/ln/ln.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 ln.c
--- bin/ln/ln.c 28 Jun 2019 13:34:59 -0000      1.25
+++ bin/ln/ln.c 6 Jul 2019 16:18:32 -0000
@@ -96,7 +96,7 @@ main(int argc, char *argv[])
        }
                                        /* ln target1 target2 directory */
        sourcedir = argv[argc - 1];
-       if (stat(sourcedir, &sb))
+       if (stat(sourcedir, &sb) == -1)
                err(1, "%s", sourcedir);
        if (!S_ISDIR(sb.st_mode))
                usage();
Index: bin/mv/cp.c
===================================================================
RCS file: /cvs/src/bin/mv/cp.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 cp.c
--- bin/mv/cp.c 28 Jun 2019 13:34:59 -0000      1.8
+++ bin/mv/cp.c 6 Jul 2019 16:18:47 -0000
@@ -530,7 +530,7 @@ copy_file(FTSENT *entp, int dne)
        {
                int skipholes = 0;
                struct stat tosb;
-               if (!fstat(to_fd, &tosb) && S_ISREG(tosb.st_mode))
+               if (fstat(to_fd, &tosb) == 0 && S_ISREG(tosb.st_mode))
                        skipholes = 1;
                while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
                        if (skipholes && memcmp(buf, zeroes, rcount) == 0)
Index: bin/mv/mv.c
===================================================================
RCS file: /cvs/src/bin/mv/mv.c,v
retrieving revision 1.46
diff -u -p -u -r1.46 mv.c
--- bin/mv/mv.c 28 Jun 2019 13:34:59 -0000      1.46
+++ bin/mv/mv.c 6 Jul 2019 16:19:09 -0000
@@ -99,7 +99,7 @@ main(int argc, char *argv[])
         * If the stat on the target fails or the target isn't a directory,
         * try the move.  More than 2 arguments is an error in this case.
         */
-       if (stat(argv[argc - 1], &sb) || !S_ISDIR(sb.st_mode)) {
+       if (stat(argv[argc - 1], &sb) == -1 || !S_ISDIR(sb.st_mode)) {
                if (argc > 2)
                        usage();
                exit(do_move(argv[0], argv[1]));
@@ -157,7 +157,7 @@ do_move(char *from, char *to)
        char modep[15];
 
        /* Source path must exist (symlink is OK). */
-       if (lstat(from, &fsb)) {
+       if (lstat(from, &fsb) == -1) {
                warn("%s", from);
                return (1);
        }
@@ -181,7 +181,7 @@ do_move(char *from, char *to)
 
                if (iflg && !access(from, F_OK)) {
                        (void)fprintf(stderr, "overwrite %s? ", to);
-               } else if (stdin_ok && access(to, W_OK) && !stat(to, &sb)) {
+               } else if (stdin_ok && access(to, W_OK) && stat(to, &sb) == 0) {
                        strmode(sb.st_mode, modep);
                        (void)fprintf(stderr, "override %s%s%s/%s for %s? ",
                            modep + 1, modep[9] == ' ' ? "" : " ",
@@ -243,7 +243,7 @@ do_move(char *from, char *to)
         *      message to the standard error and do nothing more with the
         *      current source file...
         */
-       if (!lstat(to, &sb)) {
+       if (lstat(to, &sb) == 0) {
                if ((S_ISDIR(sb.st_mode)) ? rmdir(to) : unlink(to)) {
                        warn("can't remove %s", to);
                        return (1);
Index: bin/pax/options.c
===================================================================
RCS file: /cvs/src/bin/pax/options.c,v
retrieving revision 1.102
diff -u -p -u -r1.102 options.c
--- bin/pax/options.c   13 Sep 2018 12:33:43 -0000      1.102
+++ bin/pax/options.c   6 Jul 2019 16:19:16 -0000
@@ -1123,7 +1123,7 @@ mkpath(path)
                done = (*slash == '\0');
                *slash = '\0';
 
-               if (stat(path, &sb)) {
+               if (stat(path, &sb) == -1) {
                        if (errno != ENOENT || mkdir(path, 0777)) {
                                paxwarn(1, "%s", path);
                                return (-1);
Index: bin/rm/rm.c
===================================================================
RCS file: /cvs/src/bin/rm/rm.c,v
retrieving revision 1.42
diff -u -p -u -r1.42 rm.c
--- bin/rm/rm.c 27 Jun 2017 21:49:47 -0000      1.42
+++ bin/rm/rm.c 6 Jul 2019 16:19:31 -0000
@@ -246,7 +246,7 @@ rm_file(char **argv)
         */
        while ((f = *argv++) != NULL) {
                /* Assume if can't stat the file, can't unlink it. */
-               if (lstat(f, &sb)) {
+               if (lstat(f, &sb) == -1) {
                        if (!fflag || errno != ENOENT) {
                                warn("%s", f);
                                eval = 1;
@@ -299,7 +299,7 @@ rm_overwrite(char *file, struct stat *sb
 
        fd = -1;
        if (sbp == NULL) {
-               if (lstat(file, &sb))
+               if (lstat(file, &sb) == -1)
                        goto err;
                sbp = &sb;
        }
@@ -312,7 +312,7 @@ rm_overwrite(char *file, struct stat *sb
        }
        if ((fd = open(file, O_WRONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1)
                goto err;
-       if (fstat(fd, &sb2))
+       if (fstat(fd, &sb2) == -1)
                goto err;
        if (sb2.st_dev != sbp->st_dev || sb2.st_ino != sbp->st_ino ||
            !S_ISREG(sb2.st_mode)) {
Index: lib/libossaudio/ossaudio.c
===================================================================
RCS file: /cvs/src/lib/libossaudio/ossaudio.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 ossaudio.c
--- lib/libossaudio/ossaudio.c  28 Jun 2019 13:32:42 -0000      1.20
+++ lib/libossaudio/ossaudio.c  6 Jul 2019 16:09:11 -0000
@@ -172,7 +172,7 @@ getdevinfo(int fd)
        /* Figure out what device it is so we can check if the
         * cached data is valid.
         */
-       if (fstat(fd, &sb) < 0)
+       if (fstat(fd, &sb) == -1)
                return 0;
        if (di->done && (di->dev == sb.st_dev && di->ino == sb.st_ino))
                return di;
Index: games/hack/hack.unix.c
===================================================================
RCS file: /cvs/src/games/hack/hack.unix.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 hack.unix.c
--- games/hack/hack.unix.c      11 Sep 2016 14:21:17 -0000      1.20
+++ games/hack/hack.unix.c      6 Jul 2019 16:16:05 -0000
@@ -190,7 +190,7 @@ gethdate(char *name)
 int
 uptodate(int fd)
 {
-       if(fstat(fd, &buf)) {
+       if(fstat(fd, &buf) == -1) {
                pline("Cannot get status of saved level? ");
                return(0);
        }
@@ -208,7 +208,7 @@ veryold(int fd)
        int i;
        time_t date;
 
-       if(fstat(fd, &buf)) return(0);                  /* cannot get status */
+       if(fstat(fd, &buf) == -1) return(0);            /* cannot get status */
        if(buf.st_size != sizeof(int)) return(0);       /* not an xlock file */
        (void) time(&date);
        if(date - buf.st_mtime < 3L*24L*60L*60L) {      /* recent */
@@ -231,7 +231,7 @@ veryold(int fd)
                (void) unlink(lock);
        }
        glo(0);
-       if(unlink(lock)) return(0);                     /* cannot remove it */
+       if(unlink(lock) == -1) return(0);               /* cannot remove it */
        return(1);                                      /* success! */
 }
 
@@ -346,7 +346,7 @@ getmailstatus(void)
 {
        if(!(mailbox = getenv("MAIL")))
                return;
-       if(stat(mailbox, &omstat)){
+       if(stat(mailbox, &omstat) == -1){
 #ifdef PERMANENT_MAILBOX
                pline("Cannot get status of MAIL=%s .", mailbox);
                mailbox = 0;
@@ -366,7 +366,7 @@ ckmailstatus(void)
                                                        )
                return;
        laststattime = moves;
-       if(stat(mailbox, &nmstat)){
+       if(stat(mailbox, &nmstat) == -1){
 #ifdef PERMANENT_MAILBOX
                pline("Cannot get status of MAIL=%s anymore.", mailbox);
                mailbox = 0;
Index: libexec/comsat/comsat.c
===================================================================
RCS file: /cvs/src/libexec/comsat/comsat.c,v
retrieving revision 1.49
diff -u -p -u -r1.49 comsat.c
--- libexec/comsat/comsat.c     24 Sep 2018 22:56:54 -0000      1.49
+++ libexec/comsat/comsat.c     6 Jul 2019 16:11:55 -0000
@@ -259,7 +259,7 @@ notify(struct utmp *utp, off_t offset)
                syslog(LOG_AUTH | LOG_NOTICE, "'/' in \"%s\"", tty);
                return;
        }
-       if (stat(tty, &stb) || !(stb.st_mode & S_IEXEC)) {
+       if (stat(tty, &stb) == -1 || !(stb.st_mode & S_IEXEC)) {
                dsyslog(LOG_DEBUG, "%.*s: wrong mode on %s",
                    (int)sizeof(utp->ut_name), utp->ut_name, tty);
                return;
Index: sbin/ipsecctl/ipsecctl.c
===================================================================
RCS file: /cvs/src/sbin/ipsecctl/ipsecctl.c,v
retrieving revision 1.84
diff -u -p -u -r1.84 ipsecctl.c
--- sbin/ipsecctl/ipsecctl.c    7 Sep 2018 12:43:30 -0000       1.84
+++ sbin/ipsecctl/ipsecctl.c    6 Jul 2019 16:16:18 -0000
@@ -145,7 +145,7 @@ ipsecctl_fopen(const char *name, const c
        if (fp == NULL)
                return (NULL);
 
-       if (fstat(fileno(fp), &st)) {
+       if (fstat(fileno(fp), &st) == -1) {
                fclose(fp);
                return (NULL);
        }
Index: sbin/ncheck_ffs/ncheck_ffs.c
===================================================================
RCS file: /cvs/src/sbin/ncheck_ffs/ncheck_ffs.c,v
retrieving revision 1.55
diff -u -p -u -r1.55 ncheck_ffs.c
--- sbin/ncheck_ffs/ncheck_ffs.c        3 Jul 2019 03:24:02 -0000       1.55
+++ sbin/ncheck_ffs/ncheck_ffs.c        6 Jul 2019 16:11:28 -0000
@@ -560,7 +560,7 @@ main(int argc, char *argv[])
 
        disk = argv[optind];
        if ((diskfd = opendev(disk, O_RDONLY, 0, NULL)) >= 0) {
-               if (fstat(diskfd, &stblock))
+               if (fstat(diskfd, &stblock) == -1)
                        err(1, "cannot stat %s", disk);
                if (S_ISCHR(stblock.st_mode))
                        goto gotdev;
Index: sbin/savecore/savecore.c
===================================================================
RCS file: /cvs/src/sbin/savecore/savecore.c,v
retrieving revision 1.62
diff -u -p -u -r1.62 savecore.c
--- sbin/savecore/savecore.c    28 Jun 2019 13:32:46 -0000      1.62
+++ sbin/savecore/savecore.c    6 Jul 2019 16:11:22 -0000
@@ -568,7 +568,7 @@ find_dev(dev_t dev, int type)
        while ((dir = readdir(dfd))) {
                (void)strlcpy(devname + sizeof(_PATH_DEV) - 1, dir->d_name,
                    sizeof devname - (sizeof(_PATH_DEV) - 1));
-               if (lstat(devname, &sb)) {
+               if (lstat(devname, &sb) == -1) {
                        syslog(LOG_ERR, "%s: %s", devname, strerror(errno));
                        continue;
                }
Index: usr.sbin/dev_mkdb/dev_mkdb.c
===================================================================
RCS file: /cvs/src/usr.sbin/dev_mkdb/dev_mkdb.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 dev_mkdb.c
--- usr.sbin/dev_mkdb/dev_mkdb.c        18 Oct 2018 14:37:01 -0000      1.17
+++ usr.sbin/dev_mkdb/dev_mkdb.c        6 Jul 2019 16:08:01 -0000
@@ -111,7 +111,7 @@ main(int argc, char *argv[])
                if (strcmp(dp->d_name, "..") == 0)
                        continue;
 
-               if (lstat(dp->d_name, &sb)) {
+               if (lstat(dp->d_name, &sb) == -1) {
                        warn("%s", dp->d_name);
                        continue;
                }
Index: usr.sbin/hostapd/hostapd.c
===================================================================
RCS file: /cvs/src/usr.sbin/hostapd/hostapd.c,v
retrieving revision 1.41
diff -u -p -u -r1.41 hostapd.c
--- usr.sbin/hostapd/hostapd.c  3 Jul 2019 03:24:03 -0000       1.41
+++ usr.sbin/hostapd/hostapd.c  6 Jul 2019 16:03:40 -0000
@@ -145,7 +145,7 @@ hostapd_check_file_secrecy(int fd, const
 {
        struct stat st;
 
-       if (fstat(fd, &st)) {
+       if (fstat(fd, &st) == -1) {
                hostapd_log(HOSTAPD_LOG,
                    "cannot stat %s", fname);
                return (-1);
Index: usr.sbin/pppd/auth.c
===================================================================
RCS file: /cvs/src/usr.sbin/pppd/auth.c,v
retrieving revision 1.39
diff -u -p -u -r1.39 auth.c
--- usr.sbin/pppd/auth.c        17 Nov 2017 20:48:30 -0000      1.39
+++ usr.sbin/pppd/auth.c        6 Jul 2019 16:03:26 -0000
@@ -1133,7 +1133,7 @@ check_access(f, filename)
 {
     struct stat sbuf;
 
-    if (fstat(fileno(f), &sbuf) < 0) {
+    if (fstat(fileno(f), &sbuf) == -1) {
        syslog(LOG_WARNING, "cannot stat secret file %s: %m", filename);
     } else if ((sbuf.st_mode & (S_IRWXG | S_IRWXO)) != 0) {
        syslog(LOG_WARNING, "Warning - secret file %s has world and/or group 
access", filename);
Index: usr.sbin/pppd/main.c
===================================================================
RCS file: /cvs/src/usr.sbin/pppd/main.c,v
retrieving revision 1.54
diff -u -p -u -r1.54 main.c
--- usr.sbin/pppd/main.c        17 Mar 2016 19:40:43 -0000      1.54
+++ usr.sbin/pppd/main.c        6 Jul 2019 16:03:20 -0000
@@ -456,7 +456,7 @@ main(argc, argv)
        /*
         * Do the equivalent of `mesg n' to stop broadcast messages.
         */
-       if (fstat(ttyfd, &statbuf) < 0
+       if (fstat(ttyfd, &statbuf) == -1
            || fchmod(ttyfd, statbuf.st_mode & ~(S_IWGRP | S_IWOTH)) < 0) {
            syslog(LOG_WARNING,
                   "Couldn't restrict write permissions to %s: %m", devnam);
Index: usr.sbin/pppd/options.c
===================================================================
RCS file: /cvs/src/usr.sbin/pppd/options.c,v
retrieving revision 1.29
diff -u -p -u -r1.29 options.c
--- usr.sbin/pppd/options.c     6 Dec 2015 12:00:16 -0000       1.29
+++ usr.sbin/pppd/options.c     6 Jul 2019 16:03:13 -0000
@@ -706,7 +706,7 @@ readable(fd)
     uid = getuid();
     if (uid == 0)
        return 1;
-    if (fstat(fd, &sbuf) != 0)
+    if (fstat(fd, &sbuf) == -1)
        return 0;
     if (sbuf.st_uid == uid)
        return sbuf.st_mode & S_IRUSR;
@@ -1581,7 +1581,7 @@ setdevname(cp, quiet)
     /*
      * Check if there is a device by this name.
      */
-    if (stat(cp, &statbuf) < 0) {
+    if (stat(cp, &statbuf) == -1) {
        if (errno == ENOENT || quiet)
            return 0;
        option_error("Couldn't stat %s: %m", cp);
Index: usr.sbin/rpc.bootparamd/bootparamd.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpc.bootparamd/bootparamd.c,v
retrieving revision 1.21
diff -u -p -u -r1.21 bootparamd.c
--- usr.sbin/rpc.bootparamd/bootparamd.c        16 Oct 2016 10:40:58 -0000      
1.21
+++ usr.sbin/rpc.bootparamd/bootparamd.c        6 Jul 2019 16:06:13 -0000
@@ -105,7 +105,7 @@ main(int argc, char *argv[])
                        usage();
                }
 
-       if (stat(bootpfile, &buf))
+       if (stat(bootpfile, &buf) == -1)
                err(1, "%s", bootpfile);
 
        if (!route_addr.s_addr) {
Index: usr.sbin/vipw/vipw.c
===================================================================
RCS file: /cvs/src/usr.sbin/vipw/vipw.c,v
retrieving revision 1.24
diff -u -p -u -r1.24 vipw.c
--- usr.sbin/vipw/vipw.c        28 Jun 2019 13:32:51 -0000      1.24
+++ usr.sbin/vipw/vipw.c        6 Jul 2019 16:04:16 -0000
@@ -86,7 +86,7 @@ main(int argc, char *argv[])
 
        for (;;) {
                pw_edit(0, NULL);
-               if (stat(_PATH_MASTERPASSWD_LOCK, &end))
+               if (stat(_PATH_MASTERPASSWD_LOCK, &end) == -1)
                        pw_error(_PATH_MASTERPASSWD_LOCK, 1, 1);
                if (timespeccmp(&begin.st_mtimespec, &end.st_mtimespec, ==) &&
                    begin.st_size == end.st_size) {

Reply via email to