commit: 6924710815dcc99f5fa59c647ec81a2c35a42c2a
parent: b8decd63900dcc3563145d354f57ae04b06846b4
author: Brian Callahan <bcallah@openbsd.org>
date: Tue, 23 Jul 2019 19:39:42 -0400
Pull in all ksh changes up to
CVSROOT: /cvs
Module name: src
Changes by: deraadt@cvs.openbsd.org 2019/06/28 07:35:05
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.
16 files changed, 118 insertions(+), 116 deletions(-)
diff --git a/CVS/Entries b/CVS/Entries
@@ -1,46 +1,46 @@
/config.h/1.19/Tue Jan 16 02:21:56 2018//
-/io.c/1.36/Fri Jun 1 19:10:08 2018//
-/tty.c/1.17/Fri Jun 1 19:10:08 2018//
-/exec.c/1.73/Sun Sep 23 17:58:57 2018//
/var.c/1.70/Sun Sep 23 17:59:17 2018//
-/edit.c/1.67/Result of merge//
-/history.c/1.81/Result of merge//
-/misc.c/1.72/Result of merge//
/emacs.c/1.86/Result of merge//
-/eval.c/1.64/Result of merge//
-/main.c/1.97/Result of merge//
/sh.h/1.75/Result of merge//
-/CONTRIBUTORS/1.11/Thu Jun 20 10:34:00 2019//
-/LEGAL/1.2/Thu Jun 20 10:34:00 2019//
-/Makefile/1.39/Thu Jun 20 10:34:07 2019//
-/NOTES/1.16/Thu Jun 20 10:34:00 2019//
-/PROJECTS/1.9/Thu Jun 20 10:34:00 2019//
-/README/1.16/Thu Jun 20 10:34:07 2019//
-/alloc.c/1.19/Thu Jun 20 10:34:00 2019//
-/c_ksh.c/1.61/Thu Jun 20 10:34:00 2019//
-/c_sh.c/1.63/Thu Jun 20 10:34:00 2019//
-/c_test.c/1.26/Result of merge//
-/c_test.h/1.4/Thu Jun 20 10:34:00 2019//
-/c_ulimit.c/1.28/Thu Jun 20 10:34:00 2019//
-/edit.h/1.12/Thu Jun 20 10:34:00 2019//
-/expand.h/1.15/Thu Jun 20 10:34:00 2019//
-/expr.c/1.34/Thu Jun 20 10:34:00 2019//
-/jobs.c/1.60/Thu Jun 20 10:34:00 2019//
-/ksh.1/1.204/Thu Jun 20 10:34:07 2019//
-/lex.c/1.78/Thu Jun 20 10:34:00 2019//
-/lex.h/1.21/Thu Jun 20 10:34:00 2019//
-/mail.c/1.27/Thu Jun 20 10:34:00 2019//
-/path.c/1.22/Thu Jun 20 10:34:00 2019//
-/sh.1/1.152/Thu Jun 20 10:34:07 2019//
-/shf.c/1.33/Thu Jun 20 10:34:00 2019//
-/shf.h/1.8/Thu Jun 20 10:34:00 2019//
-/syn.c/1.39/Thu Jun 20 10:34:00 2019//
-/table.c/1.25/Thu Jun 20 10:34:00 2019//
-/table.h/1.15/Thu Jun 20 10:34:00 2019//
-/trap.c/1.33/Thu Jun 20 10:34:00 2019//
-/tree.c/1.34/Thu Jun 20 10:34:00 2019//
-/tree.h/1.12/Thu Jun 20 10:34:00 2019//
-/tty.h/1.6/Thu Jun 20 10:34:00 2019//
-/version.c/1.12/Thu Jun 20 10:34:00 2019//
-/vi.c/1.56/Thu Jun 20 10:34:00 2019//
+/CONTRIBUTORS/1.11/Tue Jul 23 23:35:51 2019//
+/LEGAL/1.2/Tue Jul 23 23:35:51 2019//
+/Makefile/1.39/Tue Jul 23 23:36:04 2019//
+/NOTES/1.16/Tue Jul 23 23:35:51 2019//
+/PROJECTS/1.9/Tue Jul 23 23:35:51 2019//
+/README/1.16/Tue Jul 23 23:36:04 2019//
+/alloc.c/1.19/Tue Jul 23 23:35:51 2019//
+/c_ksh.c/1.62/Tue Jul 23 23:36:04 2019//
+/c_sh.c/1.63/Tue Jul 23 23:35:51 2019//
+/c_test.c/1.27/Result of merge//
+/c_test.h/1.4/Tue Jul 23 23:35:51 2019//
+/c_ulimit.c/1.29/Tue Jul 23 23:36:04 2019//
+/edit.c/1.69/Result of merge//
+/edit.h/1.12/Tue Jul 23 23:35:51 2019//
+/eval.c/1.65/Result of merge//
+/exec.c/1.74/Result of merge//
+/expand.h/1.15/Tue Jul 23 23:35:51 2019//
+/expr.c/1.34/Tue Jul 23 23:35:51 2019//
+/history.c/1.82/Result of merge//
+/io.c/1.37/Result of merge//
+/jobs.c/1.61/Tue Jul 23 23:36:05 2019//
+/ksh.1/1.207/Tue Jul 23 23:36:05 2019//
+/lex.c/1.78/Tue Jul 23 23:35:51 2019//
+/lex.h/1.21/Tue Jul 23 23:35:51 2019//
+/mail.c/1.27/Tue Jul 23 23:35:51 2019//
+/main.c/1.98/Result of merge//
+/misc.c/1.73/Result of merge//
+/path.c/1.23/Tue Jul 23 23:36:05 2019//
+/sh.1/1.152/Tue Jul 23 23:35:51 2019//
+/shf.c/1.34/Tue Jul 23 23:36:05 2019//
+/shf.h/1.8/Tue Jul 23 23:35:51 2019//
+/syn.c/1.39/Tue Jul 23 23:35:51 2019//
+/table.c/1.25/Tue Jul 23 23:35:51 2019//
+/table.h/1.15/Tue Jul 23 23:35:51 2019//
+/trap.c/1.33/Tue Jul 23 23:35:51 2019//
+/tree.c/1.34/Tue Jul 23 23:35:51 2019//
+/tree.h/1.12/Tue Jul 23 23:35:51 2019//
+/tty.c/1.18/Result of merge+Tue Jul 23 23:36:05 2019//
+/tty.h/1.6/Tue Jul 23 23:35:51 2019//
+/version.c/1.12/Tue Jul 23 23:35:51 2019//
+/vi.c/1.56/Tue Jul 23 23:35:51 2019//
D
diff --git a/c_ksh.c b/c_ksh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ksh.c,v 1.61 2018/05/18 13:25:20 benno Exp $ */
+/* $OpenBSD: c_ksh.c,v 1.62 2019/06/28 13:34:59 deraadt Exp $ */
/*
* built-in Korn commands: c_*
@@ -114,9 +114,9 @@ c_cd(char **wp)
simplify_path(Xstring(xs, xp));
rval = chdir(try = Xstring(xs, xp));
}
- } while (rval < 0 && cdpath != NULL);
+ } while (rval == -1 && cdpath != NULL);
- if (rval < 0) {
+ if (rval == -1) {
if (cdnode)
bi_errorf("%s: bad directory", dir);
else
@@ -186,7 +186,7 @@ c_pwd(char **wp)
}
p = current_wd[0] ? (physical ? get_phys_path(current_wd) : current_wd) :
NULL;
- if (p && access(p, R_OK) < 0)
+ if (p && access(p, R_OK) == -1)
p = NULL;
if (!p) {
freep = p = ksh_get_wd(NULL, 0);
@@ -374,7 +374,7 @@ c_print(char **wp)
}
for (s = Xstring(xs, xp); len > 0; ) {
n = write(fd, s, len);
- if (n < 0) {
+ if (n == -1) {
if (flags & PO_COPROC)
restore_pipe(opipe);
if (errno == EINTR) {
@@ -1245,7 +1245,7 @@ c_kill(char **wp)
/* use killpg if < -1 since -1 does special things for
* some non-killpg-endowed kills
*/
- if ((n < -1 ? killpg(-n, sig) : kill(n, sig)) < 0) {
+ if ((n < -1 ? killpg(-n, sig) : kill(n, sig)) == -1) {
bi_errorf("%s: %s", p, strerror(errno));
rv = 1;
}
diff --git a/c_test.c b/c_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_test.c,v 1.26 2019/06/19 18:18:22 millert Exp $ */
+/* $OpenBSD: c_test.c,v 1.27 2019/06/28 13:34:59 deraadt Exp $ */
/*
* test(1); version 7-like -- author Erik Baalbergen
@@ -371,7 +371,7 @@ test_eaccess(const char *path, int amode)
if (res == 0 && ksheuid == 0 && (amode & X_OK)) {
struct stat statb;
- if (stat(path, &statb) < 0)
+ if (stat(path, &statb) == -1)
res = -1;
else if (S_ISDIR(statb.st_mode))
res = 0;
diff --git a/c_ulimit.c b/c_ulimit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ulimit.c,v 1.28 2018/04/09 17:53:36 tobias Exp $ */
+/* $OpenBSD: c_ulimit.c,v 1.29 2019/06/28 13:34:59 deraadt Exp $ */
/*
ulimit -- handle "ulimit" builtin
@@ -162,7 +162,7 @@ set_ulimit(const struct limits *l, const char *v, int how)
limit.rlim_cur = val;
if (how & HARD)
limit.rlim_max = val;
- if (setrlimit(l->resource, &limit) < 0) {
+ if (setrlimit(l->resource, &limit) == -1) {
if (errno == EPERM)
bi_errorf("-%c exceeds allowable limit", l->option);
else
diff --git a/edit.c b/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.67 2018/12/30 23:09:58 guenther Exp $ */
+/* $OpenBSD: edit.c,v 1.69 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Command line editing - common code
@@ -65,7 +65,7 @@ check_sigwinch(void)
struct winsize ws;
got_sigwinch = 0;
- if (procpid == kshpid && ioctl(tty_fd, TIOCGWINSZ, &ws) >= 0) {
+ if (procpid == kshpid && ioctl(tty_fd, TIOCGWINSZ, &ws) == 0) {
struct tbl *vp;
/* Do NOT export COLUMNS/LINES. Many applications
@@ -390,7 +390,7 @@ x_file_glob(int flags, const char *str, int slen, char ***wordsp)
* which evaluated to an empty string (e.g.,
* "$FOO" when there is no FOO, etc).
*/
- if ((lstat(words[0], &statb) < 0) ||
+ if ((lstat(words[0], &statb) == -1) ||
words[0][0] == '\0') {
x_free_words(nwords, words);
words = NULL;
@@ -614,12 +614,12 @@ x_try_array(const char *buf, int buflen, const char *want, int wantlen,
}
/* Try to find the array. */
- if (asprintf(&name, "complete_%.*s_%d", cmdlen, cmd, n) < 0)
+ if (asprintf(&name, "complete_%.*s_%d", cmdlen, cmd, n) == -1)
internal_errorf("unable to allocate memory");
v = global(name);
free(name);
if (~v->flag & (ISSET|ARRAY)) {
- if (asprintf(&name, "complete_%.*s", cmdlen, cmd) < 0)
+ if (asprintf(&name, "complete_%.*s", cmdlen, cmd) == -1)
internal_errorf("unable to allocate memory");
v = global(name);
free(name);
diff --git a/eval.c b/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.64 2019/02/20 23:59:17 schwarze Exp $ */
+/* $OpenBSD: eval.c,v 1.65 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -1012,12 +1012,12 @@ globit(XString *xs, /* dest string */
if ((check & GF_EXCHECK) ||
((check & GF_MARKDIR) && (check & GF_GLOBBED))) {
#define stat_check() (stat_done ? stat_done : \
- (stat_done = stat(Xstring(*xs, xp), &statb) < 0 \
+ (stat_done = stat(Xstring(*xs, xp), &statb) == -1 \
? -1 : 1))
struct stat lstatb, statb;
int stat_done = 0; /* -1: failed, 1 ok */
- if (lstat(Xstring(*xs, xp), &lstatb) < 0)
+ if (lstat(Xstring(*xs, xp), &lstatb) == -1)
return;
/* special case for systems which strip trailing
* slashes from regular files (eg, /etc/passwd/).
diff --git a/exec.c b/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.73 2018/03/15 16:51:29 anton Exp $ */
+/* $OpenBSD: exec.c,v 1.74 2019/06/28 13:34:59 deraadt Exp $ */
/*
* execute command tree
@@ -956,10 +956,10 @@ search_access(const char *path, int mode,
int ret, err = 0;
struct stat statb;
- if (stat(path, &statb) < 0)
+ if (stat(path, &statb) == -1)
return -1;
ret = access(path, mode);
- if (ret < 0)
+ if (ret == -1)
err = errno; /* File exists, but we can't access it */
else if (mode == X_OK && (!S_ISREG(statb.st_mode) ||
!(statb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))) {
@@ -1078,7 +1078,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
* things like /dev/null without error.
*/
if (Flag(FNOCLOBBER) && !(iop->flag & IOCLOB) &&
- (stat(cp, &statb) < 0 || S_ISREG(statb.st_mode)))
+ (stat(cp, &statb) == -1 || S_ISREG(statb.st_mode)))
flags |= O_EXCL;
break;
@@ -1197,7 +1197,7 @@ herein(const char *content, int sub)
* doesn't get removed too soon).
*/
h = maketemp(ATEMP, TT_HEREDOC_EXP, &genv->temps);
- if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY, 0)) < 0) {
+ if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY, 0)) == -1) {
warningf(true, "can't %s temporary file %s: %s",
!shf ? "create" : "open",
h->name, strerror(errno));
diff --git a/history.c b/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.81 2018/11/20 07:02:23 martijn Exp $ */
+/* $OpenBSD: history.c,v 1.82 2019/06/28 13:34:59 deraadt Exp $ */
/*
* command history
@@ -257,7 +257,7 @@ c_fc(char **wp)
return 1;
}
- n = fstat(shf->fd, &statb) < 0 ? 128 :
+ n = fstat(shf->fd, &statb) == -1 ? 128 :
statb.st_size + 1;
Xinit(xs, xp, n, hist_source->areap);
while ((n = shf_read(xp, Xnleft(xs, xp), shf)) > 0) {
diff --git a/io.c b/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.36 2018/01/16 22:52:32 jca Exp $ */
+/* $OpenBSD: io.c,v 1.37 2019/06/28 13:34:59 deraadt Exp $ */
/*
* shell buffered IO and formatted output
@@ -243,7 +243,7 @@ ksh_dup2(int ofd, int nfd, int errok)
{
int ret = dup2(ofd, nfd);
- if (ret < 0 && errno != EBADF && !errok)
+ if (ret == -1 && errno != EBADF && !errok)
errorf("too many files open in shell");
return ret;
@@ -261,7 +261,7 @@ savefd(int fd)
if (fd < FDBASE) {
#ifdef F_DUPFD_CLOEXEC
nfd = fcntl(fd, F_DUPFD_CLOEXEC, FDBASE);
- if (nfd < 0) {
+ if (nfd == -1) {
if (errno == EBADF)
return -1;
else
@@ -302,7 +302,7 @@ openpipe(int *pv)
{
int lpv[2];
- if (pipe(lpv) < 0)
+ if (pipe(lpv) == -1)
errorf("can't create pipe - try again");
pv[0] = savefd(lpv[0]);
if (pv[0] != lpv[0])
@@ -329,7 +329,7 @@ check_fd(char *name, int mode, const char **emsgp)
if (isdigit((unsigned char)name[0]) && !name[1]) {
fd = name[0] - '0';
- if ((fl = fcntl(fd, F_GETFL)) < 0) {
+ if ((fl = fcntl(fd, F_GETFL)) == -1) {
if (emsgp)
*emsgp = "bad file descriptor";
return -1;
diff --git a/jobs.c b/jobs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jobs.c,v 1.60 2018/03/15 16:51:29 anton Exp $ */
+/* $OpenBSD: jobs.c,v 1.61 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Process and job control
@@ -198,11 +198,11 @@ j_suspend(void)
if (ttypgrp_ok) {
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
if (restore_ttypgrp >= 0) {
- if (tcsetpgrp(tty_fd, restore_ttypgrp) < 0) {
+ if (tcsetpgrp(tty_fd, restore_ttypgrp) == -1) {
warningf(false, "%s: tcsetpgrp() failed: %s",
__func__, strerror(errno));
} else {
- if (setpgid(0, restore_ttypgrp) < 0) {
+ if (setpgid(0, restore_ttypgrp) == -1) {
warningf(false,
"%s: setpgid() failed: %s",
__func__, strerror(errno));
@@ -222,12 +222,12 @@ j_suspend(void)
sigaction(SIGTSTP, &osa, NULL);
if (ttypgrp_ok) {
if (restore_ttypgrp >= 0) {
- if (setpgid(0, kshpid) < 0) {
+ if (setpgid(0, kshpid) == -1) {
warningf(false, "%s: setpgid() failed: %s",
__func__, strerror(errno));
ttypgrp_ok = 0;
} else {
- if (tcsetpgrp(tty_fd, kshpid) < 0) {
+ if (tcsetpgrp(tty_fd, kshpid) == -1) {
warningf(false,
"%s: tcsetpgrp() failed: %s",
__func__, strerror(errno));
@@ -318,7 +318,7 @@ j_change(void)
while (1) {
pid_t ttypgrp;
- if ((ttypgrp = tcgetpgrp(tty_fd)) < 0) {
+ if ((ttypgrp = tcgetpgrp(tty_fd)) == -1) {
warningf(false,
"%s: tcgetpgrp() failed: %s",
__func__, strerror(errno));
@@ -334,12 +334,12 @@ j_change(void)
setsig(&sigtraps[tt_sigs[i]], SIG_IGN,
SS_RESTORE_DFL|SS_FORCE);
if (ttypgrp_ok && our_pgrp != kshpid) {
- if (setpgid(0, kshpid) < 0) {
+ if (setpgid(0, kshpid) == -1) {
warningf(false, "%s: setpgid() failed: %s",
__func__, strerror(errno));
ttypgrp_ok = 0;
} else {
- if (tcsetpgrp(tty_fd, kshpid) < 0) {
+ if (tcsetpgrp(tty_fd, kshpid) == -1) {
warningf(false,
"%s: tcsetpgrp() failed: %s",
__func__, strerror(errno));
@@ -438,13 +438,13 @@ exchild(struct op *t, int flags, volatile int *xerrok,
/* create child process */
forksleep = 1;
- while ((i = fork()) < 0 && errno == EAGAIN && forksleep < 32) {
+ while ((i = fork()) == -1 && errno == EAGAIN && forksleep < 32) {
if (intrsig) /* allow user to ^C out... */
break;
sleep(forksleep);
forksleep <<= 1;
}
- if (i < 0) {
+ if (i == -1) {
kill_job(j, SIGKILL);
remove_job(j, "fork failed");
sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -675,7 +675,7 @@ j_kill(const char *cp, int sig)
} else {
if (j->state == PSTOPPED && (sig == SIGTERM || sig == SIGHUP))
(void) killpg(j->pgrp, SIGCONT);
- if (killpg(j->pgrp, sig) < 0) {
+ if (killpg(j->pgrp, sig) == -1) {
bi_errorf("%s: %s", cp, strerror(errno));
rv = 1;
}
@@ -739,7 +739,7 @@ j_resume(const char *cp, int bg)
/* See comment in j_waitj regarding saved_ttypgrp. */
if (ttypgrp_ok &&
tcsetpgrp(tty_fd, (j->flags & JF_SAVEDTTYPGRP) ?
- j->saved_ttypgrp : j->pgrp) < 0) {
+ j->saved_ttypgrp : j->pgrp) == -1) {
if (j->flags & JF_SAVEDTTY)
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -757,14 +757,14 @@ j_resume(const char *cp, int bg)
async_job = NULL;
}
- if (j->state == PRUNNING && killpg(j->pgrp, SIGCONT) < 0) {
+ if (j->state == PRUNNING && killpg(j->pgrp, SIGCONT) == -1) {
int err = errno;
if (!bg) {
j->flags &= ~JF_FG;
if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
- if (ttypgrp_ok && tcsetpgrp(tty_fd, our_pgrp) < 0) {
+ if (ttypgrp_ok && tcsetpgrp(tty_fd, our_pgrp) == -1) {
warningf(true,
"fg: 2nd tcsetpgrp(%d, %d) failed: %s",
tty_fd, (int) our_pgrp,
@@ -1030,7 +1030,7 @@ j_waitj(Job *j,
if (j->state == PSTOPPED &&
(j->saved_ttypgrp = tcgetpgrp(tty_fd)) >= 0)
j->flags |= JF_SAVEDTTYPGRP;
- if (tcsetpgrp(tty_fd, our_pgrp) < 0) {
+ if (tcsetpgrp(tty_fd, our_pgrp) == -1) {
warningf(true,
"%s: tcsetpgrp(%d, %d) failed: %s",
__func__, tty_fd, (int)our_pgrp,
@@ -1615,7 +1615,7 @@ kill_job(Job *j, int sig)
for (p = j->proc_list; p != NULL; p = p->next)
if (p->pid != 0)
- if (kill(p->pid, sig) < 0)
+ if (kill(p->pid, sig) == -1)
rval = -1;
return rval;
}
diff --git a/ksh.1 b/ksh.1
@@ -1,8 +1,8 @@
-.\" $OpenBSD: ksh.1,v 1.204 2019/06/19 18:18:22 millert Exp $
+.\" $OpenBSD: ksh.1,v 1.207 2019/06/24 15:05:17 jca Exp $
.\"
.\" Public Domain
.\"
-.Dd $Mdocdate: June 19 2019 $
+.Dd $Mdocdate: June 24 2019 $
.Dt KSH 1
.Os
.Sh NAME
@@ -750,7 +750,7 @@ expressions are patterns (e.g. the comparison
.Ic [[ foobar = f*r ]]
succeeds).
.It
-The
+The
.Ql <
and
.Ql >
@@ -5545,10 +5545,12 @@ Privileged shell profile.
.Rs
.%A Morris Bolsky
.%A David Korn
-.%B The KornShell Command and Programming Language, 2nd Edition
-.%D 1995
+.%B The KornShell Command and Programming Language
+.%D First Edition 1989
.%I Prentice Hall
-.%O ISBN 0131827006
+.%O ISBN 0135169720
+.\" The second edition of the above book (1995) is about ksh93,
+.\" but the OpenBSD ksh is a descendant from ksh88 via pdksh.
.Re
.Rs
.%A Stephen G. Kochan
diff --git a/main.c b/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.97 2019/02/20 23:59:17 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.98 2019/06/28 13:34:59 deraadt Exp $ */
/*
* startup, main loop, environments and error handling
@@ -282,7 +282,7 @@ main(int argc, char *argv[])
/* Try to use existing $PWD if it is valid */
if (pwd[0] != '/' ||
- stat(pwd, &s_pwd) < 0 || stat(".", &s_dot) < 0 ||
+ stat(pwd, &s_pwd) == -1 || stat(".", &s_dot) == -1 ||
s_pwd.st_dev != s_dot.st_dev ||
s_pwd.st_ino != s_dot.st_ino)
pwdx = NULL;
diff --git a/misc.c b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.72 2018/11/20 08:12:26 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.73 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Miscellaneous functions
@@ -1087,7 +1087,7 @@ blocking_read(int fd, char *buf, int nbytes)
int ret;
int tried_reset = 0;
- while ((ret = read(fd, buf, nbytes)) < 0) {
+ while ((ret = read(fd, buf, nbytes)) == -1) {
if (!tried_reset && errno == EAGAIN) {
int oerrno = errno;
if (reset_nonblock(fd) > 0) {
@@ -1110,12 +1110,12 @@ reset_nonblock(int fd)
{
int flags;
- if ((flags = fcntl(fd, F_GETFL)) < 0)
+ if ((flags = fcntl(fd, F_GETFL)) == -1)
return -1;
if (!(flags & O_NONBLOCK))
return 0;
flags &= ~O_NONBLOCK;
- if (fcntl(fd, F_SETFL, flags) < 0)
+ if (fcntl(fd, F_SETFL, flags) == -1)
return -1;
return 1;
}
diff --git a/path.c b/path.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: path.c,v 1.22 2018/01/06 16:28:58 millert Exp $ */
+/* $OpenBSD: path.c,v 1.23 2019/06/28 13:34:59 deraadt Exp $ */
#include <sys/stat.h>
@@ -248,7 +248,7 @@ do_phys_path(XString *xsp, char *xp, const char *path)
*xp = '\0';
llen = readlink(Xstring(*xsp, xp), lbuf, sizeof(lbuf) - 1);
- if (llen < 0) {
+ if (llen == -1) {
/* EINVAL means it wasn't a symlink... */
if (errno != EINVAL)
return NULL;
diff --git a/shf.c b/shf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shf.c,v 1.33 2018/03/15 16:51:29 anton Exp $ */
+/* $OpenBSD: shf.c,v 1.34 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Shell file I/O routines
@@ -49,7 +49,7 @@ shf_open(const char *name, int oflags, int mode, int sflags)
/* Rest filled in by reopen. */
fd = open(name, oflags, mode);
- if (fd < 0) {
+ if (fd == -1) {
afree(shf, shf->areap);
return NULL;
}
@@ -58,7 +58,7 @@ shf_open(const char *name, int oflags, int mode, int sflags)
nfd = fcntl(fd, F_DUPFD, FDBASE);
close(fd);
- if (nfd < 0) {
+ if (nfd == -1) {
afree(shf, shf->areap);
return NULL;
}
@@ -81,7 +81,7 @@ shf_fdopen(int fd, int sflags, struct shf *shf)
if (sflags & SHF_GETFL) {
int flags = fcntl(fd, F_GETFL);
- if (flags < 0)
+ if (flags == -1)
/* will get an error on first read/write */
sflags |= SHF_RDWR;
else {
@@ -138,7 +138,7 @@ shf_reopen(int fd, int sflags, struct shf *shf)
if (sflags & SHF_GETFL) {
int flags = fcntl(fd, F_GETFL);
- if (flags < 0)
+ if (flags == -1)
/* will get an error on first read/write */
sflags |= SHF_RDWR;
else {
@@ -223,7 +223,7 @@ shf_close(struct shf *shf)
if (shf->fd >= 0) {
ret = shf_flush(shf);
- if (close(shf->fd) < 0)
+ if (close(shf->fd) == -1)
ret = EOF;
}
if (shf->flags & SHF_ALLOCS)
@@ -242,7 +242,7 @@ shf_fdclose(struct shf *shf)
if (shf->fd >= 0) {
ret = shf_flush(shf);
- if (close(shf->fd) < 0)
+ if (close(shf->fd) == -1)
ret = EOF;
shf->rnleft = 0;
shf->rp = shf->buf;
@@ -350,7 +350,7 @@ shf_emptybuf(struct shf *shf, int flags)
while (ntowrite > 0) {
n = write(shf->fd, buf, ntowrite);
- if (n < 0) {
+ if (n == -1) {
if (errno == EINTR &&
!(shf->flags & SHF_INTERRUPT))
continue;
@@ -574,7 +574,7 @@ shf_putchar(int c, struct shf *shf)
return EOF;
}
while ((n = write(shf->fd, &cc, 1)) != 1)
- if (n < 0) {
+ if (n == -1) {
if (errno == EINTR &&
!(shf->flags & SHF_INTERRUPT))
continue;
@@ -641,7 +641,7 @@ shf_write(const char *buf, int nbytes, struct shf *shf)
nbytes -= ncopy;
while (ncopy > 0) {
n = write(shf->fd, buf, ncopy);
- if (n < 0) {
+ if (n == -1) {
if (errno == EINTR &&
!(shf->flags & SHF_INTERRUPT))
continue;
diff --git a/tty.c b/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.17 2018/03/15 16:51:29 anton Exp $ */
+/* $OpenBSD: tty.c,v 1.18 2019/06/28 13:34:59 deraadt Exp $ */
#include <errno.h>
#include <fcntl.h>
@@ -34,7 +34,7 @@ tty_init(int init_ttystate)
tty_devtty = 1;
tfd = open("/dev/tty", O_RDWR, 0);
- if (tfd < 0) {
+ if (tfd == -1) {
tty_devtty = 0;
warningf(false, "No controlling tty (open /dev/tty: %s)",
strerror(errno));
@@ -50,14 +50,14 @@ tty_init(int init_ttystate)
}
}
#ifdef F_DUPFD_CLOEXEC
- if ((tty_fd = fcntl(tfd, F_DUPFD_CLOEXEC, FDBASE)) < 0) {
+ if ((tty_fd = fcntl(tfd, F_DUPFD_CLOEXEC, FDBASE)) == -1) {
warningf(false, "%s: dup of tty fd failed: %s",
__func__, strerror(errno));
#else
- if ((tty_fd = fcntl(tfd, F_DUPFD, FDBASE)) < 0) {
+ if ((tty_fd = fcntl(tfd, F_DUPFD, FDBASE)) == -1) {
warningf(false, "%s: dup of tty fd failed: %s",
__func__, strerror(errno));
- } else if (fcntl(tty_fd, F_SETFD, FD_CLOEXEC) < 0) {
+ } else if (fcntl(tty_fd, F_SETFD, FD_CLOEXEC) == -1) {
warningf(false, "%s: set tty fd close-on-exec flag failed: %s",
__func__, strerror(errno));
close(tty_fd);