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 | |
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')
61 files changed, 241 insertions, 240 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; diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c index af13ec54946..54a9dc553ad 100644 --- a/lib/libedit/readline.c +++ b/lib/libedit/readline.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readline.c,v 1.27 2016/05/31 16:12:00 schwarze Exp $ */ +/* $OpenBSD: readline.c,v 1.28 2019/06/28 13:32:42 deraadt Exp $ */ /* $NetBSD: readline.c,v 1.91 2010/08/28 15:44:59 christos Exp $ */ /*- @@ -1265,7 +1265,7 @@ history_truncate_file (const char *filename, int nlines) if (nlines <= 0 || count == 0) break; count--; - if (fseeko(tp, (off_t)sizeof(buf) * count, SEEK_SET) < 0) { + if (fseeko(tp, (off_t)sizeof(buf) * count, SEEK_SET) == -1) { ret = errno; break; } @@ -2092,16 +2092,16 @@ _rl_event_read_char(EditLine *el, wchar_t *wc) (*rl_event_hook)(); #if defined(FIONREAD) - if (ioctl(el->el_infd, FIONREAD, &n) < 0) + if (ioctl(el->el_infd, FIONREAD, &n) == -1) return -1; if (n) num_read = read(el->el_infd, &ch, 1); else num_read = 0; #elif defined(F_SETFL) && defined(O_NDELAY) - if ((n = fcntl(el->el_infd, F_GETFL)) < 0) + if ((n = fcntl(el->el_infd, F_GETFL)) == -1) return -1; - if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0) + if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) == -1) return -1; num_read = read(el->el_infd, &ch, 1); if (fcntl(el->el_infd, F_SETFL, n)) diff --git a/lib/libevent/evutil.c b/lib/libevent/evutil.c index 1f66772d5f5..81add1dfc29 100644 --- a/lib/libevent/evutil.c +++ b/lib/libevent/evutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evutil.c,v 1.10 2016/03/20 00:01:22 krw Exp $ */ +/* $OpenBSD: evutil.c,v 1.11 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2007 Niels Provos <provos@citi.umich.edu> @@ -54,7 +54,7 @@ evutil_make_socket_nonblocking(int fd) { int flags; - if ((flags = fcntl(fd, F_GETFL)) < 0) { + if ((flags = fcntl(fd, F_GETFL)) == -1) { event_warn("fcntl(%d, F_GETFL)", fd); return -1; } diff --git a/lib/libfuse/fuse.c b/lib/libfuse/fuse.c index bc83a2812ae..2b8c0ebdfc6 100644 --- a/lib/libfuse/fuse.c +++ b/lib/libfuse/fuse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse.c,v 1.50 2018/11/16 02:16:17 tedu Exp $ */ +/* $OpenBSD: fuse.c,v 1.51 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -121,7 +121,7 @@ ifuse_try_unmount(struct fuse *f) /* unmount in another thread so fuse_loop() doesn't deadlock */ child = fork(); - if (child < 0) { + if (child == -1) { DPERROR(__func__); return; } @@ -218,7 +218,7 @@ fuse_loop(struct fuse *fuse) ioexch.fbxch_data = fbuf.fb_dat; if (ioctl(fuse->fc->fd, FIOCGETFBDAT, - &ioexch)) { + &ioexch) == -1) { free(fbuf.fb_dat); return (-1); } @@ -249,7 +249,7 @@ fuse_loop(struct fuse *fuse) ioexch.fbxch_len = fbuf.fb_len; ioexch.fbxch_data = fbuf.fb_dat; - if (ioctl(fuse->fc->fd, FIOCSETFBDAT, &ioexch)) { + if (ioctl(fuse->fc->fd, FIOCSETFBDAT, &ioexch) == -1) { free(fbuf.fb_dat); return (-1); } diff --git a/lib/libkeynote/keynote-sign.c b/lib/libkeynote/keynote-sign.c index 6609a879b8a..29469215dcb 100644 --- a/lib/libkeynote/keynote-sign.c +++ b/lib/libkeynote/keynote-sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keynote-sign.c,v 1.18 2015/11/19 07:00:58 guenther Exp $ */ +/* $OpenBSD: keynote-sign.c,v 1.19 2019/06/28 13:32:42 deraadt Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu) * @@ -104,13 +104,13 @@ keynote_sign(int argc, char *argv[]) /* Read assertion */ fd = open(argv[2 + flg], O_RDONLY, 0); - if (fd < 0) + if (fd == -1) { perror(argv[2 + flg]); exit(1); } - if (fstat(fd, &sb) < 0) + if (fstat(fd, &sb) == -1) { perror("fstat()"); exit(1); @@ -130,7 +130,7 @@ keynote_sign(int argc, char *argv[]) exit(1); } - if (read(fd, buf, buflen - 1) < 0) + if (read(fd, buf, buflen - 1) == -1) { perror("read()"); exit(1); @@ -140,13 +140,13 @@ keynote_sign(int argc, char *argv[]) /* Read private key file */ fd = open(argv[3 + flg], O_RDONLY, 0); - if (fd < 0) + if (fd == -1) { perror(argv[3 + flg]); exit(1); } - if (fstat(fd, &sb) < 0) + if (fstat(fd, &sb) == -1) { perror("fstat()"); exit(1); @@ -165,7 +165,7 @@ keynote_sign(int argc, char *argv[]) exit(1); } - if (read(fd, buf2, sb.st_size) < 0) + if (read(fd, buf2, sb.st_size) == -1) { perror("read()"); exit(1); diff --git a/lib/libkeynote/keynote-sigver.c b/lib/libkeynote/keynote-sigver.c index 61ebe036ed1..6c87e386349 100644 --- a/lib/libkeynote/keynote-sigver.c +++ b/lib/libkeynote/keynote-sigver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keynote-sigver.c,v 1.16 2015/11/19 02:35:24 mmcc Exp $ */ +/* $OpenBSD: keynote-sigver.c,v 1.17 2019/06/28 13:32:42 deraadt Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu) * @@ -57,13 +57,13 @@ keynote_sigver(int argc, char *argv[]) /* Open and read assertion file */ fd = open(argv[1], O_RDONLY, 0); - if (fd < 0) + if (fd == -1) { perror(argv[1]); exit(1); } - if (fstat(fd, &sb) < 0) + if (fstat(fd, &sb) == -1) { perror("fstat()"); exit(1); @@ -82,7 +82,7 @@ keynote_sigver(int argc, char *argv[]) exit(1); } - if (read(fd, buf, sb.st_size) < 0) + if (read(fd, buf, sb.st_size) == -1) { perror("read()"); exit(1); diff --git a/lib/libkeynote/keynote-verify.c b/lib/libkeynote/keynote-verify.c index 1368c21dd00..d6f13f19295 100644 --- a/lib/libkeynote/keynote-verify.c +++ b/lib/libkeynote/keynote-verify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keynote-verify.c,v 1.17 2015/11/19 05:20:19 mmcc Exp $ */ +/* $OpenBSD: keynote-verify.c,v 1.18 2019/06/28 13:32:42 deraadt Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu) * @@ -102,13 +102,13 @@ keynote_verify(int argc, char *argv[]) case 'k': sk = 1; - if ((fd = open(optarg, O_RDONLY, 0)) < 0) + if ((fd = open(optarg, O_RDONLY, 0)) == -1) { perror(optarg); exit(1); } - if (fstat(fd, &sb) < 0) + if (fstat(fd, &sb) == -1) { perror("fstat()"); exit(1); @@ -127,7 +127,7 @@ keynote_verify(int argc, char *argv[]) } i = read(fd, buf, sb.st_size); - if (i < 0) + if (i == -1) { perror("read()"); exit(1); @@ -222,13 +222,13 @@ keynote_verify(int argc, char *argv[]) break; case 'l': - if ((fd = open(optarg, O_RDONLY, 0)) < 0) + if ((fd = open(optarg, O_RDONLY, 0)) == -1) { perror(optarg); exit(1); } - if (fstat(fd, &sb) < 0) + if (fstat(fd, &sb) == -1) { perror("fstat()"); exit(1); @@ -247,7 +247,7 @@ keynote_verify(int argc, char *argv[]) } i = read(fd, buf, sb.st_size); - if (i < 0) + if (i == -1) { perror("read()"); exit(1); @@ -306,13 +306,13 @@ keynote_verify(int argc, char *argv[]) while (argc--) { - if ((fd = open(argv[argc], O_RDONLY, 0)) < 0) + if ((fd = open(argv[argc], O_RDONLY, 0)) == -1) { perror(argv[argc]); exit(1); } - if (fstat(fd, &sb) < 0) + if (fstat(fd, &sb) == -1) { perror("fstat()"); exit(1); @@ -331,7 +331,7 @@ keynote_verify(int argc, char *argv[]) } i = read(fd, buf, sb.st_size); - if (i < 0) + if (i == -1) { perror("read()"); exit(1); diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c index f1d14a04cc2..610173686e3 100644 --- a/lib/libkvm/kvm.c +++ b/lib/libkvm/kvm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm.c,v 1.65 2018/05/03 16:42:07 zhuk Exp $ */ +/* $OpenBSD: kvm.c,v 1.66 2019/06/28 13:32:42 deraadt Exp $ */ /* $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $ */ /*- @@ -219,11 +219,11 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, const char *sf, if (mf == 0) mf = _PATH_MEM; - if ((kd->pmfd = open(mf, flag)) < 0) { + if ((kd->pmfd = open(mf, flag)) == -1) { _kvm_syserr(kd, kd->program, "%s", mf); goto failed; } - if (fstat(kd->pmfd, &st) < 0) { + if (fstat(kd->pmfd, &st) == -1) { _kvm_syserr(kd, kd->program, "%s", mf); goto failed; } @@ -239,12 +239,12 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, const char *sf, "%s: not physical memory device", mf); goto failed; } - if ((kd->vmfd = open(_PATH_KMEM, flag)) < 0) { + if ((kd->vmfd = open(_PATH_KMEM, flag)) == -1) { _kvm_syserr(kd, kd->program, "%s", _PATH_KMEM); goto failed; } kd->alive = 1; - if (sf != NULL && (kd->swfd = open(sf, flag)) < 0) { + if (sf != NULL && (kd->swfd = open(sf, flag)) == -1) { _kvm_syserr(kd, kd->program, "%s", sf); goto failed; } diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c index a18e9983ae0..f2733ccfc26 100644 --- a/lib/libkvm/kvm_proc.c +++ b/lib/libkvm/kvm_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc.c,v 1.59 2018/05/03 15:47:41 zhuk Exp $ */ +/* $OpenBSD: kvm_proc.c,v 1.60 2019/06/28 13:32:42 deraadt Exp $ */ /* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -491,7 +491,7 @@ again: mib[3] = isenv ? KERN_PROC_ENV : KERN_PROC_ARGV; len = orglen; - ret = (sysctl(mib, 4, *pargbuf, &len, NULL, 0) < 0); + ret = (sysctl(mib, 4, *pargbuf, &len, NULL, 0) == -1); if (ret && errno == ENOMEM) { buf = _kvm_reallocarray(kd, *pargbuf, orglen, 2); if (buf == NULL) diff --git a/lib/libossaudio/ossaudio.c b/lib/libossaudio/ossaudio.c index 8bfcd2c9777..8374af54830 100644 --- a/lib/libossaudio/ossaudio.c +++ b/lib/libossaudio/ossaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ossaudio.c,v 1.19 2018/10/26 14:46:05 miko Exp $ */ +/* $OpenBSD: ossaudio.c,v 1.20 2019/06/28 13:32:42 deraadt Exp $ */ /* $NetBSD: ossaudio.c,v 1.14 2001/05/10 01:53:48 augustss Exp $ */ /*- @@ -194,7 +194,7 @@ getdevinfo(int fd) } for(i = 0; i < MAX_MIXER_DEVS; i++) { mi.index = i; - if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) < 0) + if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) == -1) break; switch(mi.type) { case AUDIO_MIXER_VALUE: @@ -215,12 +215,12 @@ getdevinfo(int fd) } for(i = 0; i < MAX_MIXER_DEVS; i++) { mi.index = i; - if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) < 0) + if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) == -1) break; if (strcmp(mi.label.name, AudioNsource) != 0) continue; cl.index = mi.mixer_class; - if (ioctl(fd, AUDIO_MIXER_DEVINFO, &cl) < 0) + if (ioctl(fd, AUDIO_MIXER_DEVINFO, &cl) == -1) break; if ((cl.type != AUDIO_MIXER_CLASS) || (strcmp(cl.label.name, AudioCrecord) != 0)) @@ -274,7 +274,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp) case SOUND_MIXER_INFO: case SOUND_OLD_MIXER_INFO: error = ioctl(fd, AUDIO_GETDEV, &adev); - if (error) + if (error == -1) return (error); omi = argp; if (com == SOUND_MIXER_INFO) @@ -289,7 +289,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp) if (di->caps & SOUND_CAP_EXCL_INPUT) { mc.type = AUDIO_MIXER_ENUM; retval = ioctl(fd, AUDIO_MIXER_READ, &mc); - if (retval < 0) + if (retval == -1) return retval; e = opaque_to_enum(di, NULL, mc.un.ord); if (e >= 0) @@ -297,7 +297,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp) } else { mc.type = AUDIO_MIXER_SET; retval = ioctl(fd, AUDIO_MIXER_READ, &mc); - if (retval < 0) + if (retval == -1) return retval; e = opaque_to_enum(di, NULL, mc.un.mask); if (e >= 0) @@ -354,7 +354,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp) doread: mc.un.value.num_channels = di->stereomask & (1<<n) ? 2 : 1; retval = ioctl(fd, AUDIO_MIXER_READ, &mc); - if (retval < 0) + if (retval == -1) return retval; if (mc.type != AUDIO_MIXER_VALUE) return EINVAL; @@ -387,7 +387,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp) mc.un.value.level[AUDIO_MIXER_LEVEL_MONO] = (l+r)/2; } retval = ioctl(fd, AUDIO_MIXER_WRITE, &mc); - if (retval < 0) + if (retval == -1) return retval; if (MIXER_WRITE(SOUND_MIXER_FIRST) <= com && com < MIXER_WRITE(SOUND_MIXER_NRDEVICES)) diff --git a/lib/libpcap/inet.c b/lib/libpcap/inet.c index 2a3da9d1d50..0aa3ef8c379 100644 --- a/lib/libpcap/inet.c +++ b/lib/libpcap/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.24 2015/12/22 19:51:04 mmcc Exp $ */ +/* $OpenBSD: inet.c,v 1.25 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 1994, 1995, 1996, 1997, 1998 @@ -161,7 +161,7 @@ pcap_lookupdev(errbuf) static char device[sizeof(ifrp->ifr_name) + 1]; fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { + if (fd == -1) { (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "socket: %s", pcap_strerror(errno)); return (NULL); @@ -170,7 +170,7 @@ pcap_lookupdev(errbuf) ifc.ifc_buf = (caddr_t)ibuf; memset((char *)ibuf, 0, sizeof(ibuf)); - if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 || + if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) == -1 || ifc.ifc_len < sizeof(struct ifreq)) { (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFCONF: %s", pcap_strerror(errno)); @@ -202,7 +202,7 @@ pcap_lookupdev(errbuf) */ (void)strlcpy(ifr.ifr_name, ifrp->ifr_name, sizeof(ifr.ifr_name)); - if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) { + if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) == -1) { if (errno == ENXIO) continue; (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, @@ -247,7 +247,7 @@ pcap_lookupnet(const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, struct ifreq ifr; fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { + if (fd == -1) { (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "socket: %s", pcap_strerror(errno)); return (-1); @@ -258,7 +258,7 @@ pcap_lookupnet(const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, ifr.ifr_addr.sa_family = AF_INET; #endif (void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); - if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) { + if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) == -1) { if (errno == EADDRNOTAVAIL) { (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: no IPv4 address assigned", device); @@ -272,7 +272,7 @@ pcap_lookupnet(const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, } sin = (struct sockaddr_in *)&ifr.ifr_addr; *netp = sin->sin_addr.s_addr; - if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) { + if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) == -1) { (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno)); (void)close(fd); diff --git a/lib/libpcap/pcap-bpf.c b/lib/libpcap/pcap-bpf.c index c2b4a83f4a9..068580f98c6 100644 --- a/lib/libpcap/pcap-bpf.c +++ b/lib/libpcap/pcap-bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcap-bpf.c,v 1.36 2018/04/05 03:47:27 lteo Exp $ */ +/* $OpenBSD: pcap-bpf.c,v 1.37 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 1993, 1994, 1995, 1996, 1998 @@ -55,7 +55,7 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps) { struct bpf_stat s; - if (ioctl(p->fd, BIOCGSTATS, (caddr_t)&s) < 0) { + if (ioctl(p->fd, BIOCGSTATS, (caddr_t)&s) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGSTATS: %s", pcap_strerror(errno)); return (PCAP_ERROR); @@ -90,7 +90,7 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) cc = p->cc; if (p->cc == 0) { cc = read(p->fd, (char *)p->buffer, p->bufsize); - if (cc < 0) { + if (cc == -1) { /* Don't choke when we get ptraced */ switch (errno) { @@ -246,7 +246,7 @@ get_dlt_list(int fd, int v, struct bpf_dltlist *bdlp, char *ebuf) return (PCAP_ERROR); } - if (ioctl(fd, BIOCGDLTLIST, (caddr_t)bdlp) < 0) { + if (ioctl(fd, BIOCGDLTLIST, (caddr_t)bdlp) == -1) { (void)snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCGDLTLIST: %s", pcap_strerror(errno)); free(bdlp->bfl_list); @@ -321,7 +321,7 @@ pcap_cleanup_bpf(pcap_t *p) memset(&req, 0, sizeof(req)); (void)strlcpy(req.ifm_name, p->opt.source, sizeof(req.ifm_name)); - if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) { + if (ioctl(sock, SIOCGIFMEDIA, &req) == -1) { fprintf(stderr, "Can't restore interface flags " "(SIOCGIFMEDIA failed: %s).\n" @@ -437,7 +437,7 @@ pcap_activate(pcap_t *p) p->fd = fd; - if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0) { + if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCVERSION: %s", pcap_strerror(errno)); status = PCAP_ERROR; @@ -470,7 +470,7 @@ pcap_activate(pcap_t *p) * A buffer size was explicitly specified; use it. */ if (ioctl(fd, BIOCSBLEN, - (caddr_t)&p->opt.buffer_size) < 0) { + (caddr_t)&p->opt.buffer_size) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSBLEN: %s: %s", p->opt.source, pcap_strerror(errno)); @@ -483,12 +483,12 @@ pcap_activate(pcap_t *p) * Now bind to the device. */ (void)strlcpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name)); - if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) { + if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) == -1) { status = check_setif_failure(p, errno); goto bad; } /* Get the data link layer type. */ - if (ioctl(fd, BIOCGDLT, (caddr_t)&v) < 0) { + if (ioctl(fd, BIOCGDLT, (caddr_t)&v) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGDLT: %s", pcap_strerror(errno)); status = PCAP_ERROR; @@ -557,7 +557,7 @@ pcap_activate(pcap_t *p) struct timeval to; to.tv_sec = p->md.timeout / 1000; to.tv_usec = (p->md.timeout * 1000) % 1000000; - if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) < 0) { + if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSRTIMEOUT: %s", pcap_strerror(errno)); status = PCAP_ERROR; @@ -567,7 +567,7 @@ pcap_activate(pcap_t *p) if (p->opt.immediate) { v = 1; - if (ioctl(p->fd, BIOCIMMEDIATE, &v) < 0) { + if (ioctl(p->fd, BIOCIMMEDIATE, &v) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCIMMEDIATE: %s", pcap_strerror(errno)); status = PCAP_ERROR; @@ -577,14 +577,14 @@ pcap_activate(pcap_t *p) if (p->opt.promisc) { /* set promiscuous mode, just warn if it fails */ - if (ioctl(p->fd, BIOCPROMISC, NULL) < 0) { + if (ioctl(p->fd, BIOCPROMISC, NULL) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCPROMISC: %s", pcap_strerror(errno)); status = PCAP_WARNING_PROMISC_NOTSUP; } } - if (ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) { + if (ioctl(fd, BIOCGBLEN, (caddr_t)&v) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGBLEN: %s", pcap_strerror(errno)); status = PCAP_ERROR; @@ -645,7 +645,7 @@ monitor_mode(pcap_t *p, int set) /* * Find out how many media types we have. */ - if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) { + if (ioctl(sock, SIOCGIFMEDIA, &req) == -1) { /* * Can't get the media types. */ @@ -693,7 +693,7 @@ monitor_mode(pcap_t *p, int set) return (PCAP_ERROR); } req.ifm_ulist = media_list; - if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) { + if (ioctl(sock, SIOCGIFMEDIA, &req) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFMEDIA: %s", pcap_strerror(errno)); free(media_list); @@ -931,7 +931,7 @@ pcap_setfilter(pcap_t *p, struct bpf_program *fp) } memcpy(p->fcode.bf_insns, fp->bf_insns, fp->bf_len * sizeof(*fp->bf_insns)); - } else if (ioctl(p->fd, BIOCSETF, (caddr_t)fp) < 0) { + } else if (ioctl(p->fd, BIOCSETF, (caddr_t)fp) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETF: %s", pcap_strerror(errno)); return (-1); @@ -958,7 +958,7 @@ pcap_setdirection(pcap_t *p, pcap_direction_t d) snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Invalid direction"); return (-1); } - if (ioctl(p->fd, BIOCSDIRFILT, &dirfilt) < 0) { + if (ioctl(p->fd, BIOCSDIRFILT, &dirfilt) == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSDIRFILT: %s", pcap_strerror(errno)); return (-1); diff --git a/lib/libsndio/sio_sun.c b/lib/libsndio/sio_sun.c index 08ad7489bc9..5ff939b7de4 100644 --- a/lib/libsndio/sio_sun.c +++ b/lib/libsndio/sio_sun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sio_sun.c,v 1.27 2018/09/19 14:01:52 miko Exp $ */ +/* $OpenBSD: sio_sun.c,v 1.28 2019/06/28 13:32:42 deraadt Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -79,12 +79,12 @@ sio_sun_adjpar(struct sio_sun_hdl *hdl, struct audio_swpar *ap) { if (hdl->sio.eof) return 0; - if (ioctl(hdl->fd, AUDIO_SETPAR, ap)) { + if (ioctl(hdl->fd, AUDIO_SETPAR, ap) == -1) { DPERROR("AUDIO_SETPAR"); hdl->sio.eof = 1; return 0; } - if (ioctl(hdl->fd, AUDIO_GETPAR, ap)) { + if (ioctl(hdl->fd, AUDIO_GETPAR, ap) == -1) { DPERROR("AUDIO_GETPAR"); hdl->sio.eof = 1; return 0; @@ -163,7 +163,7 @@ sio_sun_getcap(struct sio_hdl *sh, struct sio_cap *cap) unsigned int enc_map = 0, rchan_map = 0, pchan_map = 0, rate_map; unsigned int i, j, conf; - if (ioctl(hdl->fd, AUDIO_GETPAR, &savepar)) { + if (ioctl(hdl->fd, AUDIO_GETPAR, &savepar) == -1) { DPERROR("AUDIO_GETPAR"); hdl->sio.eof = 1; return 0; @@ -256,7 +256,7 @@ sio_sun_getcap(struct sio_hdl *sh, struct sio_cap *cap) } cap->nconf = nconf; - if (ioctl(hdl->fd, AUDIO_SETPAR, &savepar)) { + if (ioctl(hdl->fd, AUDIO_SETPAR, &savepar) == -1) { DPERROR("AUDIO_SETPAR"); hdl->sio.eof = 1; return 0; @@ -298,7 +298,7 @@ sio_sun_getfd(const char *str, unsigned int mode, int nbio) flags = O_RDWR; else flags = (mode & SIO_PLAY) ? O_WRONLY : O_RDONLY; - while ((fd = open(path, flags | O_NONBLOCK | O_CLOEXEC)) < 0) { + while ((fd = open(path, flags | O_NONBLOCK | O_CLOEXEC)) == -1) { if (errno == EINTR) continue; DPERROR(path); @@ -323,7 +323,7 @@ sio_sun_fdopen(int fd, unsigned int mode, int nbio) /* * pause the device */ - if (ioctl(fd, AUDIO_STOP) < 0) { + if (ioctl(fd, AUDIO_STOP) == -1) { DPERROR("AUDIO_STOP"); free(hdl); return NULL; @@ -340,12 +340,12 @@ _sio_sun_open(const char *str, unsigned int mode, int nbio) int fd; fd = sio_sun_getfd(str, mode, nbio); - if (fd < 0) + if (fd == -1) return NULL; hdl = sio_sun_fdopen(fd, mode, nbio); if (hdl != NULL) return hdl; - while (close(fd) < 0 && errno == EINTR) + while (close(fd) == -1 && errno == EINTR) ; /* retry */ return NULL; } @@ -355,7 +355,7 @@ sio_sun_close(struct sio_hdl *sh) { struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh; - while (close(hdl->fd) < 0 && errno == EINTR) + while (close(hdl->fd) == -1 && errno == EINTR) ; /* retry */ free(hdl); } @@ -384,7 +384,7 @@ sio_sun_start(struct sio_hdl *sh) /* * no play buffers to fill, start now! */ - if (ioctl(hdl->fd, AUDIO_START) < 0) { + if (ioctl(hdl->fd, AUDIO_START) == -1) { DPERROR("AUDIO_START"); hdl->sio.eof = 1; return 0; @@ -403,7 +403,7 @@ sio_sun_stop(struct sio_hdl *sh) hdl->filling = 0; return 1; } - if (ioctl(hdl->fd, AUDIO_STOP) < 0) { + if (ioctl(hdl->fd, AUDIO_STOP) == -1) { DPERROR("AUDIO_STOP"); hdl->sio.eof = 1; return 0; @@ -438,7 +438,7 @@ sio_sun_setpar(struct sio_hdl *sh, struct sio_par *par) ap.round = par->appbufsz / 2; ap.nblks = 2; } - if (ioctl(hdl->fd, AUDIO_SETPAR, &ap) < 0) { + if (ioctl(hdl->fd, AUDIO_SETPAR, &ap) == -1) { DPERROR("AUDIO_SETPAR"); hdl->sio.eof = 1; return 0; @@ -452,7 +452,7 @@ sio_sun_getpar(struct sio_hdl *sh, struct sio_par *par) struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh; struct audio_swpar ap; - if (ioctl(hdl->fd, AUDIO_GETPAR, &ap) < 0) { + if (ioctl(hdl->fd, AUDIO_GETPAR, &ap) == -1) { DPERROR("AUDIO_GETPAR"); hdl->sio.eof = 1; return 0; @@ -477,7 +477,7 @@ sio_sun_read(struct sio_hdl *sh, void *buf, size_t len) struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh; ssize_t n; - while ((n = read(hdl->fd, buf, len)) < 0) { + while ((n = read(hdl->fd, buf, len)) == -1) { if (errno == EINTR) continue; if (errno != EAGAIN) { @@ -502,7 +502,7 @@ sio_sun_write(struct sio_hdl *sh, const void *buf, size_t len) ssize_t n, todo; todo = len; - while ((n = write(hdl->fd, data, todo)) < 0) { + while ((n = write(hdl->fd, data, todo)) == -1) { if (errno == EINTR) continue; if (errno != EAGAIN) { @@ -530,7 +530,7 @@ sio_sun_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events) if (hdl->filling && hdl->sio.wused == hdl->sio.par.bufsz * hdl->sio.par.pchan * hdl->sio.par.bps) { hdl->filling = 0; - if (ioctl(hdl->fd, AUDIO_START) < 0) { + if (ioctl(hdl->fd, AUDIO_START) == -1) { DPERROR("AUDIO_START"); hdl->sio.eof = 1; return 0; @@ -551,7 +551,7 @@ sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd) if ((pfd->revents & POLLHUP) || (pfd->revents & (POLLIN | POLLOUT)) == 0) return pfd->revents; - if (ioctl(hdl->fd, AUDIO_GETPOS, &ap) < 0) { + if (ioctl(hdl->fd, AUDIO_GETPOS, &ap) == -1) { DPERROR("sio_sun_revents: GETPOS"); hdl->sio.eof = 1; return POLLHUP; diff --git a/lib/libusbhid/descr.c b/lib/libusbhid/descr.c index 11972c2259c..9d81c2f0e3f 100644 --- a/lib/libusbhid/descr.c +++ b/lib/libusbhid/descr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: descr.c,v 1.6 2012/07/16 19:57:17 jasper Exp $ */ +/* $OpenBSD: descr.c,v 1.7 2019/06/28 13:32:42 deraadt Exp $ */ /* $NetBSD: descr.c,v 1.2 2002/02/20 20:31:07 christos Exp $ */ /* @@ -46,7 +46,7 @@ hid_get_report_desc(int fd) struct usb_ctl_report_desc rep; rep.ucrd_size = 0; - if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0) + if (ioctl(fd, USB_GET_REPORT_DESC, &rep) == -1) return (NULL); return hid_use_report_desc(rep.ucrd_data, (unsigned int)rep.ucrd_size); diff --git a/lib/libutil/check_expire.c b/lib/libutil/check_expire.c index 7379cdbe8a8..ebbaa2acd2b 100644 --- a/lib/libutil/check_expire.c +++ b/lib/libutil/check_expire.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_expire.c,v 1.12 2015/11/26 23:32:52 millert Exp $ */ +/* $OpenBSD: check_expire.c,v 1.13 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. @@ -166,7 +166,7 @@ pwd_update(const struct passwd *pwd, const struct passwd *opwd) pw_init(); tfd = pw_lock(0); - if (tfd < 0) { + if (tfd == -1) { if (errno == EEXIST) return("the passwd file is busy."); else @@ -174,13 +174,13 @@ pwd_update(const struct passwd *pwd, const struct passwd *opwd) } pfd = open(_PATH_MASTERPASSWD, O_RDONLY|O_CLOEXEC, 0); - if (pfd < 0) { + if (pfd == -1) { pw_abort(); return(strerror(errno)); } pw_copy(pfd, tfd, pwd, opwd); - if (pw_mkdb(pwd->pw_name, 0) < 0) { + if (pw_mkdb(pwd->pw_name, 0) == -1) { pw_abort(); return("unable to update password database"); } diff --git a/lib/libutil/getmaxpartitions.c b/lib/libutil/getmaxpartitions.c index 22f3c8d3cc6..dd9d2bc6b3b 100644 --- a/lib/libutil/getmaxpartitions.c +++ b/lib/libutil/getmaxpartitions.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getmaxpartitions.c,v 1.9 2016/08/27 03:54:20 guenther Exp $ */ +/* $OpenBSD: getmaxpartitions.c,v 1.10 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: getmaxpartitions.c,v 1.1 1996/05/16 07:03:31 thorpej Exp $ */ /*- @@ -45,7 +45,7 @@ getmaxpartitions(void) mib[0] = CTL_KERN; mib[1] = KERN_MAXPARTITIONS; varlen = sizeof(maxpart); - if (sysctl(mib, 2, &maxpart, &varlen, NULL, (size_t)0) < 0) + if (sysctl(mib, 2, &maxpart, &varlen, NULL, (size_t)0) == -1) return (-1); return (maxpart); diff --git a/lib/libutil/getrawpartition.c b/lib/libutil/getrawpartition.c index 10324472bd2..bc7fa06d5f1 100644 --- a/lib/libutil/getrawpartition.c +++ b/lib/libutil/getrawpartition.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getrawpartition.c,v 1.9 2016/08/27 03:54:20 guenther Exp $ */ +/* $OpenBSD: getrawpartition.c,v 1.10 2019/06/28 13:32:43 deraadt Exp $ */ /* $NetBSD: getrawpartition.c,v 1.1 1996/05/16 07:03:33 thorpej Exp $ */ /*- @@ -45,7 +45,7 @@ getrawpartition(void) mib[0] = CTL_KERN; mib[1] = KERN_RAWPARTITION; varlen = sizeof(rawpart); - if (sysctl(mib, 2, &rawpart, &varlen, NULL, (size_t)0) < 0) + if (sysctl(mib, 2, &rawpart, &varlen, NULL, (size_t)0) == -1) return (-1); return (rawpart); diff --git a/lib/libutil/logout.c b/lib/libutil/logout.c index 13c11fa863f..c2b6818610f 100644 --- a/lib/libutil/logout.c +++ b/lib/libutil/logout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logout.c,v 1.9 2015/12/28 20:11:36 guenther Exp $ */ +/* $OpenBSD: logout.c,v 1.10 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -47,7 +47,7 @@ logout(const char *line) int fd, rval; UTMP ut; - if ((fd = open(_PATH_UTMP, O_RDWR|O_CLOEXEC)) < 0) + if ((fd = open(_PATH_UTMP, O_RDWR|O_CLOEXEC)) == -1) return(0); rval = 0; while (read(fd, &ut, sizeof(UTMP)) == sizeof(UTMP)) { diff --git a/lib/libutil/logwtmp.c b/lib/libutil/logwtmp.c index decde069377..1223d7a4b57 100644 --- a/lib/libutil/logwtmp.c +++ b/lib/libutil/logwtmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logwtmp.c,v 1.10 2016/08/30 14:44:45 guenther Exp $ */ +/* $OpenBSD: logwtmp.c,v 1.11 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -46,7 +46,7 @@ logwtmp(const char *line, const char *name, const char *host) struct utmp ut; int fd; - if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND|O_CLOEXEC)) < 0) + if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND|O_CLOEXEC)) == -1) return; if (fstat(fd, &buf) == 0) { (void) strncpy(ut.ut_line, line, sizeof(ut.ut_line)); diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c index cd2929428ea..7acd7085d42 100644 --- a/lib/libutil/passwd.c +++ b/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.55 2018/08/10 17:03:26 deraadt Exp $ */ +/* $OpenBSD: passwd.c,v 1.56 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -101,7 +101,7 @@ pw_lock(int retries) /* Acquire the lock file. */ old_mode = umask(0); fd = open(pw_lck, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0600); - for (i = 0; i < retries && fd < 0 && errno == EEXIST; i++) { + for (i = 0; i < retries && fd == -1 && errno == EEXIST; i++) { sleep(1); fd = open(pw_lck, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0600); } diff --git a/lib/libutil/readlabel.c b/lib/libutil/readlabel.c index d53820e67ac..9d811b5c9cf 100644 --- a/lib/libutil/readlabel.c +++ b/lib/libutil/readlabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readlabel.c,v 1.14 2016/08/30 14:44:45 guenther Exp $ */ +/* $OpenBSD: readlabel.c,v 1.15 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 1996, Jason Downs. All rights reserved. @@ -74,7 +74,7 @@ readlabelfs(char *device, int verbose) } /* Assuming device is of the form /dev/??p, build a raw partition. */ - if (stat(device, &sbuf) < 0) { + if (stat(device, &sbuf) == -1) { if (verbose) warn("%s", device); return (NULL); @@ -106,12 +106,12 @@ readlabelfs(char *device, int verbose) /* If rpath doesn't exist, change that partition back. */ fd = open(rpath, O_RDONLY|O_CLOEXEC); - if (fd < 0) { + if (fd == -1) { if (errno == ENOENT) { rpath[strlen(rpath) - 1] = part; fd = open(rpath, O_RDONLY|O_CLOEXEC); - if (fd < 0) { + if (fd == -1) { if (verbose) warn("%s", rpath); return (NULL); @@ -125,7 +125,7 @@ readlabelfs(char *device, int verbose) disklabel: - if (ioctl(fd, DIOCGDINFO, &dk) < 0) { + if (ioctl(fd, DIOCGDINFO, &dk) == -1) { if (verbose) warn("%s: couldn't read disklabel", rpath); close(fd); diff --git a/lib/libutil/uucplock.c b/lib/libutil/uucplock.c index f38382282ba..0ec649421ab 100644 --- a/lib/libutil/uucplock.c +++ b/lib/libutil/uucplock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uucplock.c,v 1.19 2016/08/30 14:52:09 guenther Exp $ */ +/* $OpenBSD: uucplock.c,v 1.20 2019/06/28 13:32:43 deraadt Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -71,11 +71,11 @@ uu_lock(const char *ttyname) (void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, ttyname); tmpfd = open(lcktmpname, O_CREAT|O_TRUNC|O_WRONLY|O_CLOEXEC, 0664); - if (tmpfd < 0) + if (tmpfd == -1) GORET(0, UU_LOCK_CREAT_ERR); for (i = 0; i < MAXTRIES; i++) { - if (link(lcktmpname, lckname) < 0) { + if (link(lcktmpname, lckname) == -1) { if (errno != EEXIST) GORET(1, UU_LOCK_LINK_ERR); /* @@ -83,7 +83,7 @@ uu_lock(const char *ttyname) * check to see if the process holding the lock * still exists */ - if ((fd = open(lckname, O_RDONLY | O_CLOEXEC)) < 0) + if ((fd = open(lckname, O_RDONLY | O_CLOEXEC)) == -1) GORET(1, UU_LOCK_OPEN_ERR); if ((pid_old = get_pid(fd, &err)) == -1) @@ -127,7 +127,7 @@ uu_lock_txfr(const char *ttyname, pid_t pid) snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, ttyname); - if ((fd = open(lckname, O_RDWR | O_CLOEXEC)) < 0) + if ((fd = open(lckname, O_RDWR | O_CLOEXEC)) == -1) return UU_LOCK_OWNER_ERR; if (get_pid(fd, &err) != getpid()) ret = UU_LOCK_OWNER_ERR; |