Skip to content

Commit

Permalink
Merge branch 'upstream/6.6' into 6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Oct 17, 2019
2 parents 423a52a + cad7d6e commit 806e031
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 86 deletions.
12 changes: 6 additions & 6 deletions c_ksh.c
Original file line number Diff line number Diff line change
@@ -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_*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
11 changes: 4 additions & 7 deletions c_test.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: c_test.c,v 1.25 2018/04/09 17:53:36 tobias Exp $ */
/* $OpenBSD: c_test.c,v 1.27 2019/06/28 13:34:59 deraadt Exp $ */

/*
* test(1); version 7-like -- author Erik Baalbergen
Expand Down Expand Up @@ -32,8 +32,7 @@
"-L"|"-h"|"-S"|"-H";
binary-operator ::= "="|"=="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
"-nt"|"-ot"|"-ef"|
"<"|">" # rules used for [[ .. ]] expressions
"-nt"|"-ot"|"-ef"|"<"|">"
;
operand ::= <any thing>
*/
Expand Down Expand Up @@ -195,9 +194,7 @@ test_isop(Test_env *te, Test_meta meta, const char *s)
sc1 = s[1];
for (; otab->op_text[0]; otab++)
if (sc1 == otab->op_text[1] &&
strcmp(s, otab->op_text) == 0 &&
((te->flags & TEF_DBRACKET) ||
(otab->op_num != TO_STLT && otab->op_num != TO_STGT)))
strcmp(s, otab->op_text) == 0)
return otab->op_num;
}
return TO_NONOP;
Expand Down Expand Up @@ -374,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;
Expand Down
4 changes: 2 additions & 2 deletions c_ulimit.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -163,7 +163,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
Expand Down
10 changes: 5 additions & 5 deletions edit.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -66,7 +66,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
Expand Down Expand Up @@ -391,7 +391,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;
Expand Down Expand Up @@ -615,12 +615,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);
Expand Down
6 changes: 3 additions & 3 deletions eval.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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/).
Expand Down
10 changes: 5 additions & 5 deletions exec.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)))) {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions history.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -256,7 +256,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) {
Expand Down
10 changes: 5 additions & 5 deletions io.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: io.c,v 1.36 2018/01/16 22:52:32 jca Exp $ */
/* $OpenBSD: io.c,v 1.38 2019/07/24 14:33:16 bcallah Exp $ */

/*
* shell buffered IO and formatted output
Expand Down Expand Up @@ -244,7 +244,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;
Expand All @@ -261,7 +261,7 @@ savefd(int fd)

if (fd < FDBASE) {
nfd = fcntl(fd, F_DUPFD_CLOEXEC, FDBASE);
if (nfd < 0) {
if (nfd == -1) {
if (errno == EBADF)
return -1;
else
Expand Down Expand Up @@ -292,7 +292,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])
Expand All @@ -319,7 +319,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;
Expand Down
24 changes: 12 additions & 12 deletions jobs.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -272,7 +272,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));
Expand All @@ -288,12 +288,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));
Expand Down Expand Up @@ -392,13 +392,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);
Expand Down Expand Up @@ -629,7 +629,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;
}
Expand Down Expand Up @@ -693,7 +693,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);
Expand All @@ -711,14 +711,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,
Expand Down Expand Up @@ -984,7 +984,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,
Expand Down Expand Up @@ -1569,7 +1569,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;
}
Loading

0 comments on commit 806e031

Please sign in to comment.