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 /lib/libc | |
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 'lib/libc')
40 files changed, 125 insertions, 124 deletions
diff --git a/lib/libc/gen/alarm.c b/lib/libc/gen/alarm.c index 8bca23a971f..f15dd151219 100644 --- a/lib/libc/gen/alarm.c +++ b/lib/libc/gen/alarm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alarm.c,v 1.8 2016/01/28 16:40:54 schwarze Exp $ */ +/* $OpenBSD: alarm.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -40,7 +40,7 @@ alarm(unsigned int secs) timerclear(&itp->it_interval); itp->it_value.tv_sec = secs; itp->it_value.tv_usec = 0; - if (setitimer(ITIMER_REAL, itp, &oitv) < 0) + if (setitimer(ITIMER_REAL, itp, &oitv) == -1) return ((unsigned int) -1); if (oitv.it_value.tv_usec) oitv.it_value.tv_sec++; diff --git a/lib/libc/gen/auth_subr.c b/lib/libc/gen/auth_subr.c index a1a2e5a7b69..6d1844f4a28 100644 --- a/lib/libc/gen/auth_subr.c +++ b/lib/libc/gen/auth_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth_subr.c,v 1.52 2019/03/23 17:03:00 millert Exp $ */ +/* $OpenBSD: auth_subr.c,v 1.53 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 2000-2002,2004 Todd C. Miller <millert@openbsd.org> @@ -848,7 +848,7 @@ auth_call(auth_session_t *as, char *path, ...) argv[argc] = NULL; - if (socketpair(PF_LOCAL, SOCK_STREAM, 0, pfd) < 0) { + if (socketpair(PF_LOCAL, SOCK_STREAM, 0, pfd) == -1) { syslog(LOG_ERR, "unable to create backchannel %m"); warnx("internal resource failure"); goto fail; @@ -864,10 +864,10 @@ auth_call(auth_session_t *as, char *path, ...) case 0: #define COMM_FD 3 #define AUTH_FD 4 - if (dup2(pfd[1], COMM_FD) < 0) + if (dup2(pfd[1], COMM_FD) == -1) err(1, "dup of backchannel"); if (as->fd != -1) { - if (dup2(as->fd, AUTH_FD) < 0) + if (dup2(as->fd, AUTH_FD) == -1) err(1, "dup of auth fd"); closefrom(AUTH_FD + 1); } else @@ -1003,7 +1003,7 @@ _recv_fd(auth_session_t *as, int fd) memset(&msg, 0, sizeof(msg)); msg.msg_control = &cmsgbuf.buf; msg.msg_controllen = sizeof(cmsgbuf.buf); - if (recvmsg(fd, &msg, 0) < 0) + if (recvmsg(fd, &msg, 0) == -1) syslog(LOG_ERR, "recvmsg: %m"); else if (msg.msg_flags & MSG_TRUNC) syslog(LOG_ERR, "message truncated"); diff --git a/lib/libc/gen/authenticate.c b/lib/libc/gen/authenticate.c index f1373694d58..fb96881832f 100644 --- a/lib/libc/gen/authenticate.c +++ b/lib/libc/gen/authenticate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: authenticate.c,v 1.26 2016/05/26 15:51:37 millert Exp $ */ +/* $OpenBSD: authenticate.c,v 1.27 2019/06/28 13:32:41 deraadt Exp $ */ /*- * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. @@ -164,7 +164,7 @@ auth_cat(char *file) int fd, nchars; char tbuf[8192]; - if ((fd = open(file, O_RDONLY, 0)) < 0) + if ((fd = open(file, O_RDONLY, 0)) == -1) return (0); while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0) (void)write(fileno(stdout), tbuf, nchars); @@ -282,7 +282,7 @@ auth_approval(auth_session_t *as, login_cap_t *lc, char *name, char *type) pwd->pw_dir[0]) { struct stat sb; - if (stat(pwd->pw_dir, &sb) < 0 || !S_ISDIR(sb.st_mode) || + if (stat(pwd->pw_dir, &sb) == -1 || !S_ISDIR(sb.st_mode) || (pwd->pw_uid && sb.st_uid == pwd->pw_uid && (sb.st_mode & S_IXUSR) == 0)) { auth_setstate(as, (auth_getstate(as) & ~AUTH_ALLOW)); diff --git a/lib/libc/gen/ftok.c b/lib/libc/gen/ftok.c index 387b80f3450..ea1edf1afd9 100644 --- a/lib/libc/gen/ftok.c +++ b/lib/libc/gen/ftok.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftok.c,v 1.8 2014/11/15 22:38:47 guenther Exp $ */ +/* $OpenBSD: ftok.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com> * All rights reserved. @@ -34,7 +34,7 @@ ftok(const char *path, int id) { struct stat st; - if (stat(path, &st) < 0) + if (stat(path, &st) == -1) return (key_t)-1; return (key_t) diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 98b3a0a390d..d13d0a3f223 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fts.c,v 1.58 2017/03/17 15:14:40 deraadt Exp $ */ +/* $OpenBSD: fts.c,v 1.59 2019/06/28 13:32:41 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -160,7 +160,7 @@ fts_open(char * const *argv, int options, * descriptor we run anyway, just more slowly. */ if (!ISSET(FTS_NOCHDIR) && - (sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC)) < 0) + (sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC)) == -1) SET(FTS_NOCHDIR); if (nitems == 0) @@ -287,7 +287,7 @@ fts_read(FTS *sp) p->fts_info = fts_stat(sp, p, 1, -1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { if ((p->fts_symfd = - open(".", O_RDONLY | O_CLOEXEC)) < 0) { + open(".", O_RDONLY | O_CLOEXEC)) == -1) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -377,7 +377,7 @@ next: tmp = p; p->fts_info = fts_stat(sp, p, 1, -1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { if ((p->fts_symfd = - open(".", O_RDONLY | O_CLOEXEC)) < 0) { + open(".", O_RDONLY | O_CLOEXEC)) == -1) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -517,7 +517,7 @@ fts_children(FTS *sp, int instr) ISSET(FTS_NOCHDIR)) return (sp->fts_child = fts_build(sp, instr)); - if ((fd = open(".", O_RDONLY | O_CLOEXEC)) < 0) + if ((fd = open(".", O_RDONLY | O_CLOEXEC)) == -1) return (NULL); sp->fts_child = fts_build(sp, instr); if (fchdir(fd)) { @@ -1028,9 +1028,9 @@ fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path) newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = open(path, O_RDONLY|O_DIRECTORY|O_CLOEXEC)) < 0) + if (fd == -1 && (newfd = open(path, O_RDONLY|O_DIRECTORY|O_CLOEXEC)) == -1) return (-1); - if (fstat(newfd, &sb)) { + if (fstat(newfd, &sb) == -1) { ret = -1; goto bail; } @@ -1042,7 +1042,7 @@ fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path) ret = fchdir(newfd); bail: oerrno = errno; - if (fd < 0) + if (fd == -1) (void)close(newfd); errno = oerrno; return (ret); diff --git a/lib/libc/gen/getloadavg.c b/lib/libc/gen/getloadavg.c index 3ab72b09b47..f6e6b282222 100644 --- a/lib/libc/gen/getloadavg.c +++ b/lib/libc/gen/getloadavg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getloadavg.c,v 1.7 2015/01/16 16:48:51 deraadt Exp $ */ +/* $OpenBSD: getloadavg.c,v 1.8 2019/06/28 13:32:41 deraadt Exp $ */ /*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -52,7 +52,7 @@ getloadavg(double loadavg[], int nelem) mib[0] = CTL_VM; mib[1] = VM_LOADAVG; size = sizeof(loadinfo); - if (sysctl(mib, 2, &loadinfo, &size, NULL, 0) < 0) + if (sysctl(mib, 2, &loadinfo, &size, NULL, 0) == -1) return (-1); nelem = MINIMUM(nelem, sizeof(loadinfo.ldavg) / sizeof(fixpt_t)); diff --git a/lib/libc/gen/getmntinfo.c b/lib/libc/gen/getmntinfo.c index 4ba27ce14a3..f12f8d86c09 100644 --- a/lib/libc/gen/getmntinfo.c +++ b/lib/libc/gen/getmntinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getmntinfo.c,v 1.10 2015/09/14 16:09:13 tedu Exp $ */ +/* $OpenBSD: getmntinfo.c,v 1.11 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -42,18 +42,18 @@ getmntinfo(struct statfs **mntbufp, int flags) static int mntsize; static size_t bufsize; - if (mntsize <= 0 && (mntsize = getfsstat(0, 0, MNT_NOWAIT)) < 0) + if (mntsize <= 0 && (mntsize = getfsstat(0, 0, MNT_NOWAIT)) == -1) return (0); - if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, flags)) < 0) + if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, flags)) == -1) return (0); while (bufsize <= mntsize * sizeof(struct statfs)) { free(mntbuf); bufsize = (mntsize + 1) * sizeof(struct statfs); - if ((mntbuf = malloc(bufsize)) == 0) { + if ((mntbuf = malloc(bufsize)) == NULL) { bufsize = 0; return (0); } - if ((mntsize = getfsstat(mntbuf, bufsize, flags)) < 0) + if ((mntsize = getfsstat(mntbuf, bufsize, flags)) == -1) return (0); } *mntbufp = mntbuf; diff --git a/lib/libc/gen/initgroups.c b/lib/libc/gen/initgroups.c index b8c32ad653e..8f60409dcfd 100644 --- a/lib/libc/gen/initgroups.c +++ b/lib/libc/gen/initgroups.c @@ -1,4 +1,4 @@ -/* $OpenBSD: initgroups.c,v 1.10 2015/09/12 14:56:50 guenther Exp $ */ +/* $OpenBSD: initgroups.c,v 1.11 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -41,7 +41,7 @@ initgroups(const char *uname, gid_t agroup) ngroups = NGROUPS_MAX; (void) getgrouplist(uname, agroup, groups, &ngroups); - if (setgroups(ngroups, groups) < 0) + if (setgroups(ngroups, groups) == -1) return (-1); return (0); } diff --git a/lib/libc/gen/login_cap.c b/lib/libc/gen/login_cap.c index 59652f006a0..b33c65c4291 100644 --- a/lib/libc/gen/login_cap.c +++ b/lib/libc/gen/login_cap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: login_cap.c,v 1.36 2019/03/23 17:03:00 millert Exp $ */ +/* $OpenBSD: login_cap.c,v 1.37 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 2000-2004 Todd C. Miller <millert@openbsd.org> @@ -598,7 +598,7 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags) if (flags & LOGIN_SETPRIORITY) { p = login_getcapnum(lc, "priority", 0, 0); - if (setpriority(PRIO_PROCESS, 0, (int)p) < 0) + if (setpriority(PRIO_PROCESS, 0, (int)p) == -1) syslog(LOG_ERR, "%s: setpriority: %m", lc->lc_class); } @@ -608,14 +608,14 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags) } if (flags & LOGIN_SETGROUP) { - if (setresgid(pwd->pw_gid, pwd->pw_gid, pwd->pw_gid) < 0) { + if (setresgid(pwd->pw_gid, pwd->pw_gid, pwd->pw_gid) == -1) { syslog(LOG_ERR, "setresgid(%u,%u,%u): %m", pwd->pw_gid, pwd->pw_gid, pwd->pw_gid); login_close(flc); return (-1); } - if (initgroups(pwd->pw_name, pwd->pw_gid) < 0) { + if (initgroups(pwd->pw_name, pwd->pw_gid) == -1) { syslog(LOG_ERR, "initgroups(%s,%u): %m", pwd->pw_name, pwd->pw_gid); login_close(flc); @@ -624,7 +624,7 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags) } if (flags & LOGIN_SETLOGIN) - if (setlogin(pwd->pw_name) < 0) { + if (setlogin(pwd->pw_name) == -1) { syslog(LOG_ERR, "setlogin(%s) failure: %m", pwd->pw_name); login_close(flc); @@ -632,7 +632,7 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags) } if (flags & LOGIN_SETUSER) { - if (setresuid(uid, uid, uid) < 0) { + if (setresuid(uid, uid, uid) == -1) { syslog(LOG_ERR, "setresuid(%u,%u,%u): %m", uid, uid, uid); login_close(flc); @@ -968,7 +968,7 @@ secure_path(char *path) * If not a regular file, or is owned/writeable by someone * other than root, quit. */ - if (lstat(path, &sb) < 0) { + if (lstat(path, &sb) == -1) { syslog(LOG_ERR, "cannot stat %s: %m", path); return (-1); } else if (!S_ISREG(sb.st_mode)) { diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index 9a65ea3a66a..da66558a1f6 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nlist.c,v 1.70 2019/05/13 17:18:10 guenther Exp $ */ +/* $OpenBSD: nlist.c,v 1.71 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -102,7 +102,7 @@ __fdnlist(int fd, struct nlist *list) /* Make sure obj is OK */ if (pread(fd, &ehdr, sizeof(Elf_Ehdr), 0) != sizeof(Elf_Ehdr) || - !__elf_is_okay__(&ehdr) || fstat(fd, &st) < 0) + !__elf_is_okay__(&ehdr) || fstat(fd, &st) == -1) return (-1); /* calculate section header table size */ @@ -293,7 +293,7 @@ nlist(const char *name, struct nlist *list) int fd, n; fd = open(name, O_RDONLY | O_CLOEXEC); - if (fd < 0) + if (fd == -1) return (-1); n = __fdnlist(fd, list); (void)close(fd); diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index 0779f70cae6..92a352c07b5 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.21 2015/08/31 02:53:57 guenther Exp $ */ +/* $OpenBSD: popen.c,v 1.22 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -70,7 +70,7 @@ popen(const char *program, const char *type) if ((cur = malloc(sizeof(struct pid))) == NULL) return (NULL); - if (pipe2(pdes, O_CLOEXEC) < 0) { + if (pipe2(pdes, O_CLOEXEC) == -1) { free(cur); return (NULL); } diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index a2d55b49167..f863ebc1e6b 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: posix_spawn.c,v 1.9 2016/03/13 18:34:20 guenther Exp $ */ +/* $OpenBSD: posix_spawn.c,v 1.10 2019/06/28 13:32:41 deraadt Exp $ */ /*- * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -141,7 +141,7 @@ process_file_actions_entry(posix_spawn_file_actions_entry_t *fae) case FAE_OPEN: /* Perform an open(), make it use the right fd */ fd = open(fae->fae_path, fae->fae_oflag, fae->fae_mode); - if (fd < 0) + if (fd == -1) return (errno); if (fd != fae->fae_fildes) { if (dup2(fd, fae->fae_fildes) == -1) diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c index c364bda6c4f..870dc0a39ad 100644 --- a/lib/libc/gen/scandir.c +++ b/lib/libc/gen/scandir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scandir.c,v 1.20 2015/08/20 21:49:29 deraadt Exp $ */ +/* $OpenBSD: scandir.c,v 1.21 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -70,7 +70,7 @@ scandir(const char *dirname, struct dirent ***namelist, if ((dirp = opendir(dirname)) == NULL) return (-1); - if (fstat(dirp->dd_fd, &stb) < 0) + if (fstat(dirp->dd_fd, &stb) == -1) goto fail; /* @@ -97,7 +97,7 @@ scandir(const char *dirname, struct dirent ***namelist, if (nitems >= arraysz) { struct dirent **nnames; - if (fstat(dirp->dd_fd, &stb) < 0) + if (fstat(dirp->dd_fd, &stb) == -1) goto fail; arraysz *= 2; diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c index b6725a6d7b6..99e4b5296c5 100644 --- a/lib/libc/gen/siginterrupt.c +++ b/lib/libc/gen/siginterrupt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: siginterrupt.c,v 1.8 2015/10/23 04:39:24 guenther Exp $ */ +/* $OpenBSD: siginterrupt.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -40,7 +40,7 @@ siginterrupt(int sig, int flag) struct sigaction sa; int ret; - if ((ret = WRAP(sigaction)(sig, NULL, &sa)) < 0) + if ((ret = WRAP(sigaction)(sig, NULL, &sa)) == -1) return (ret); if (flag) { sigaddset(&__sigintr, sig); diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c index c948ef0e5e0..35c6b075f9f 100644 --- a/lib/libc/gen/signal.c +++ b/lib/libc/gen/signal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: signal.c,v 1.10 2015/10/25 04:13:59 guenther Exp $ */ +/* $OpenBSD: signal.c,v 1.11 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1985, 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -47,7 +47,7 @@ signal(int s, sig_t a) sa.sa_flags = 0; if (!sigismember(&__sigintr, s)) sa.sa_flags |= SA_RESTART; - if (WRAP(sigaction)(s, &sa, &osa) < 0) + if (WRAP(sigaction)(s, &sa, &osa) == -1) return (SIG_ERR); return (osa.sa_handler); } diff --git a/lib/libc/gen/time.c b/lib/libc/gen/time.c index 6fcf1cde209..3bbd0d733d1 100644 --- a/lib/libc/gen/time.c +++ b/lib/libc/gen/time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: time.c,v 1.7 2015/10/29 03:58:55 mmcc Exp $ */ +/* $OpenBSD: time.c,v 1.8 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -36,7 +36,7 @@ time(time_t *t) { struct timeval tt; - if (gettimeofday(&tt, NULL) < 0) + if (gettimeofday(&tt, NULL) == -1) return (-1); if (t) *t = (time_t)tt.tv_sec; diff --git a/lib/libc/gen/times.c b/lib/libc/gen/times.c index d5a7210ee77..02e4dd44b5c 100644 --- a/lib/libc/gen/times.c +++ b/lib/libc/gen/times.c @@ -1,4 +1,4 @@ -/* $OpenBSD: times.c,v 1.8 2018/03/02 16:35:58 cheloha Exp $ */ +/* $OpenBSD: times.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -44,11 +44,11 @@ times(struct tms *tp) struct rusage ru; struct timespec ts; - if (getrusage(RUSAGE_SELF, &ru) < 0) + if (getrusage(RUSAGE_SELF, &ru) == -1) return ((clock_t)-1); tp->tms_utime = CONVTCK(ru.ru_utime); tp->tms_stime = CONVTCK(ru.ru_stime); - if (getrusage(RUSAGE_CHILDREN, &ru) < 0) + if (getrusage(RUSAGE_CHILDREN, &ru) == -1) return ((clock_t)-1); tp->tms_cutime = CONVTCK(ru.ru_utime); tp->tms_cstime = CONVTCK(ru.ru_stime); diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index cbfd663e839..c17fcc52bd1 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gmon.c,v 1.30 2016/09/21 04:38:56 guenther Exp $ */ +/* $OpenBSD: gmon.c,v 1.31 2019/06/28 13:32:41 deraadt Exp $ */ /*- * Copyright (c) 1983, 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -162,7 +162,7 @@ _mcleanup(void) size = sizeof(clockinfo); mib[0] = CTL_KERN; mib[1] = KERN_CLOCKRATE; - if (sysctl(mib, 2, &clockinfo, &size, NULL, 0) < 0) { + if (sysctl(mib, 2, &clockinfo, &size, NULL, 0) == -1) { /* * Best guess */ @@ -221,13 +221,13 @@ _mcleanup(void) } fd = open(proffile , O_CREAT|O_TRUNC|O_WRONLY, 0664); - if (fd < 0) { + if (fd == -1) { perror( proffile ); return; } #ifdef DEBUG log = open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); - if (log < 0) { + if (log == -1) { perror("mcount: gmon.log"); close(fd); return; diff --git a/lib/libc/hash/helper.c b/lib/libc/hash/helper.c index 8fa692af091..f36d385e552 100644 --- a/lib/libc/hash/helper.c +++ b/lib/libc/hash/helper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: helper.c,v 1.17 2017/10/23 14:33:07 millert Exp $ */ +/* $OpenBSD: helper.c,v 1.18 2019/06/28 13:32:41 deraadt Exp $ */ /* * Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org> @@ -67,7 +67,7 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len) HASHInit(&ctx); - if ((fd = open(filename, O_RDONLY)) < 0) + if ((fd = open(filename, O_RDONLY)) == -1) return (NULL); if (len == 0) { if (fstat(fd, &sb) == -1) { @@ -78,7 +78,7 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len) } len = sb.st_size; } - if (off > 0 && lseek(fd, off, SEEK_SET) < 0) { + if (off > 0 && lseek(fd, off, SEEK_SET) == -1) { save_errno = errno; close(fd); errno = save_errno; @@ -94,7 +94,7 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len) save_errno = errno; close(fd); errno = save_errno; - return (nr < 0 ? NULL : HASHEnd(&ctx, buf)); + return (nr == -1 ? NULL : HASHEnd(&ctx, buf)); } DEF_WEAK(HASHFileChunk); diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c index d5c3e5c0681..97566656ec0 100644 --- a/lib/libc/locale/rune.c +++ b/lib/libc/locale/rune.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rune.c,v 1.7 2016/09/05 09:47:03 schwarze Exp $ */ +/* $OpenBSD: rune.c,v 1.8 2019/06/28 13:32:41 deraadt Exp $ */ /* $NetBSD: rune.c,v 1.26 2004/05/09 11:26:33 kleink Exp $ */ /*- @@ -227,7 +227,7 @@ _Read_RuneMagi(FILE *fp) int x; uint32_t runetype_nranges, maplower_nranges, mapupper_nranges, var_len; - if (fstat(fileno(fp), &sb) < 0) + if (fstat(fileno(fp), &sb) == -1) return NULL; if (sb.st_size < sizeof(_FileRuneLocale)) diff --git a/lib/libc/net/rcmdsh.c b/lib/libc/net/rcmdsh.c index b9cbd6d5d14..66caac3f3d9 100644 --- a/lib/libc/net/rcmdsh.c +++ b/lib/libc/net/rcmdsh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcmdsh.c,v 1.19 2016/05/28 15:46:00 millert Exp $ */ +/* $OpenBSD: rcmdsh.c,v 1.20 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2001, MagniComp @@ -89,13 +89,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser, } /* Get a socketpair we'll use for stdin and stdout. */ - if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) < 0) { + if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) == -1) { perror("rcmdsh: socketpair"); return(-1); } cpid = fork(); - if (cpid < 0) { + if (cpid == -1) { perror("rcmdsh: fork failed"); return(-1); } else if (cpid == 0) { @@ -103,13 +103,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser, * Child. We use sp[1] to be stdin/stdout, and close sp[0]. */ (void) close(sp[0]); - if (dup2(sp[1], 0) < 0 || dup2(0, 1) < 0) { + if (dup2(sp[1], 0) == -1 || dup2(0, 1) == -1) { perror("rcmdsh: dup2 failed"); _exit(255); } /* Fork again to lose parent. */ cpid = fork(); - if (cpid < 0) { + if (cpid == -1) { perror("rcmdsh: fork to lose parent failed"); _exit(255); } diff --git a/lib/libc/net/rresvport.c b/lib/libc/net/rresvport.c index 6b45000f7b7..72c27c3a3f0 100644 --- a/lib/libc/net/rresvport.c +++ b/lib/libc/net/rresvport.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rresvport.c,v 1.11 2015/09/12 14:56:50 guenther Exp $ */ +/* $OpenBSD: rresvport.c,v 1.12 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 1995, 1996, 1998 Theo de Raadt. All rights reserved. * Copyright (c) 1983, 1993, 1994 @@ -82,12 +82,12 @@ rresvport_af(int *alport, int af) sa->sa_family = af; s = socket(af, SOCK_STREAM, 0); - if (s < 0) + if (s == -1) return (-1); *portp = htons(*alport); if (*alport < IPPORT_RESERVED - 1) { - if (bind(s, sa, sa->sa_len) >= 0) + if (bind(s, sa, sa->sa_len) != -1) return (s); if (errno != EADDRINUSE) { (void)close(s); diff --git a/lib/libc/net/ruserok.c b/lib/libc/net/ruserok.c index cab6f964494..a399c013e26 100644 --- a/lib/libc/net/ruserok.c +++ b/lib/libc/net/ruserok.c @@ -131,11 +131,11 @@ again: * user or root or if writeable by anyone but the owner, quit. */ cp = NULL; - if (lstat(pbuf, &sbuf) < 0) + if (lstat(pbuf, &sbuf) == -1) cp = ".rhosts lstat failed"; else if (!S_ISREG(sbuf.st_mode)) cp = ".rhosts not regular file"; - else if (fstat(fileno(hostf), &sbuf) < 0) + else if (fstat(fileno(hostf), &sbuf) == -1) cp = ".rhosts fstat failed"; else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) cp = "bad .rhosts owner"; diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index 1ee7f7a50cb..402d98cede4 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth_unix.c,v 1.26 2015/11/01 03:45:29 guenther Exp $ */ +/* $OpenBSD: auth_unix.c,v 1.27 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -194,7 +194,7 @@ authunix_create_default(void) machname[MAX_MACHINE_NAME] = 0; uid = geteuid(); gid = getegid(); - if ((len = getgroups(NGRPS, gids)) < 0) + if ((len = getgroups(NGRPS, gids)) == -1) return (NULL); if (len > maxgrplist) len = maxgrplist; diff --git a/lib/libc/rpc/bindresvport.c b/lib/libc/rpc/bindresvport.c index 145a7de9944..536b1f2ab9b 100644 --- a/lib/libc/rpc/bindresvport.c +++ b/lib/libc/rpc/bindresvport.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bindresvport.c,v 1.18 2015/09/14 11:01:47 guenther Exp $ */ +/* $OpenBSD: bindresvport.c,v 1.19 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright 1996, Jason Downs. All rights reserved. @@ -92,12 +92,12 @@ bindresvport_sa(int sd, struct sockaddr *sa) socklen_t oldlen = sizeof(old); error = getsockopt(sd, proto, portrange, &old, &oldlen); - if (error < 0) + if (error == -1) return (error); error = setsockopt(sd, proto, portrange, &portlow, sizeof(portlow)); - if (error < 0) + if (error == -1) return (error); } @@ -108,14 +108,14 @@ bindresvport_sa(int sd, struct sockaddr *sa) if (error) { if (setsockopt(sd, proto, portrange, &old, - sizeof(old)) < 0) + sizeof(old)) == -1) errno = saved_errno; return (error); } if (sa != (struct sockaddr *)&myaddr) { /* Hmm, what did the kernel assign... */ - if (getsockname(sd, sa, &salen) < 0) + if (getsockname(sd, sa, &salen) == -1) errno = saved_errno; return (error); } diff --git a/lib/libc/rpc/clnt_tcp.c b/lib/libc/rpc/clnt_tcp.c index c29d0f4c1d9..8e6ef515b0e 100644 --- a/lib/libc/rpc/clnt_tcp.c +++ b/lib/libc/rpc/clnt_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clnt_tcp.c,v 1.32 2018/01/06 15:37:36 cheloha Exp $ */ +/* $OpenBSD: clnt_tcp.c,v 1.33 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -148,9 +148,9 @@ clnttcp_create(struct sockaddr_in *raddr, u_long prog, u_long vers, int *sockp, if (*sockp < 0) { *sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); (void)bindresvport(*sockp, NULL); - if ((*sockp < 0) + if ((*sockp == -1) || (connect(*sockp, (struct sockaddr *)raddr, - sizeof(*raddr)) < 0)) { + sizeof(*raddr)) == -1)) { rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; if (*sockp != -1) diff --git a/lib/libc/rpc/clnt_udp.c b/lib/libc/rpc/clnt_udp.c index fd0d83611c0..68d01674410 100644 --- a/lib/libc/rpc/clnt_udp.c +++ b/lib/libc/rpc/clnt_udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clnt_udp.c,v 1.35 2018/01/06 15:37:36 cheloha Exp $ */ +/* $OpenBSD: clnt_udp.c,v 1.36 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -158,7 +158,7 @@ clntudp_bufcreate(struct sockaddr_in *raddr, u_long program, u_long version, if (*sockp < 0) { *sockp = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); - if (*sockp < 0) { + if (*sockp == -1) { rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; goto fooy; @@ -299,8 +299,8 @@ send_again: inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, (int) cu->cu_recvsz, 0, (struct sockaddr *)&from, &fromlen); - } while (inlen < 0 && errno == EINTR); - if (inlen < 0) { + } while (inlen == -1 && errno == EINTR); + if (inlen == -1) { if (errno == EWOULDBLOCK) continue; cu->cu_error.re_errno = errno; diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index 50237f324c2..097999b5ae6 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_rmt.c,v 1.34 2015/12/28 22:08:18 mmcc Exp $ */ +/* $OpenBSD: pmap_rmt.c,v 1.35 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -238,12 +238,12 @@ clnt_broadcast(u_long prog, /* program number */ * initialization: create a socket, a broadcast address, and * preserialize the arguments into a send buffer. */ - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { stat = RPC_CANTSEND; goto done_broad; } #ifdef SO_BROADCAST - if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { + if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) == -1) { stat = RPC_CANTSEND; goto done_broad; } @@ -338,7 +338,7 @@ clnt_broadcast(u_long prog, /* program number */ fromlen = sizeof(struct sockaddr); inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0, (struct sockaddr *)&raddr, &fromlen); - if (inlen < 0) { + if (inlen == -1) { if (errno == EINTR) goto try_again; stat = RPC_CANTRECV; diff --git a/lib/libc/rpc/svc_tcp.c b/lib/libc/rpc/svc_tcp.c index 11d3961ee3a..f9d7a70938f 100644 --- a/lib/libc/rpc/svc_tcp.c +++ b/lib/libc/rpc/svc_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svc_tcp.c,v 1.39 2017/12/14 18:56:22 jca Exp $ */ +/* $OpenBSD: svc_tcp.c,v 1.40 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -134,18 +134,18 @@ svctcp_create(int sock, u_int sendsize, u_int recvsize) socklen_t len = sizeof(struct sockaddr_in); if (sock == RPC_ANYSOCK) { - if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) + if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) return (NULL); madesock = TRUE; } memset(&addr, 0, sizeof (addr)); addr.sin_len = sizeof(struct sockaddr_in); addr.sin_family = AF_INET; - if (bindresvport(sock, &addr)) { + if (bindresvport(sock, &addr) == -1) { addr.sin_port = 0; (void)bind(sock, (struct sockaddr *)&addr, len); } - if ((getsockname(sock, (struct sockaddr *)&addr, &len) != 0) || + if ((getsockname(sock, (struct sockaddr *)&addr, &len) == -1) || (listen(sock, 2) != 0)) { if (madesock) (void)close(sock); @@ -241,7 +241,7 @@ rendezvous_request(SVCXPRT *xprt, struct rpc_msg *ignored) again: len = sizeof(struct sockaddr_in); if ((sock = accept(xprt->xp_sock, (struct sockaddr *)&addr, - &len)) < 0) { + &len)) == -1) { if (errno == EINTR || errno == EWOULDBLOCK || errno == ECONNABORTED) goto again; @@ -254,8 +254,9 @@ rendezvous_request(SVCXPRT *xprt, struct rpc_msg *ignored) socklen_t optsize = sizeof(opts); int i; - if (!getsockopt(sock, IPPROTO_IP, IP_OPTIONS, (char *)&opts, - &optsize) && optsize != 0) { + if (getsockopt(sock, IPPROTO_IP, IP_OPTIONS, + (char *)&opts, &optsize) == 0 && + optsize != 0) { for (i = 0; (char *)&opts.ipopt_list[i] - (char *)&opts < optsize; ) { u_char c = (u_char)opts.ipopt_list[i]; @@ -377,7 +378,7 @@ writetcp(SVCXPRT *xprt, caddr_t buf, int len) int i, cnt; for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = write(xprt->xp_sock, buf, cnt)) < 0) { + if ((i = write(xprt->xp_sock, buf, cnt)) == -1) { ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; return (-1); diff --git a/lib/libc/rpc/svc_udp.c b/lib/libc/rpc/svc_udp.c index da8d4d5af94..ccd00f3c4ab 100644 --- a/lib/libc/rpc/svc_udp.c +++ b/lib/libc/rpc/svc_udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svc_udp.c,v 1.25 2015/11/01 03:45:29 guenther Exp $ */ +/* $OpenBSD: svc_udp.c,v 1.26 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -104,7 +104,7 @@ svcudp_bufcreate(int sock, u_int sendsz, u_int recvsz) socklen_t len = sizeof(struct sockaddr_in); if (sock == RPC_ANYSOCK) { - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) + if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) return (NULL); madesock = TRUE; } diff --git a/lib/libc/rpc/xdr_stdio.c b/lib/libc/rpc/xdr_stdio.c index db0ad4ba809..d010a8a4e53 100644 --- a/lib/libc/rpc/xdr_stdio.c +++ b/lib/libc/rpc/xdr_stdio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xdr_stdio.c,v 1.14 2015/11/01 03:45:29 guenther Exp $ */ +/* $OpenBSD: xdr_stdio.c,v 1.15 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -144,7 +144,7 @@ static bool_t xdrstdio_setpos(XDR *xdrs, u_int pos) { - return ((fseek((FILE *)xdrs->x_private, (long)pos, SEEK_SET) < 0) ? + return ((fseek((FILE *)xdrs->x_private, (long)pos, SEEK_SET) == -1) ? FALSE : TRUE); } diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c index 8ba51eeab01..5ec625f739c 100644 --- a/lib/libc/stdio/fdopen.c +++ b/lib/libc/stdio/fdopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdopen.c,v 1.9 2016/03/20 00:01:21 krw Exp $ */ +/* $OpenBSD: fdopen.c,v 1.10 2019/06/28 13:32:42 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -55,7 +55,7 @@ fdopen(int fd, const char *mode) return (NULL); /* Make sure the mode the user wants is a subset of the actual mode. */ - if ((fdflags = fcntl(fd, F_GETFL)) < 0) + if ((fdflags = fcntl(fd, F_GETFL)) == -1) return (NULL); tmp = fdflags & O_ACCMODE; if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) { diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c index 5932a552158..d62e2eb36d6 100644 --- a/lib/libc/stdio/fopen.c +++ b/lib/libc/stdio/fopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fopen.c,v 1.9 2016/09/21 04:38:56 guenther Exp $ */ +/* $OpenBSD: fopen.c,v 1.10 2019/06/28 13:32:42 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -51,7 +51,7 @@ fopen(const char *file, const char *mode) return (NULL); if ((fp = __sfp()) == NULL) return (NULL); - if ((f = open(file, oflags, DEFFILEMODE)) < 0) { + if ((f = open(file, oflags, DEFFILEMODE)) == -1) { fp->_flags = 0; /* release */ return (NULL); } diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index f2e975df69e..1d0895a819a 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fseek.c,v 1.12 2015/08/31 02:53:57 guenther Exp $ */ +/* $OpenBSD: fseek.c,v 1.13 2019/06/28 13:32:42 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -127,7 +127,7 @@ fseeko(FILE *fp, off_t offset, int whence) goto dumb; if ((fp->_flags & __SOPT) == 0) { if (seekfn != __sseek || - fp->_file < 0 || fstat(fp->_file, &st) || + fp->_file < 0 || fstat(fp->_file, &st) == -1 || (st.st_mode & S_IFMT) != S_IFREG) { fp->_flags |= __SNPT; goto dumb; @@ -143,7 +143,7 @@ fseeko(FILE *fp, off_t offset, int whence) if (whence == SEEK_SET) target = offset; else { - if (fstat(fp->_file, &st)) + if (fstat(fp->_file, &st) == -1) goto dumb; target = st.st_size + offset; } diff --git a/lib/libc/stdio/makebuf.c b/lib/libc/stdio/makebuf.c index 56e5f210cf4..b771a408779 100644 --- a/lib/libc/stdio/makebuf.c +++ b/lib/libc/stdio/makebuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: makebuf.c,v 1.9 2015/01/13 07:18:21 guenther Exp $ */ +/* $OpenBSD: makebuf.c,v 1.10 2019/06/28 13:32:42 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -81,7 +81,7 @@ __swhatbuf(FILE *fp, size_t *bufsize, int *couldbetty) { struct stat st; - if (fp->_file < 0 || fstat(fp->_file, &st) < 0) { + if (fp->_file < 0 || fstat(fp->_file, &st) == -1) { *couldbetty = 0; *bufsize = BUFSIZ; return (__SNPT); diff --git a/lib/libc/stdio/remove.c b/lib/libc/stdio/remove.c index e08e5997658..f3ad006376b 100644 --- a/lib/libc/stdio/remove.c +++ b/lib/libc/stdio/remove.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remove.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ +/* $OpenBSD: remove.c,v 1.9 2019/06/28 13:32:42 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -41,7 +41,7 @@ remove(const char *file) { struct stat st; - if (lstat(file, &st) < 0) + if (lstat(file, &st) == -1) return (-1); if (S_ISDIR(st.st_mode)) return (rmdir(file)); diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index f2e82679e9d..7d49438b7be 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.261 2019/05/23 06:43:18 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.262 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> @@ -897,7 +897,7 @@ omalloc_make_chunks(struct dir_info *d, int bits, int listnum) return NULL; /* memory protect the page allocated in the malloc(0) case */ - if (bits == 0 && mprotect(pp, MALLOC_PAGESIZE, PROT_NONE) < 0) + if (bits == 0 && mprotect(pp, MALLOC_PAGESIZE, PROT_NONE) == -1) goto err; bp = alloc_chunk_info(d, bits); diff --git a/lib/libc/termios/tcgetpgrp.c b/lib/libc/termios/tcgetpgrp.c index a85267a9a6e..b8aedf98be0 100644 --- a/lib/libc/termios/tcgetpgrp.c +++ b/lib/libc/termios/tcgetpgrp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcgetpgrp.c,v 1.7 2014/12/16 03:32:21 millert Exp $ */ +/* $OpenBSD: tcgetpgrp.c,v 1.8 2019/06/28 13:32:42 deraadt Exp $ */ /*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -36,7 +36,7 @@ tcgetpgrp(int fd) { int s; - if (ioctl(fd, TIOCGPGRP, &s) < 0) + if (ioctl(fd, TIOCGPGRP, &s) == -1) return (-1); return (s); diff --git a/lib/libc/termios/tcgetsid.c b/lib/libc/termios/tcgetsid.c index 531179212ef..2f25a962bd3 100644 --- a/lib/libc/termios/tcgetsid.c +++ b/lib/libc/termios/tcgetsid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcgetsid.c,v 1.3 2013/12/17 22:12:07 millert Exp $ */ +/* $OpenBSD: tcgetsid.c,v 1.4 2019/06/28 13:32:42 deraadt Exp $ */ /*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -36,7 +36,7 @@ tcgetsid(int fd) { int s; - if (ioctl(fd, TIOCGSID, &s) < 0) + if (ioctl(fd, TIOCGSID, &s) == -1) return (-1); return (s); diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index fbe33e94aef..2fb277dee22 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: localtime.c,v 1.60 2019/05/12 12:49:52 schwarze Exp $ */ +/* $OpenBSD: localtime.c,v 1.61 2019/06/28 13:32:42 deraadt Exp $ */ /* ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. @@ -342,7 +342,7 @@ tzload(const char *name, struct state *sp, int doextend) goto oops; nread = read(fid, up->buf, sizeof up->buf); - if (close(fid) < 0 || nread <= 0) + if (close(fid) == -1 || nread <= 0) goto oops; for (stored = 4; stored <= 8; stored *= 2) { int ttisstdcnt; |