summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/cat/cat.c8
-rw-r--r--bin/chio/chio.c26
-rw-r--r--bin/cp/cp.c4
-rw-r--r--bin/cp/utils.c8
-rw-r--r--bin/csh/csh.c8
-rw-r--r--bin/csh/dir.c12
-rw-r--r--bin/csh/file.c4
-rw-r--r--bin/csh/func.c10
-rw-r--r--bin/csh/lex.c4
-rw-r--r--bin/csh/proc.c8
-rw-r--r--bin/csh/sem.c12
-rw-r--r--bin/date/date.c4
-rw-r--r--bin/dd/dd.c16
-rw-r--r--bin/dd/position.c6
-rw-r--r--bin/df/df.c6
-rw-r--r--bin/ed/buf.c17
-rw-r--r--bin/ed/main.c4
-rw-r--r--bin/ksh/c_ksh.c12
-rw-r--r--bin/ksh/c_test.c4
-rw-r--r--bin/ksh/c_ulimit.c4
-rw-r--r--bin/ksh/edit.c6
-rw-r--r--bin/ksh/eval.c6
-rw-r--r--bin/ksh/exec.c10
-rw-r--r--bin/ksh/history.c4
-rw-r--r--bin/ksh/io.c10
-rw-r--r--bin/ksh/jobs.c32
-rw-r--r--bin/ksh/main.c4
-rw-r--r--bin/ksh/misc.c8
-rw-r--r--bin/ksh/path.c4
-rw-r--r--bin/ksh/shf.c20
-rw-r--r--bin/ksh/tty.c6
-rw-r--r--bin/ln/ln.c4
-rw-r--r--bin/mkdir/mkdir.c8
-rw-r--r--bin/mt/mt.c8
-rw-r--r--bin/mt/mtrmt.c21
-rw-r--r--bin/mv/cp.c10
-rw-r--r--bin/mv/mv.c8
-rw-r--r--bin/pax/ar_io.c56
-rw-r--r--bin/pax/ar_subs.c4
-rw-r--r--bin/pax/buf_subs.c6
-rw-r--r--bin/pax/file_subs.c40
-rw-r--r--bin/pax/ftree.c8
-rw-r--r--bin/pax/pax.c10
-rw-r--r--bin/ps/nlist.c10
-rw-r--r--bin/rmdir/rmdir.c6
-rw-r--r--bin/stty/key.c8
-rw-r--r--bin/stty/stty.c14
47 files changed, 250 insertions, 258 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index ed28a7f44bf..609e000db9f 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cat.c,v 1.26 2016/10/19 18:20:25 schwarze Exp $ */
+/* $OpenBSD: cat.c,v 1.27 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: cat.c,v 1.11 1995/09/07 06:12:54 jtc Exp $ */
/*
@@ -206,7 +206,7 @@ raw_args(char **argv)
if (*argv) {
if (!strcmp(*argv, "-"))
fd = fileno(stdin);
- else if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
+ else if ((fd = open(*argv, O_RDONLY, 0)) == -1) {
warn("%s", *argv);
rval = 1;
++argv;
@@ -231,7 +231,7 @@ raw_cat(int rfd)
wfd = fileno(stdout);
if (buf == NULL) {
- if (fstat(wfd, &sbuf))
+ if (fstat(wfd, &sbuf) == -1)
err(1, "stdout");
bsize = MAXIMUM(sbuf.st_blksize, BUFSIZ);
if ((buf = malloc(bsize)) == NULL)
@@ -242,7 +242,7 @@ raw_cat(int rfd)
if ((nw = write(wfd, buf + off, (size_t)nr)) == 0 ||
nw == -1)
err(1, "stdout");
- if (nr < 0) {
+ if (nr == -1) {
warn("%s", filename);
rval = 1;
}
diff --git a/bin/chio/chio.c b/bin/chio/chio.c
index a0a7c57b693..bbf221a0019 100644
--- a/bin/chio/chio.c
+++ b/bin/chio/chio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chio.c,v 1.25 2014/03/16 18:38:30 guenther Exp $ */
+/* $OpenBSD: chio.c,v 1.26 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: chio.c,v 1.1.1.1 1996/04/03 00:34:38 thorpej Exp $ */
/*
@@ -219,7 +219,7 @@ do_move(char *cname, int argc, char *argv[])
}
/* Send command to changer. */
- if (ioctl(changer_fd, CHIOMOVE, &cmd))
+ if (ioctl(changer_fd, CHIOMOVE, &cmd) == -1)
err(1, "%s: CHIOMOVE", changer_name);
return (0);
@@ -312,7 +312,7 @@ do_exchange(char *cname, int argc, char *argv[])
}
/* Send command to changer. */
- if (ioctl(changer_fd, CHIOEXCHANGE, &cmd))
+ if (ioctl(changer_fd, CHIOEXCHANGE, &cmd) == -1)
err(1, "%s: CHIOEXCHANGE", changer_name);
return (0);
@@ -373,7 +373,7 @@ do_position(char *cname, int argc, char *argv[])
}
/* Send command to changer. */
- if (ioctl(changer_fd, CHIOPOSITION, &cmd))
+ if (ioctl(changer_fd, CHIOPOSITION, &cmd) == -1)
err(1, "%s: CHIOPOSITION", changer_name);
return (0);
@@ -400,7 +400,7 @@ do_params(char *cname, int argc, char *argv[])
/* Get params from changer and display them. */
bzero(&data, sizeof(data));
- if (ioctl(changer_fd, CHIOGPARAMS, &data))
+ if (ioctl(changer_fd, CHIOGPARAMS, &data) == -1)
err(1, "%s: CHIOGPARAMS", changer_name);
printf("%s: %d slot%s, %d drive%s, %d picker%s",
@@ -435,7 +435,7 @@ do_getpicker(char *cname, int argc, char *argv[])
}
/* Get current picker from changer and display it. */
- if (ioctl(changer_fd, CHIOGPICKER, &picker))
+ if (ioctl(changer_fd, CHIOGPICKER, &picker) == -1)
err(1, "%s: CHIOGPICKER", changer_name);
printf("%s: current picker: %d\n", changer_name, picker);
@@ -465,7 +465,7 @@ do_setpicker(char *cname, int argc, char *argv[])
picker = parse_element_unit(*argv);
/* Set the changer picker. */
- if (ioctl(changer_fd, CHIOSPICKER, &picker))
+ if (ioctl(changer_fd, CHIOSPICKER, &picker) == -1)
err(1, "%s: CHIOSPICKER", changer_name);
return (0);
@@ -525,7 +525,7 @@ do_status(char *cname, int argc, char *argv[])
* counts.
*/
bzero(&data, sizeof(data));
- if (ioctl(changer_fd, CHIOGPARAMS, &data))
+ if (ioctl(changer_fd, CHIOGPARAMS, &data) == -1)
err(1, "%s: CHIOGPARAMS", changer_name);
if (argc)
@@ -578,7 +578,7 @@ do_status(char *cname, int argc, char *argv[])
if (avoltag || pvoltag)
cmd.cesr_flags |= CESR_VOLTAGS;
- if (ioctl(changer_fd, CHIOGSTATUS, &cmd)) {
+ if (ioctl(changer_fd, CHIOGSTATUS, &cmd) == -1) {
free(cmd.cesr_data);
err(1, "%s: CHIOGSTATUS", changer_name);
}
@@ -634,7 +634,7 @@ check_source_drive(int unit)
* counts.
*/
bzero(&data, sizeof(data));
- if (ioctl(changer_fd, CHIOGPARAMS, &data))
+ if (ioctl(changer_fd, CHIOGPARAMS, &data) == -1)
err(1, "%s: CHIOGPARAMS", changer_name);
count = data.cp_ndrives;
@@ -648,7 +648,7 @@ check_source_drive(int unit)
if ((cmd.cesr_data) == NULL)
errx(1, "can't allocate status storage");
- if (ioctl(changer_fd, CHIOGSTATUS, &cmd)) {
+ if (ioctl(changer_fd, CHIOGSTATUS, &cmd) == -1) {
free(cmd.cesr_data);
err(1, "%s: CHIOGSTATUS", changer_name);
}
@@ -687,7 +687,7 @@ find_voltag(char *voltag, int *type, int *unit)
* counts.
*/
bzero(&data, sizeof(data));
- if (ioctl(changer_fd, CHIOGPARAMS, &data))
+ if (ioctl(changer_fd, CHIOGPARAMS, &data) == -1)
err(1, "%s: CHIOGPARAMS", changer_name);
found = 0;
@@ -724,7 +724,7 @@ find_voltag(char *voltag, int *type, int *unit)
errx(1, "can't allocate status storage");
cmd.cesr_flags |= CESR_VOLTAGS;
- if (ioctl(changer_fd, CHIOGSTATUS, &cmd)) {
+ if (ioctl(changer_fd, CHIOGSTATUS, &cmd) == -1) {
free(cmd.cesr_data);
err(1, "%s: CHIOGSTATUS", changer_name);
}
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index c0a0d63dbeb..791e1d18c54 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cp.c,v 1.52 2019/01/28 18:58:42 jca Exp $ */
+/* $OpenBSD: cp.c,v 1.53 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
@@ -425,7 +425,7 @@ copy(char *argv[], enum op type, int fts_options)
*/
if (fts_dne(curr)) {
if (mkdir(to.p_path,
- curr->fts_statp->st_mode | S_IRWXU) < 0)
+ curr->fts_statp->st_mode | S_IRWXU) == -1)
err(1, "%s", to.p_path);
else if (vflag)
(void)fprintf(stdout, "%s -> %s\n",
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index 2275c127b76..a2f480c3393 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.47 2019/01/28 18:58:42 jca Exp $ */
+/* $OpenBSD: utils.c,v 1.48 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
@@ -129,7 +129,7 @@ copy_file(FTSENT *entp, int exists)
rval = 1;
}
/* Some systems don't unmap on close(2). */
- if (munmap(p, fs->st_size) < 0) {
+ if (munmap(p, fs->st_size) == -1) {
warn("%s", entp->fts_path);
rval = 1;
}
@@ -152,9 +152,9 @@ copy_file(FTSENT *entp, int exists)
break;
}
}
- if (skipholes && rcount >= 0)
+ if (skipholes && rcount != -1)
rcount = ftruncate(to_fd, lseek(to_fd, 0, SEEK_CUR));
- if (rcount < 0) {
+ if (rcount == -1) {
warn("%s", entp->fts_path);
rval = 1;
}
diff --git a/bin/csh/csh.c b/bin/csh/csh.c
index 9709b7cdee6..98e665507d1 100644
--- a/bin/csh/csh.c
+++ b/bin/csh/csh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: csh.c,v 1.45 2018/10/24 06:01:03 martijn Exp $ */
+/* $OpenBSD: csh.c,v 1.46 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: csh.c,v 1.14 1995/04/29 23:21:28 mycroft Exp $ */
/*-
@@ -343,7 +343,7 @@ main(int argc, char *argv[])
*/
if (nofile == 0 && argc > 0) {
nofile = open(tempv[0], O_RDONLY);
- if (nofile < 0) {
+ if (nofile == -1) {
child = 1; /* So this doesn't return */
stderror(ERR_SYSTEM, tempv[0], strerror(errno));
}
@@ -662,7 +662,7 @@ srcunit(int unit, bool onlyown, bool hflg)
if (onlyown) {
struct stat stb;
- if (fstat(unit, &stb) < 0) {
+ if (fstat(unit, &stb) == -1) {
(void) close(unit);
return;
}
@@ -1127,7 +1127,7 @@ mailchk(void)
if (chktim + intvl > t)
return;
for (; *vp; vp++) {
- if (stat(short2str(*vp), &stb) < 0)
+ if (stat(short2str(*vp), &stb) == -1)
continue;
new = stb.st_mtime > time0.tv_sec;
if (stb.st_size == 0 || stb.st_atime > stb.st_mtime ||
diff --git a/bin/csh/dir.c b/bin/csh/dir.c
index 16cec8ecfc1..d66fc677c8f 100644
--- a/bin/csh/dir.c
+++ b/bin/csh/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.23 2018/10/24 06:01:03 martijn Exp $ */
+/* $OpenBSD: dir.c,v 1.24 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: dir.c,v 1.9 1995/03/21 09:02:42 cgd Exp $ */
/*-
@@ -328,7 +328,7 @@ dochngd(Char **v, struct command *t)
if (*v == NULL) {
if ((cp = value(STRhome)) == NULL || *cp == 0)
stderror(ERR_NAME | ERR_NOHOMEDIR);
- if (chdir(short2str(cp)) < 0)
+ if (chdir(short2str(cp)) == -1)
stderror(ERR_NAME | ERR_CANTCHANGE);
cp = Strsave(cp);
}
@@ -341,7 +341,7 @@ dochngd(Char **v, struct command *t)
char *tmp;
printd = 1;
- if (chdir(tmp = short2str(dp->di_name)) < 0)
+ if (chdir(tmp = short2str(dp->di_name)) == -1)
stderror(ERR_SYSTEM, tmp, strerror(errno));
dcwd->di_prev->di_next = dcwd->di_next;
dcwd->di_next->di_prev = dcwd->di_prev;
@@ -478,7 +478,7 @@ dopushd(Char **v, struct command *t)
dp = dhead.di_prev;
if (dp == dcwd)
stderror(ERR_NAME | ERR_NODIR);
- if (chdir(tmp = short2str(dp->di_name)) < 0)
+ if (chdir(tmp = short2str(dp->di_name)) == -1)
stderror(ERR_SYSTEM, tmp, strerror(errno));
dp->di_prev->di_next = dp->di_next;
dp->di_next->di_prev = dp->di_prev;
@@ -495,7 +495,7 @@ dopushd(Char **v, struct command *t)
else if ((dp = dfind(*v)) != NULL) {
char *tmp;
- if (chdir(tmp = short2str(dp->di_name)) < 0)
+ if (chdir(tmp = short2str(dp->di_name)) == -1)
stderror(ERR_SYSTEM, tmp, strerror(errno));
}
else {
@@ -569,7 +569,7 @@ dopopd(Char **v, struct command *t)
if ((p = dp->di_prev) == &dhead)
p = dhead.di_prev;
- if (chdir(tmp = short2str(p->di_name)) < 0)
+ if (chdir(tmp = short2str(p->di_name)) == -1)
stderror(ERR_SYSTEM, tmp, strerror(errno));
}
dp->di_prev->di_next = dp->di_next;
diff --git a/bin/csh/file.c b/bin/csh/file.c
index f04ea2b7fea..ab881d5f5a1 100644
--- a/bin/csh/file.c
+++ b/bin/csh/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.37 2017/11/16 19:22:33 anton Exp $ */
+/* $OpenBSD: file.c,v 1.38 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: file.c,v 1.11 1996/11/08 19:34:37 christos Exp $ */
/*-
@@ -472,7 +472,7 @@ print_by_column(Char *dir, Char *items[], int count)
struct winsize win;
int i, rows, r, c, maxwidth = 0, columns;
- if (ioctl(SHOUT, TIOCGWINSZ, (ioctl_t) & win) < 0 || win.ws_col == 0)
+ if (ioctl(SHOUT, TIOCGWINSZ, (ioctl_t) & win) == -1 || win.ws_col == 0)
win.ws_col = 80;
for (i = 0; i < count; i++)
maxwidth = maxwidth > (r = Strlen(items[i])) ? maxwidth : r;
diff --git a/bin/csh/func.c b/bin/csh/func.c
index b34874328f4..fa6530303fc 100644
--- a/bin/csh/func.c
+++ b/bin/csh/func.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: func.c,v 1.38 2018/09/08 01:28:39 miko Exp $ */
+/* $OpenBSD: func.c,v 1.39 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: func.c,v 1.11 1996/02/09 02:28:29 christos Exp $ */
/*-
@@ -1101,7 +1101,7 @@ dolimit(Char **v, struct command *t)
return;
}
limit = getval(lp, v + 1);
- if (setlim(lp, hard, limit) < 0)
+ if (setlim(lp, hard, limit) == -1)
stderror(ERR_SILENT);
}
@@ -1221,7 +1221,7 @@ dounlimit(Char **v, struct command *t)
}
if (*v == 0) {
for (lp = limits; lp->limconst >= 0; lp++)
- if (setlim(lp, hard, RLIM_INFINITY) < 0)
+ if (setlim(lp, hard, RLIM_INFINITY) == -1)
lerr++;
if (lerr)
stderror(ERR_SILENT);
@@ -1229,7 +1229,7 @@ dounlimit(Char **v, struct command *t)
}
while (*v) {
lp = findlim(*v++);
- if (setlim(lp, hard, RLIM_INFINITY) < 0)
+ if (setlim(lp, hard, RLIM_INFINITY) == -1)
stderror(ERR_SILENT);
}
}
@@ -1248,7 +1248,7 @@ setlim(struct limits *lp, Char hard, rlim_t limit)
else
rlim.rlim_cur = limit;
- if (setrlimit(lp->limconst, &rlim) < 0) {
+ if (setrlimit(lp->limconst, &rlim) == -1) {
(void) fprintf(csherr, "%s: %s: Can't %s%s limit\n", bname, lp->limname,
limit == RLIM_INFINITY ? "remove" : "set",
hard ? " hard" : "");
diff --git a/bin/csh/lex.c b/bin/csh/lex.c
index 974eeaf44e9..5d20e22eb04 100644
--- a/bin/csh/lex.c
+++ b/bin/csh/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.30 2018/10/24 06:01:03 martijn Exp $ */
+/* $OpenBSD: lex.c,v 1.31 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: lex.c,v 1.9 1995/09/27 00:38:46 jtc Exp $ */
/*-
@@ -1553,7 +1553,7 @@ settell(void)
cantell = 0;
if (arginp || onelflg || intty)
return;
- if (lseek(SHIN, (off_t) 0, SEEK_CUR) < 0 || errno == ESPIPE)
+ if (lseek(SHIN, (off_t) 0, SEEK_CUR) == -1 || errno == ESPIPE)
return;
fbuf = xcalloc(2, sizeof(*fbuf));
fblocks = 1;
diff --git a/bin/csh/proc.c b/bin/csh/proc.c
index 12bf6ee47af..44274cc2744 100644
--- a/bin/csh/proc.c
+++ b/bin/csh/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.32 2018/09/08 01:28:39 miko Exp $ */
+/* $OpenBSD: proc.c,v 1.33 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: proc.c,v 1.9 1995/04/29 23:21:33 mycroft Exp $ */
/*-
@@ -1042,7 +1042,7 @@ pkill(Char **v, int signum)
pstart(pp, 0);
goto cont;
}
- if (kill(-pp->p_jobid, signum) < 0) {
+ if (kill(-pp->p_jobid, signum) == -1) {
(void) fprintf(csherr, "%s: %s\n", vis_str(cp),
strerror(errno));
err1++;
@@ -1062,7 +1062,7 @@ pkill(Char **v, int signum)
err1++;
goto cont;
}
- if (kill((pid_t) pid, signum) < 0) {
+ if (kill((pid_t) pid, signum) == -1) {
(void) fprintf(csherr, "%d: %s\n", pid, strerror(errno));
err1++;
goto cont;
@@ -1258,7 +1258,7 @@ pfork(struct command *t, int wanttty)
sigemptyset(&sigset);
sigaddset(&sigset, SIGCHLD);
sigprocmask(SIG_BLOCK, &sigset, &osigset);
- while ((pid = fork()) < 0)
+ while ((pid = fork()) == -1)
if (setintr == 0)
(void) sleep(FORKSLEEP);
else {
diff --git a/bin/csh/sem.c b/bin/csh/sem.c
index 2ca92f54f90..f9ffff8a08d 100644
--- a/bin/csh/sem.c
+++ b/bin/csh/sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sem.c,v 1.22 2016/03/19 15:42:38 krw Exp $ */
+/* $OpenBSD: sem.c,v 1.23 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: sem.c,v 1.9 1995/09/27 00:38:50 jtc Exp $ */
/*-
@@ -254,7 +254,7 @@ execute(struct command *t, int wanttty, int *pipein, int *pipeout)
Vt = 0;
pid = vfork();
- if (pid < 0) {
+ if (pid == -1) {
sigprocmask(SIG_SETMASK, &osigset, NULL);
stderror(ERR_NOPROC);
}
@@ -529,7 +529,7 @@ doio(struct command *t, int *pipein, int *pipeout)
cp = splicepipe(t, t->t_dlef);
strlcpy(tmp, short2str(cp), sizeof tmp);
free(cp);
- if ((fd = open(tmp, O_RDONLY)) < 0)
+ if ((fd = open(tmp, O_RDONLY)) == -1)
stderror(ERR_SYSTEM, tmp, strerror(errno));
(void) dmove(fd, 0);
}
@@ -568,7 +568,7 @@ doio(struct command *t, int *pipein, int *pipeout)
stderror(ERR_SYSTEM, tmp, strerror(errno));
chkclob(tmp);
}
- if ((fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
+ if ((fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0666)) == -1)
stderror(ERR_SYSTEM, tmp, strerror(errno));
}
(void) dmove(fd, 1);
@@ -598,7 +598,7 @@ void
mypipe(int *pv)
{
- if (pipe(pv) < 0)
+ if (pipe(pv) == -1)
goto oops;
pv[0] = dmove(pv[0], -1);
pv[1] = dmove(pv[1], -1);
@@ -613,7 +613,7 @@ chkclob(char *cp)
{
struct stat stb;
- if (stat(cp, &stb) < 0)
+ if (stat(cp, &stb) == -1)
return;
if (S_ISCHR(stb.st_mode))
return;
diff --git a/bin/date/date.c b/bin/date/date.c
index 3cd6199c24f..63adee969dc 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: date.c,v 1.54 2019/01/21 21:37:15 tedu Exp $ */
+/* $OpenBSD: date.c,v 1.55 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */
/*
@@ -237,7 +237,7 @@ setthetime(char *p, const char *pformat)
}
/* convert broken-down time to UTC clock time */
- if ((tval = mktime(lt)) < 0)
+ if ((tval = mktime(lt)) == -1)
errx(1, "specified date is outside allowed range");
if (jflag)
diff --git a/bin/dd/dd.c b/bin/dd/dd.c
index 3db20cf635a..300d8ada685 100644
--- a/bin/dd/dd.c
+++ b/bin/dd/dd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dd.c,v 1.26 2019/02/16 10:54:00 bluhm Exp $ */
+/* $OpenBSD: dd.c,v 1.27 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: dd.c,v 1.6 1996/02/20 19:29:06 jtc Exp $ */
/*-
@@ -96,7 +96,7 @@ setup(void)
in.fd = STDIN_FILENO;
} else {
in.fd = open(in.name, O_RDONLY, 0);
- if (in.fd < 0)
+ if (in.fd == -1)
err(1, "%s", in.name);
}
@@ -118,11 +118,11 @@ setup(void)
* Without read we may have a problem if output also does
* not support seeks.
*/
- if (out.fd < 0) {
+ if (out.fd == -1) {
out.fd = open(out.name, O_WRONLY | OFLAGS, DEFFILEMODE);
out.flags |= NOREAD;
}
- if (out.fd < 0)
+ if (out.fd == -1)
err(1, "%s", out.name);
}
@@ -257,7 +257,7 @@ dd_in(void)
}
/* Read error. */
- if (n < 0) {
+ if (n == -1) {
/*
* If noerror not specified, die. POSIX requires that
* the warning message be followed by an I/O display.
@@ -381,9 +381,9 @@ dd_out(int force)
for (n = force ? out.dbcnt : out.dbsz;; n = out.dbsz) {
for (cnt = n;; cnt -= nw) {
nw = write(out.fd, outp, cnt);
- if (nw <= 0) {
- if (nw == 0)
- errx(1, "%s: end of device", out.name);
+ if (nw == 0)
+ errx(1, "%s: end of device", out.name);
+ if (nw == -1) {
if (errno != EINTR)
err(1, "%s", out.name);
nw = 0;
diff --git a/bin/dd/position.c b/bin/dd/position.c
index 1f0a9382be9..ee8b039bdae 100644
--- a/bin/dd/position.c
+++ b/bin/dd/position.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: position.c,v 1.10 2009/10/27 23:59:21 deraadt Exp $ */
+/* $OpenBSD: position.c,v 1.11 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: position.c,v 1.4 1995/03/21 09:04:12 cgd Exp $ */
/*-
@@ -134,7 +134,7 @@ pos_out(void)
t_op.mt_op = MTFSR;
t_op.mt_count = out.offset;
- if (ioctl(out.fd, MTIOCTOP, &t_op) < 0)
+ if (ioctl(out.fd, MTIOCTOP, &t_op) == -1)
err(1, "%s", out.name);
return;
}
@@ -144,7 +144,7 @@ pos_out(void)
if ((n = read(out.fd, out.db, out.dbsz)) > 0)
continue;
- if (n < 0)
+ if (n == -1)
err(1, "%s", out.name);
/*
diff --git a/bin/df/df.c b/bin/df/df.c
index 981f64340f9..fd51f906f89 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: df.c,v 1.59 2016/08/14 21:07:40 krw Exp $ */
+/* $OpenBSD: df.c,v 1.60 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: df.c,v 1.21.2.1 1995/11/01 00:06:11 jtc Exp $ */
/*
@@ -129,7 +129,7 @@ main(int argc, char *argv[])
err(1, NULL);
mntsize = 0;
for (; *argv; argv++) {
- if (stat(*argv, &stbuf) < 0) {
+ if (stat(*argv, &stbuf) == -1) {
if ((mntpt = getmntpt(*argv)) == 0) {
warn("%s", *argv);
continue;
@@ -421,7 +421,7 @@ raw_df(char *file, struct statfs *sfsp)
{
int rfd, ret = -1;
- if ((rfd = open(file, O_RDONLY)) < 0) {
+ if ((rfd = open(file, O_RDONLY)) == -1) {
warn("%s", file);
return (-1);
}
diff --git a/bin/ed/buf.c b/bin/ed/buf.c
index 14987cfcda7..06dc7ebc89c 100644
--- a/bin/ed/buf.c
+++ b/bin/ed/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.23 2016/03/22 17:58:28 mmcc Exp $ */
+/* $OpenBSD: buf.c,v 1.24 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: buf.c,v 1.15 1995/04/23 10:07:28 cgd Exp $ */
/* buf.c: This file contains the scratch-file buffer routines for the
@@ -55,8 +55,7 @@ get_sbuf_line(line_t *lp)
{
static char *sfbuf = NULL; /* buffer */
static int sfbufsz = 0; /* buffer size */
-
- int len, ct;
+ int len;
if (lp == &buffer_head)
return NULL;
@@ -64,7 +63,7 @@ get_sbuf_line(line_t *lp)
/* out of position */
if (sfseek != lp->seek) {
sfseek = lp->seek;
- if (fseeko(sfp, sfseek, SEEK_SET) < 0) {
+ if (fseeko(sfp, sfseek, SEEK_SET) == -1) {
perror(NULL);
seterrmsg("cannot seek temp file");
return NULL;
@@ -72,7 +71,7 @@ get_sbuf_line(line_t *lp)
}
len = lp->len;
REALLOC(sfbuf, sfbufsz, len + 1, NULL);
- if ((ct = fread(sfbuf, sizeof(char), len, sfp)) < 0 || ct != len) {
+ if (fread(sfbuf, sizeof(char), len, sfp) != len) {
perror(NULL);
seterrmsg("cannot read temp file");
return NULL;
@@ -89,7 +88,7 @@ char *
put_sbuf_line(char *cs)
{
line_t *lp;
- int len, ct;
+ int len;
char *s;
if ((lp = malloc(sizeof(line_t))) == NULL) {
@@ -108,7 +107,7 @@ put_sbuf_line(char *cs)
len = s - cs;
/* out of position */
if (seek_write) {
- if (fseek(sfp, 0L, SEEK_END) < 0) {
+ if (fseek(sfp, 0L, SEEK_END) == -1) {
perror(NULL);
seterrmsg("cannot seek temp file");
free(lp);
@@ -118,7 +117,7 @@ put_sbuf_line(char *cs)
seek_write = 0;
}
/* assert: SPL1() */
- if ((ct = fwrite(cs, sizeof(char), len, sfp)) < 0 || ct != len) {
+ if (fwrite(cs, sizeof(char), len, sfp) != len) {
sfseek = -1;
perror(NULL);
seterrmsg("cannot write temp file");
@@ -226,7 +225,7 @@ int
close_sbuf(void)
{
if (sfp) {
- if (fclose(sfp) < 0) {
+ if (fclose(sfp) == EOF) {
perror(sfn);
seterrmsg("cannot close temp file");
return ERR;
diff --git a/bin/ed/main.c b/bin/ed/main.c
index d01a3955eb3..dc73dd92b69 100644
--- a/bin/ed/main.c
+++ b/bin/ed/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.65 2018/06/15 08:45:03 martijn Exp $ */
+/* $OpenBSD: main.c,v 1.66 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */
/* main.c: This file contains the main control and user-interface routines
@@ -1384,7 +1384,7 @@ handle_winch(int signo)
int save_errno = errno;
struct winsize ws; /* window size structure */
- if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) >= 0) {
+ if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == 0) {
if (ws.ws_row > 2)
rows = ws.ws_row - 2;
if (ws.ws_col > 8)
diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c
index 89b7a9c5545..cd75f77ad6f 100644
--- a/bin/ksh/c_ksh.c
+++ b/bin/ksh/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/bin/ksh/c_test.c b/bin/ksh/c_test.c
index 8422c0936a4..7038a52bfa4 100644
--- a/bin/ksh/c_test.c
+++ b/bin/ksh/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/bin/ksh/c_ulimit.c b/bin/ksh/c_ulimit.c
index 1ba64f46707..65e0ccaddce 100644
--- a/bin/ksh/c_ulimit.c
+++ b/bin/ksh/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/bin/ksh/edit.c b/bin/ksh/edit.c
index a7a6c200f0c..3089d195d20 100644
--- a/bin/ksh/edit.c
+++ b/bin/ksh/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.68 2019/06/27 18:03:36 deraadt 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;
diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c
index 5791d7348b6..ba4b73f404e 100644
--- a/bin/ksh/eval.c
+++ b/bin/ksh/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/bin/ksh/exec.c b/bin/ksh/exec.c
index 1d274919fcb..3cc2cde1a97 100644
--- a/bin/ksh/exec.c
+++ b/bin/ksh/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/bin/ksh/history.c b/bin/ksh/history.c
index 1448f8abc58..a3a8b60cc76 100644
--- a/bin/ksh/history.c
+++ b/bin/ksh/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
@@ -252,7 +252,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/bin/ksh/io.c b/bin/ksh/io.c
index 5d8f1564c72..377cb9b14f8 100644
--- a/bin/ksh/io.c
+++ b/bin/ksh/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;
@@ -260,7 +260,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
@@ -291,7 +291,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])
@@ -318,7 +318,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/bin/ksh/jobs.c b/bin/ksh/jobs.c
index ba738663390..f99c9eb74c8 100644
--- a/bin/ksh/jobs.c
+++ b/bin/ksh/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/bin/ksh/main.c b/bin/ksh/main.c
index 86e0bbf56af..a85cddfa9b3 100644
--- a/bin/ksh/main.c
+++ b/bin/ksh/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
@@ -280,7 +280,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/bin/ksh/misc.c b/bin/ksh/misc.c
index 6e04514161b..8f673085583 100644
--- a/bin/ksh/misc.c
+++ b/bin/ksh/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
@@ -1085,7 +1085,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) {
@@ -1108,12 +1108,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/bin/ksh/path.c b/bin/ksh/path.c
index 5da57a3f829..d046f00b11d 100644
--- a/bin/ksh/path.c
+++ b/bin/ksh/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/bin/ksh/shf.c b/bin/ksh/shf.c
index 98097713360..b2670b93fd0 100644
--- a/bin/ksh/shf.c
+++ b/bin/ksh/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/bin/ksh/tty.c b/bin/ksh/tty.c
index e93b0a5d1dd..6588d9cdd99 100644
--- a/bin/ksh/tty.c
+++ b/bin/ksh/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));
@@ -49,7 +49,7 @@ tty_init(int init_ttystate)
return;
}
}
- 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 (init_ttystate)
diff --git a/bin/ln/ln.c b/bin/ln/ln.c
index ae0d34ed383..ec191ef6aac 100644
--- a/bin/ln/ln.c
+++ b/bin/ln/ln.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ln.c,v 1.24 2016/05/10 20:20:43 tim Exp $ */
+/* $OpenBSD: ln.c,v 1.25 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: ln.c,v 1.10 1995/03/21 09:06:10 cgd Exp $ */
/*
@@ -178,7 +178,7 @@ linkit(char *target, char *source, int isdir)
* If the file exists, and -f was specified, unlink it.
* Attempt the link.
*/
- if ((fflag && unlink(source) < 0 && errno != ENOENT) ||
+ if ((fflag && unlink(source) == -1 && errno != ENOENT) ||
(sflag ? symlink(target, source) :
linkat(AT_FDCWD, target, AT_FDCWD, source,
Pflag ? 0 : AT_SYMLINK_FOLLOW))) {
diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c
index 1f94d0a51a8..635a77f23ec 100644
--- a/bin/mkdir/mkdir.c
+++ b/bin/mkdir/mkdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkdir.c,v 1.30 2016/10/19 18:20:25 schwarze Exp $ */
+/* $OpenBSD: mkdir.c,v 1.31 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: mkdir.c,v 1.14 1995/06/25 21:59:21 mycroft Exp $ */
/*
@@ -109,7 +109,7 @@ main(int argc, char *argv[])
if (rv == 0 && mode > 0777)
rv = chmod(*argv, mode);
}
- if (rv < 0) {
+ if (rv == -1) {
warn("%s", *argv);
exitval = 1;
}
@@ -140,12 +140,12 @@ mkpath(char *path, mode_t mode, mode_t dir_mode)
*slash = '\0';
if (mkdir(path, done ? mode : dir_mode) == 0) {
- if (mode > 0777 && chmod(path, mode) < 0)
+ if (mode > 0777 && chmod(path, mode) == -1)
return (-1);
} else {
int mkdir_errno = errno;
- if (stat(path, &sb)) {
+ if (stat(path, &sb) == -1) {
/* Not there; use mkdir()s errno */
errno = mkdir_errno;
return (-1);
diff --git a/bin/mt/mt.c b/bin/mt/mt.c
index 2d60d2cc31e..29a74863491 100644
--- a/bin/mt/mt.c
+++ b/bin/mt/mt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mt.c,v 1.40 2019/01/22 21:20:13 krw Exp $ */
+/* $OpenBSD: mt.c,v 1.41 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: mt.c,v 1.14.2.1 1996/05/27 15:12:11 mrg Exp $ */
/*
@@ -122,7 +122,7 @@ _rmtstatus(int fd)
if (host)
return rmtstatus();
#endif
- if (ioctl(fd, MTIOCGET, &mt_status) < 0)
+ if (ioctl(fd, MTIOCGET, &mt_status) == -1)
err(2, "ioctl MTIOCGET");
return &mt_status;
}
@@ -217,7 +217,7 @@ main(int argc, char *argv[])
flags = comp->c_ronly ? O_RDONLY : O_WRONLY | O_CREAT;
/* NOTE: OPENDEV_PART required since cd(4) devices go through here. */
- if ((mtfd = _rmtopendev(tape, flags, OPENDEV_PART, &realtape)) < 0) {
+ if ((mtfd = _rmtopendev(tape, flags, OPENDEV_PART, &realtape)) == -1) {
if (errno != 0)
warn("%s", host ? tape : realtape);
exit(2);
@@ -231,7 +231,7 @@ main(int argc, char *argv[])
}
else
mt_com.mt_count = 1;
- if (_rmtmtioctop(mtfd, &mt_com) < 0) {
+ if (_rmtmtioctop(mtfd, &mt_com) == -1) {
if (eject)
err(2, "%s", tape);
else
diff --git a/bin/mt/mtrmt.c b/bin/mt/mtrmt.c
index 7e9bfe6c222..84e4dd57b40 100644
--- a/bin/mt/mtrmt.c
+++ b/bin/mt/mtrmt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mtrmt.c,v 1.22 2018/07/09 19:38:29 deraadt Exp $ */
+/* $OpenBSD: mtrmt.c,v 1.23 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: mtrmt.c,v 1.2 1996/03/06 06:22:07 scottr Exp $ */
/*-
@@ -104,7 +104,6 @@ void
rmtgetconn(void)
{
char *cp;
- static struct servent *sp = NULL;
static struct passwd *pwd = NULL;
#ifdef notdef
static int on = 1;
@@ -113,14 +112,6 @@ rmtgetconn(void)
int size;
int maxseg;
- if (sp == NULL) {
- sp = getservbyname("shell", "tcp");
- if (sp == NULL)
- errx(1, "shell/tcp: unknown service");
- pwd = getpwuid(getuid());
- if (pwd == NULL)
- errx(1, "who are you?");
- }
if ((cp = strchr(rmtpeer, '@')) != NULL) {
tuser = rmtpeer;
*cp = '\0';
@@ -130,7 +121,7 @@ rmtgetconn(void)
} else
tuser = pwd->pw_name;
- rmtape = rcmd(&rmtpeer, (u_short)sp->s_port, pwd->pw_name, tuser,
+ rmtape = rcmdsh(&rmtpeer, -1, pwd->pw_name, tuser,
_PATH_RMT, NULL);
if (rmtape == -1)
exit(1); /* rcmd already printed error message */
@@ -142,18 +133,20 @@ rmtgetconn(void)
size += 2 * 1024;
while (size > TP_BSIZE &&
- setsockopt(rmtape, SOL_SOCKET, SO_SNDBUF, &size, sizeof (size)) < 0)
+ setsockopt(rmtape, SOL_SOCKET, SO_SNDBUF, &size, sizeof (size)) == -1)
size -= TP_BSIZE;
(void)setsockopt(rmtape, SOL_SOCKET, SO_RCVBUF, &size, sizeof (size));
maxseg = 1024;
(void)setsockopt(rmtape, IPPROTO_TCP, TCP_MAXSEG, &maxseg,
- sizeof (maxseg));
+ sizeof (maxseg));
#ifdef notdef
- if (setsockopt(rmtape, IPPROTO_TCP, TCP_NODELAY, &on, sizeof (on)) < 0)
+ if (setsockopt(rmtape, IPPROTO_TCP, TCP_NODELAY, &on, sizeof (on)) == -1)
perror("TCP_NODELAY setsockopt");
#endif
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
}
static int
diff --git a/bin/mv/cp.c b/bin/mv/cp.c
index 34799f782af..281d5731910 100644
--- a/bin/mv/cp.c
+++ b/bin/mv/cp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cp.c,v 1.7 2015/12/27 01:25:57 chl Exp $ */
+/* $OpenBSD: cp.c,v 1.8 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
@@ -356,7 +356,7 @@ copy(char *argv[], enum op type, int fts_options)
*/
if (fts_dne(curr)) {
if (mkdir(to.p_path,
- curr->fts_statp->st_mode | S_IRWXU) < 0)
+ curr->fts_statp->st_mode | S_IRWXU) == -1)
err(1, "%s", to.p_path);
} else if (!S_ISDIR(to_stat.st_mode))
errc(1, ENOTDIR, "%s", to.p_path);
@@ -386,7 +386,7 @@ copy(char *argv[], enum op type, int fts_options)
}
-/* $OpenBSD: cp.c,v 1.7 2015/12/27 01:25:57 chl Exp $ */
+/* $OpenBSD: cp.c,v 1.8 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
@@ -520,7 +520,7 @@ copy_file(FTSENT *entp, int dne)
rval = 1;
}
/* Some systems don't unmap on close(2). */
- if (munmap(p, fs->st_size) < 0) {
+ if (munmap(p, fs->st_size) == -1) {
warn("%s", entp->fts_path);
rval = 1;
}
@@ -545,7 +545,7 @@ copy_file(FTSENT *entp, int dne)
}
if (skipholes && rcount >= 0)
rcount = ftruncate(to_fd, lseek(to_fd, 0, SEEK_CUR));
- if (rcount < 0) {
+ if (rcount == -1) {
warn("%s", entp->fts_path);
rval = 1;
}
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index cf8e07bdab0..674349f42c3 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mv.c,v 1.45 2017/06/27 21:43:46 tedu Exp $ */
+/* $OpenBSD: mv.c,v 1.46 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: mv.c,v 1.9 1995/03/21 09:06:52 cgd Exp $ */
/*
@@ -276,11 +276,11 @@ fastcopy(char *from, char *to, struct stat *sbp)
}
}
- if ((from_fd = open(from, O_RDONLY, 0)) < 0) {
+ if ((from_fd = open(from, O_RDONLY, 0)) == -1) {
warn("%s", from);
return (1);
}
- if ((to_fd = open(to, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0) {
+ if ((to_fd = open(to, O_CREAT | O_TRUNC | O_WRONLY, 0600)) == -1) {
warn("%s", to);
(void)close(from_fd);
return (1);
@@ -297,7 +297,7 @@ fastcopy(char *from, char *to, struct stat *sbp)
warn("%s", to);
goto err;
}
- if (nread < 0) {
+ if (nread == -1) {
warn("%s", from);
err: if (unlink(to))
warn("%s: remove", to);
diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c
index 40a6492405e..ddbd36ee720 100644
--- a/bin/pax/ar_io.c
+++ b/bin/pax/ar_io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar_io.c,v 1.62 2017/03/11 12:55:47 tb Exp $ */
+/* $OpenBSD: ar_io.c,v 1.63 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: ar_io.c,v 1.5 1996/03/26 23:54:13 mrg Exp $ */
/*-
@@ -111,7 +111,7 @@ ar_open(const char *name)
if (name == NULL) {
arfd = STDIN_FILENO;
arcname = STDN;
- } else if ((arfd = open(name, EXT_MODE, DMOD)) < 0)
+ } else if ((arfd = open(name, EXT_MODE, DMOD)) == -1)
syswarn(1, errno, "Failed open to read on %s", name);
if (arfd != -1 && gzip_program != NULL)
ar_start_gzip(arfd, gzip_program, 0);
@@ -120,7 +120,7 @@ ar_open(const char *name)
if (name == NULL) {
arfd = STDOUT_FILENO;
arcname = STDO;
- } else if ((arfd = open(name, AR_MODE, DMOD)) < 0)
+ } else if ((arfd = open(name, AR_MODE, DMOD)) == -1)
syswarn(1, errno, "Failed open to write on %s", name);
else
can_unlnk = 1;
@@ -131,7 +131,7 @@ ar_open(const char *name)
if (name == NULL) {
arfd = STDOUT_FILENO;
arcname = STDO;
- } else if ((arfd = open(name, APP_MODE, DMOD)) < 0)
+ } else if ((arfd = open(name, APP_MODE, DMOD)) == -1)
syswarn(1, errno, "Failed open to read/write on %s",
name);
break;
@@ -147,14 +147,14 @@ ar_open(const char *name)
return(-1);
if (chdname != NULL)
- if (chdir(chdname) != 0) {
+ if (chdir(chdname) == -1) {
syswarn(1, errno, "Failed chdir to %s", chdname);
return(-1);
}
/*
* set up is based on device type
*/
- if (fstat(arfd, &arsb) < 0) {
+ if (fstat(arfd, &arsb) == -1) {
syswarn(1, errno, "Failed stat on %s", arcname);
(void)close(arfd);
arfd = -1;
@@ -462,7 +462,7 @@ ar_set_wr(void)
* (it was not written by pax).
*/
if (((cpos = lseek(arfd, 0, SEEK_CUR)) < 0) ||
- (ftruncate(arfd, cpos) < 0)) {
+ (ftruncate(arfd, cpos) == -1)) {
syswarn(1, errno, "Unable to truncate archive file");
return(-1);
}
@@ -588,7 +588,7 @@ ar_read(char *buf, int cnt)
int
ar_write(char *buf, int bsz)
{
- int res;
+ ssize_t res;
off_t cpos;
/*
@@ -607,7 +607,7 @@ ar_write(char *buf, int bsz)
* write broke, see what we can do with it. We try to send any partial
* writes that may violate pax spec to the next archive volume.
*/
- if (res < 0)
+ if (res == -1)
lstrval = res;
else
lstrval = 0;
@@ -620,10 +620,10 @@ ar_write(char *buf, int bsz)
* in size by forcing the runt record to next archive
* volume
*/
- if ((cpos = lseek(arfd, 0, SEEK_CUR)) < 0)
+ if ((cpos = lseek(arfd, 0, SEEK_CUR)) == -1)
break;
cpos -= res;
- if (ftruncate(arfd, cpos) < 0)
+ if (ftruncate(arfd, cpos) == -1)
break;
res = lstrval = 0;
break;
@@ -743,7 +743,7 @@ ar_rdsync(void)
}
mb.mt_op = MTFSR;
mb.mt_count = 1;
- if (ioctl(arfd, MTIOCTOP, &mb) < 0)
+ if (ioctl(arfd, MTIOCTOP, &mb) == -1)
break;
lstrval = 1;
break;
@@ -756,10 +756,10 @@ ar_rdsync(void)
io_ok = 0;
if (((fsbz = arsb.st_blksize) <= 0) || (artyp != ISREG))
fsbz = BLKMULT;
- if ((cpos = lseek(arfd, 0, SEEK_CUR)) < 0)
+ if ((cpos = lseek(arfd, 0, SEEK_CUR)) == -1)
break;
mpos = fsbz - (cpos % fsbz);
- if (lseek(arfd, mpos, SEEK_CUR) < 0)
+ if (lseek(arfd, mpos, SEEK_CUR) == -1)
break;
lstrval = 1;
break;
@@ -885,7 +885,7 @@ ar_rev(off_t sksz)
* may not even have the ability to lseek() in any direction).
* First we figure out where we are in the archive.
*/
- if ((cpos = lseek(arfd, 0, SEEK_CUR)) < 0) {
+ if ((cpos = lseek(arfd, 0, SEEK_CUR)) == -1) {
syswarn(1, errno,
"Unable to obtain current archive byte offset");
lstrval = -1;
@@ -910,7 +910,7 @@ ar_rev(off_t sksz)
}
cpos = 0;
}
- if (lseek(arfd, cpos, SEEK_SET) < 0) {
+ if (lseek(arfd, cpos, SEEK_SET) == -1) {
syswarn(1, errno, "Unable to seek archive backwards");
lstrval = -1;
return(-1);
@@ -957,7 +957,7 @@ ar_rev(off_t sksz)
*/
mb.mt_op = MTBSR;
mb.mt_count = sksz/phyblk;
- if (ioctl(arfd, MTIOCTOP, &mb) < 0) {
+ if (ioctl(arfd, MTIOCTOP, &mb) == -1) {
syswarn(1,errno, "Unable to backspace tape %d blocks.",
mb.mt_count);
lstrval = -1;
@@ -1000,7 +1000,7 @@ get_phys(void)
*/
while ((res = read(arfd, scbuf, sizeof(scbuf))) > 0)
padsz += res;
- if (res < 0) {
+ if (res == -1) {
syswarn(1, errno, "Unable to locate tape filemark.");
return(-1);
}
@@ -1012,7 +1012,7 @@ get_phys(void)
*/
mb.mt_op = MTBSF;
mb.mt_count = 1;
- if (ioctl(arfd, MTIOCTOP, &mb) < 0) {
+ if (ioctl(arfd, MTIOCTOP, &mb) == -1) {
syswarn(1, errno, "Unable to backspace over tape filemark.");
return(-1);
}
@@ -1023,7 +1023,7 @@ get_phys(void)
*/
mb.mt_op = MTBSR;
mb.mt_count = 1;
- if (ioctl(arfd, MTIOCTOP, &mb) < 0) {
+ if (ioctl(arfd, MTIOCTOP, &mb) == -1) {
syswarn(1, errno, "Unable to backspace over last tape block.");
return(-1);
}
@@ -1038,13 +1038,13 @@ get_phys(void)
*/
while ((res = read(arfd, scbuf, sizeof(scbuf))) > 0)
continue;
- if (res < 0) {
+ if (res == -1) {
syswarn(1, errno, "Unable to locate tape filemark.");
return(-1);
}
mb.mt_op = MTBSF;
mb.mt_count = 1;
- if (ioctl(arfd, MTIOCTOP, &mb) < 0) {
+ if (ioctl(arfd, MTIOCTOP, &mb) == -1) {
syswarn(1, errno, "Unable to backspace over tape filemark.");
return(-1);
}
@@ -1075,7 +1075,7 @@ get_phys(void)
*/
mb.mt_op = MTBSR;
mb.mt_count = padsz/phyblk;
- if (ioctl(arfd, MTIOCTOP, &mb) < 0) {
+ if (ioctl(arfd, MTIOCTOP, &mb) == -1) {
syswarn(1,errno,"Unable to backspace tape over %d pad blocks",
mb.mt_count);
return(-1);
@@ -1105,10 +1105,10 @@ ar_next(void)
* things like writing EOF etc will be done) (Watch out ar_close() can
* also be called via a signal handler, so we must prevent a race.
*/
- if (sigprocmask(SIG_BLOCK, &s_mask, &o_mask) < 0)
+ if (sigprocmask(SIG_BLOCK, &s_mask, &o_mask) == -1)
syswarn(0, errno, "Unable to set signal mask");
ar_close(0);
- if (sigprocmask(SIG_SETMASK, &o_mask, NULL) < 0)
+ if (sigprocmask(SIG_SETMASK, &o_mask, NULL) == -1)
syswarn(0, errno, "Unable to restore signal mask");
if (done || !wr_trail || force_one_volume || op_mode == OP_TAR)
@@ -1245,10 +1245,10 @@ ar_start_gzip(int fd, const char *path, int wr)
int fds[2];
const char *gzip_flags;
- if (pipe(fds) < 0)
+ if (pipe(fds) == -1)
err(1, "could not pipe");
zpid = fork();
- if (zpid < 0)
+ if (zpid == -1)
err(1, "could not fork");
/* parent */
@@ -1281,7 +1281,7 @@ ar_start_gzip(int fd, const char *path, int wr)
/* System compressors are more likely to use pledge(2) */
putenv("PATH=/usr/bin:/usr/local/bin");
- if (execlp(path, path, gzip_flags, (char *)NULL) < 0)
+ if (execlp(path, path, gzip_flags, (char *)NULL) == -1)
err(1, "could not exec %s", path);
/* NOTREACHED */
}
diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c
index 51dd6e0859b..0a4f411466b 100644
--- a/bin/pax/ar_subs.c
+++ b/bin/pax/ar_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar_subs.c,v 1.48 2016/08/26 05:06:14 guenther Exp $ */
+/* $OpenBSD: ar_subs.c,v 1.49 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $ */
/*-
@@ -773,7 +773,7 @@ copy(void)
}
drem = PAXPATHLEN - dlen;
- if (stat(dirptr, &sb) < 0) {
+ if (stat(dirptr, &sb) == -1) {
syswarn(1, errno, "Cannot access destination directory %s",
dirptr);
return;
diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c
index 41f06ae31cd..e510f542e55 100644
--- a/bin/pax/buf_subs.c
+++ b/bin/pax/buf_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf_subs.c,v 1.30 2016/12/20 21:29:08 kettenis Exp $ */
+/* $OpenBSD: buf_subs.c,v 1.31 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: buf_subs.c,v 1.5 1995/03/21 09:07:08 cgd Exp $ */
/*-
@@ -626,7 +626,7 @@ wr_rdfile(ARCHD *arcn, int ifd, off_t *left)
syswarn(1, errno, "Read fault on %s", arcn->org_name);
else if (size != 0)
paxwarn(1, "File changed size during read %s", arcn->org_name);
- else if (fstat(ifd, &sb) < 0)
+ else if (fstat(ifd, &sb) == -1)
syswarn(1, errno, "Failed stat on %s", arcn->org_name);
else if (timespeccmp(&arcn->sb.st_mtim, &sb.st_mtim, !=))
paxwarn(1, "File %s was modified during copy to archive",
@@ -800,7 +800,7 @@ cp_file(ARCHD *arcn, int fd1, int fd2)
else if (cpcnt != arcn->sb.st_size)
paxwarn(1, "File %s changed size during copy to %s",
arcn->org_name, arcn->name);
- else if (fstat(fd1, &sb) < 0)
+ else if (fstat(fd1, &sb) == -1)
syswarn(1, errno, "Failed stat of %s", arcn->org_name);
else if (timespeccmp(&arcn->sb.st_mtim, &sb.st_mtim, !=))
paxwarn(1, "File %s was modified during copy to %s",
diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c
index 9f834bf1748..be8d0659590 100644
--- a/bin/pax/file_subs.c
+++ b/bin/pax/file_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file_subs.c,v 1.53 2017/01/21 08:17:06 krw Exp $ */
+/* $OpenBSD: file_subs.c,v 1.54 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: file_subs.c,v 1.4 1995/03/21 09:07:18 cgd Exp $ */
/*-
@@ -147,7 +147,7 @@ file_close(ARCHD *arcn, int fd)
if (patime || pmtime)
fset_ftime(arcn->name, fd, &arcn->sb.st_mtim,
&arcn->sb.st_atim, 0);
- if (close(fd) < 0)
+ if (close(fd) == -1)
syswarn(0, errno, "Unable to close file descriptor on %s",
arcn->name);
}
@@ -170,7 +170,7 @@ lnk_creat(ARCHD *arcn)
* we may be running as root, so we have to be sure that link target
* is not a directory, so we lstat and check
*/
- if (lstat(arcn->ln_name, &sb) < 0) {
+ if (lstat(arcn->ln_name, &sb) == -1) {
syswarn(1,errno,"Unable to link to %s from %s", arcn->ln_name,
arcn->name);
return(-1);
@@ -239,7 +239,7 @@ chk_same(ARCHD *arcn)
* if file does not exist, return. if file exists and -k, skip it
* quietly
*/
- if (lstat(arcn->name, &sb) < 0)
+ if (lstat(arcn->name, &sb) == -1)
return(1);
if (kflag)
return(0);
@@ -293,12 +293,12 @@ mk_link(char *to, struct stat *to_sb, char *from, int ign)
* try to get rid of the file, based on the type
*/
if (S_ISDIR(sb.st_mode)) {
- if (rmdir(from) < 0) {
+ if (rmdir(from) == -1) {
syswarn(1, errno, "Unable to remove %s", from);
return(-1);
}
delete_dir(sb.st_dev, sb.st_ino);
- } else if (unlink(from) < 0) {
+ } else if (unlink(from) == -1) {
if (!ign) {
syswarn(1, errno, "Unable to remove %s", from);
return(-1);
@@ -493,9 +493,9 @@ badlink:
* before pax exits. To do that safely, we want the dev+ino
* of the directory we created.
*/
- if (lstat(nm, &sb) < 0) {
+ if (lstat(nm, &sb) == -1) {
syswarn(0, errno,"Could not access %s (stat)", nm);
- } else if (access(nm, R_OK | W_OK | X_OK) < 0) {
+ } else if (access(nm, R_OK | W_OK | X_OK) == -1) {
/*
* We have to add rights to the dir, so we make
* sure to restore the mode. The mode must be
@@ -545,7 +545,7 @@ unlnk_exist(char *name, int type)
/*
* the file does not exist, or -k we are done
*/
- if (lstat(name, &sb) < 0)
+ if (lstat(name, &sb) == -1)
return(0);
if (kflag)
return(-1);
@@ -555,7 +555,7 @@ unlnk_exist(char *name, int type)
* try to remove a directory, if it fails and we were going to
* create a directory anyway, tell the caller (return a 1)
*/
- if (rmdir(name) < 0) {
+ if (rmdir(name) == -1) {
if (type == PAX_DIR)
return(1);
syswarn(1,errno,"Unable to remove directory %s", name);
@@ -568,7 +568,7 @@ unlnk_exist(char *name, int type)
/*
* try to get rid of all non-directory type nodes
*/
- if (unlink(name) < 0) {
+ if (unlink(name) == -1) {
syswarn(1, errno, "Could not unlink %s", name);
return(-1);
}
@@ -642,7 +642,7 @@ chk_path(char *name, uid_t st_uid, gid_t st_gid)
* the path fails at this point, see if we can create the
* needed directory and continue on
*/
- if (mkdir(name, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
+ if (mkdir(name, S_IRWXU | S_IRWXG | S_IRWXO) == -1) {
*spt = '/';
retval = -1;
break;
@@ -663,7 +663,7 @@ chk_path(char *name, uid_t st_uid, gid_t st_gid)
* the modes and restore them back to the creation default at
* the end of pax
*/
- if ((access(name, R_OK | W_OK | X_OK) < 0) &&
+ if ((access(name, R_OK | W_OK | X_OK) == -1) &&
(lstat(name, &sb) == 0)) {
set_pmode(name, ((sb.st_mode & FILEBITS) | S_IRWXU));
add_dir(name, &sb, 1);
@@ -736,7 +736,7 @@ fset_ftime(const char *fnm, int fd, const struct timespec *mtimp,
/*
* set the times
*/
- if (futimens(fd, tv) < 0)
+ if (futimens(fd, tv) == -1)
syswarn(1, errno, "Access/modification time set failed on: %s",
fnm);
}
@@ -751,7 +751,7 @@ fset_ftime(const char *fnm, int fd, const struct timespec *mtimp,
int
set_ids(char *fnm, uid_t uid, gid_t gid)
{
- if (fchownat(AT_FDCWD, fnm, uid, gid, AT_SYMLINK_NOFOLLOW) < 0) {
+ if (fchownat(AT_FDCWD, fnm, uid, gid, AT_SYMLINK_NOFOLLOW) == -1) {
/*
* ignore EPERM unless in verbose mode or being run by root.
* if running as pax, POSIX requires a warning.
@@ -768,7 +768,7 @@ set_ids(char *fnm, uid_t uid, gid_t gid)
int
fset_ids(char *fnm, int fd, uid_t uid, gid_t gid)
{
- if (fchown(fd, uid, gid) < 0) {
+ if (fchown(fd, uid, gid) == -1) {
/*
* ignore EPERM unless in verbose mode or being run by root.
* if running as pax, POSIX requires a warning.
@@ -791,7 +791,7 @@ void
set_pmode(char *fnm, mode_t mode)
{
mode &= ABITS;
- if (fchmodat(AT_FDCWD, fnm, mode, AT_SYMLINK_NOFOLLOW) < 0)
+ if (fchmodat(AT_FDCWD, fnm, mode, AT_SYMLINK_NOFOLLOW) == -1)
syswarn(1, errno, "Could not set permissions on %s", fnm);
}
@@ -799,7 +799,7 @@ void
fset_pmode(char *fnm, int fd, mode_t mode)
{
mode &= ABITS;
- if (fchmod(fd, mode) < 0)
+ if (fchmod(fd, mode) == -1)
syswarn(1, errno, "Could not set permissions on %s", fnm);
}
@@ -1032,7 +1032,7 @@ file_flush(int fd, char *fname, int isempt)
return;
}
- if (write(fd, blnk, 1) < 0)
+ if (write(fd, blnk, 1) == -1)
syswarn(1, errno, "Failed write to file %s", fname);
}
@@ -1111,7 +1111,7 @@ set_crc(ARCHD *arcn, int fd)
*/
if (cpcnt != arcn->sb.st_size)
paxwarn(1, "File changed size %s", arcn->org_name);
- else if (fstat(fd, &sb) < 0)
+ else if (fstat(fd, &sb) == -1)
syswarn(1, errno, "Failed stat on %s", arcn->org_name);
else if (timespeccmp(&arcn->sb.st_mtim, &sb.st_mtim, !=))
paxwarn(1, "File %s was modified during read", arcn->org_name);
diff --git a/bin/pax/ftree.c b/bin/pax/ftree.c
index eb76a1e540a..b780dbbf509 100644
--- a/bin/pax/ftree.c
+++ b/bin/pax/ftree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftree.c,v 1.41 2017/09/16 07:42:34 otto Exp $ */
+/* $OpenBSD: ftree.c,v 1.42 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: ftree.c,v 1.4 1995/03/21 09:07:21 cgd Exp $ */
/*-
@@ -308,12 +308,12 @@ ftree_arg(void)
return(-1);
if (ftcur->chflg) {
/* First fchdir() back... */
- if (fchdir(cwdfd) < 0) {
+ if (fchdir(cwdfd) == -1) {
syswarn(1, errno,
"Can't fchdir to starting directory");
return(-1);
}
- if (chdir(ftcur->fname) < 0) {
+ if (chdir(ftcur->fname) == -1) {
syswarn(1, errno, "Can't chdir to %s",
ftcur->fname);
return(-1);
@@ -480,7 +480,7 @@ next_file(ARCHD *arcn)
* have to read the symlink path from the file
*/
if ((cnt = readlink(ftent->fts_path, arcn->ln_name,
- PAXPATHLEN)) < 0) {
+ PAXPATHLEN)) == -1) {
syswarn(1, errno, "Unable to read symlink %s",
ftent->fts_path);
continue;
diff --git a/bin/pax/pax.c b/bin/pax/pax.c
index f6b3634369a..0ddfd9d91ed 100644
--- a/bin/pax/pax.c
+++ b/bin/pax/pax.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pax.c,v 1.52 2018/09/13 12:33:43 millert Exp $ */
+/* $OpenBSD: pax.c,v 1.53 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */
/*-
@@ -228,7 +228,7 @@ main(int argc, char **argv)
* Keep a reference to cwd, so we can always come back home.
*/
cwdfd = open(".", O_RDONLY | O_CLOEXEC);
- if (cwdfd < 0) {
+ if (cwdfd == -1) {
syswarn(1, errno, "Can't open current working directory.");
return(exit_val);
}
@@ -348,7 +348,7 @@ setup_sig(int sig, const struct sigaction *n_hand)
{
struct sigaction o_hand;
- if (sigaction(sig, NULL, &o_hand) < 0)
+ if (sigaction(sig, NULL, &o_hand) == -1)
return (-1);
if (o_hand.sa_handler == SIG_IGN)
@@ -433,8 +433,8 @@ gen_init(void)
goto out;
n_hand.sa_handler = SIG_IGN;
- if ((sigaction(SIGPIPE, &n_hand, NULL) < 0) ||
- (sigaction(SIGXFSZ, &n_hand, NULL) < 0))
+ if ((sigaction(SIGPIPE, &n_hand, NULL) == -1) ||
+ (sigaction(SIGXFSZ, &n_hand, NULL) == -1))
goto out;
return(0);
diff --git a/bin/ps/nlist.c b/bin/ps/nlist.c
index 49c646614bc..e762367518b 100644
--- a/bin/ps/nlist.c
+++ b/bin/ps/nlist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nlist.c,v 1.20 2017/01/24 22:40:09 deraadt Exp $ */
+/* $OpenBSD: nlist.c,v 1.21 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: nlist.c,v 1.11 1995/03/21 09:08:03 cgd Exp $ */
/*-
@@ -105,14 +105,14 @@ donlist(void)
siz = sizeof (fscale);
mib[0] = CTL_KERN;
mib[1] = KERN_FSCALE;
- if (sysctl(mib, 2, &fscale, &siz, NULL, 0) < 0) {
+ if (sysctl(mib, 2, &fscale, &siz, NULL, 0) == -1) {
warnx("fscale: failed to get kern.fscale");
eval = rval = 1;
}
siz = sizeof (physmem);
mib[0] = CTL_HW;
mib[1] = HW_PHYSMEM64;
- if (sysctl(mib, 2, &physmem, &siz, NULL, 0) < 0) {
+ if (sysctl(mib, 2, &physmem, &siz, NULL, 0) == -1) {
warnx("physmem: failed to get hw.physmem");
eval = rval = 1;
}
@@ -121,14 +121,14 @@ donlist(void)
siz = sizeof (ccpu);
mib[0] = CTL_KERN;
mib[1] = KERN_CCPU;
- if (sysctl(mib, 2, &ccpu, &siz, NULL, 0) < 0) {
+ if (sysctl(mib, 2, &ccpu, &siz, NULL, 0) == -1) {
warnx("ccpu: failed to get kern.ccpu");
eval = rval = 1;
}
siz = sizeof (maxslp);
mib[0] = CTL_VM;
mib[1] = VM_MAXSLP;
- if (sysctl(mib, 2, &maxslp, &siz, NULL, 0) < 0) {
+ if (sysctl(mib, 2, &maxslp, &siz, NULL, 0) == -1) {
warnx("maxslp: failed to get vm.maxslp");
eval = rval = 1;
}
diff --git a/bin/rmdir/rmdir.c b/bin/rmdir/rmdir.c
index 9a08fccf53a..0197254749a 100644
--- a/bin/rmdir/rmdir.c
+++ b/bin/rmdir/rmdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rmdir.c,v 1.13 2016/10/19 18:20:26 schwarze Exp $ */
+/* $OpenBSD: rmdir.c,v 1.14 2019/06/28 13:34:59 deraadt Exp $ */
/* $NetBSD: rmdir.c,v 1.13 1995/03/21 09:08:31 cgd Exp $ */
/*-
@@ -75,7 +75,7 @@ main(int argc, char *argv[])
continue;
*++p = '\0';
- if (rmdir(*argv) < 0) {
+ if (rmdir(*argv) == -1) {
warn("%s", *argv);
errors = 1;
} else if (pflag)
@@ -96,7 +96,7 @@ rm_path(char *path)
continue;
*++p = '\0';
- if (rmdir(path) < 0) {
+ if (rmdir(path) == -1) {
warn("%s", path);
return (1);
}
diff --git a/bin/stty/key.c b/bin/stty/key.c
index 92af19f9006..245e5db0861 100644
--- a/bin/stty/key.c
+++ b/bin/stty/key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.c,v 1.17 2016/03/23 14:52:42 mmcc Exp $ */
+/* $OpenBSD: key.c,v 1.18 2019/06/28 13:35:00 deraadt Exp $ */
/* $NetBSD: key.c,v 1.11 1995/09/07 06:57:11 jtc Exp $ */
/*-
@@ -323,20 +323,20 @@ f_tty(struct info *ip)
int tmp;
tmp = TTYDISC;
- if (ioctl(ip->fd, TIOCSETD, &tmp) < 0)
+ if (ioctl(ip->fd, TIOCSETD, &tmp) == -1)
err(1, "TIOCSETD");
}
void
f_ostart(struct info *ip)
{
- if (ioctl(ip->fd, TIOCSTART) < 0)
+ if (ioctl(ip->fd, TIOCSTART) == -1)
err(1, "TIOCSTART");
}
void
f_ostop(struct info *ip)
{
- if (ioctl(ip->fd, TIOCSTOP) < 0)
+ if (ioctl(ip->fd, TIOCSTOP) == -1)
err(1, "TIOCSTOP");
}
diff --git a/bin/stty/stty.c b/bin/stty/stty.c
index 4d70ae6687a..904d86996cf 100644
--- a/bin/stty/stty.c
+++ b/bin/stty/stty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stty.c,v 1.20 2016/07/23 08:57:18 bluhm Exp $ */
+/* $OpenBSD: stty.c,v 1.21 2019/06/28 13:35:00 deraadt Exp $ */
/* $NetBSD: stty.c,v 1.11 1995/03/21 09:11:30 cgd Exp $ */
/*-
@@ -69,7 +69,7 @@ main(int argc, char *argv[])
fmt = BSD;
break;
case 'f':
- if ((i.fd = open(optarg, O_RDONLY | O_NONBLOCK)) < 0)
+ if ((i.fd = open(optarg, O_RDONLY | O_NONBLOCK)) == -1)
err(1, "%s", optarg);
break;
case 'g':
@@ -82,12 +82,12 @@ main(int argc, char *argv[])
args: argc -= optind;
argv += optind;
- if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0 )
+ if (ioctl(i.fd, TIOCGETD, &i.ldisc) == -1)
err(1, "TIOCGETD");
- if (tcgetattr(i.fd, &i.t) < 0)
+ if (tcgetattr(i.fd, &i.t) == -1)
errx(1, "not a terminal");
- if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
+ if (ioctl(i.fd, TIOCGWINSZ, &i.win) == -1)
warn("TIOCGWINSZ");
switch(fmt) {
@@ -149,9 +149,9 @@ args: argc -= optind;
usage();
}
- if (i.set && tcsetattr(i.fd, 0, &i.t) < 0)
+ if (i.set && tcsetattr(i.fd, 0, &i.t) == -1)
err(1, "tcsetattr");
- if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) < 0)
+ if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) == -1)
warn("TIOCSWINSZ");
return (0);
}