1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

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.
This commit is contained in:
deraadt 2019-06-28 13:34:58 +00:00
parent d6719668f9
commit 3aaa63eb46
218 changed files with 1116 additions and 1122 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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",

View File

@ -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;
}

View File

@ -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 ||

View File

@ -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;

View File

@ -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;

View File

@ -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" : "");

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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);
/*

View File

@ -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);
}

View File

@ -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;

View File

@ -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)

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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/).

View File

@ -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));

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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))) {

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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 */
}

View File

@ -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;

View File

@ -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",

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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");
}

View File

@ -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);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: at.c,v 1.81 2017/06/15 19:37:10 tb Exp $ */
/* $OpenBSD: at.c,v 1.82 2019/06/28 13:35:00 deraadt Exp $ */
/*
* at.c : Put file into atrun queue
@ -353,7 +353,7 @@ writefile(const char *cwd, time_t runtimer, char queue)
/*
* Set the x bit so that we're ready to start executing
*/
if (fchmod(fileno(fp), S_IRUSR | S_IWUSR | S_IXUSR) < 0)
if (fchmod(fileno(fp), S_IRUSR | S_IWUSR | S_IXUSR) == -1)
fatal("fchmod");
(void)fclose(fp);

View File

@ -219,7 +219,7 @@ be32_set(be32_t *p, unsigned int v)
static int
afile_readhdr(struct afile *f, void *addr, size_t size)
{
if (lseek(f->fd, 0, SEEK_SET) < 0) {
if (lseek(f->fd, 0, SEEK_SET) == -1) {
log_puts(f->path);
log_puts(": failed to seek to beginning of file\n");
return 0;
@ -235,7 +235,7 @@ afile_readhdr(struct afile *f, void *addr, size_t size)
static int
afile_writehdr(struct afile *f, void *addr, size_t size)
{
if (lseek(f->fd, 0, SEEK_SET) < 0) {
if (lseek(f->fd, 0, SEEK_SET) == -1) {
log_puts(f->path);
log_puts(": failed to seek back to header\n");
return 0;
@ -404,7 +404,7 @@ afile_wav_readhdr(struct afile *f)
* next chunk
*/
pos += sizeof(struct wav_chunk) + csize;
if (lseek(f->fd, sizeof(riff) + pos, SEEK_SET) < 0) {
if (lseek(f->fd, sizeof(riff) + pos, SEEK_SET) == -1) {
log_puts(f->path);
log_puts(": filed to seek to chunk\n");
return 0;
@ -593,7 +593,7 @@ afile_aiff_readhdr(struct afile *f)
csize = (csize + 1) & ~1;
pos += sizeof(struct aiff_chunk) + csize;
if (lseek(f->fd, sizeof(form) + pos, SEEK_SET) < 0) {
if (lseek(f->fd, sizeof(form) + pos, SEEK_SET) == -1) {
log_puts(f->path);
log_puts(": filed to seek to chunk\n");
return 0;
@ -708,7 +708,7 @@ afile_au_readhdr(struct afile *f)
f->par.msb = 0;
f->rate = be32_get(&hdr.rate);
f->nch = be32_get(&hdr.nch);
if (lseek(f->fd, f->startpos, SEEK_SET) < 0) {
if (lseek(f->fd, f->startpos, SEEK_SET) == -1) {
log_puts(f->path);
log_puts(": ");
log_puts("failed to seek to data chunk\n");
@ -778,7 +778,7 @@ afile_read(struct afile *f, void *data, size_t count)
count = maxread;
}
n = read(f->fd, data, count);
if (n < 0) {
if (n == -1) {
log_puts(f->path);
log_puts(": couldn't read\n");
return 0;
@ -808,7 +808,7 @@ afile_write(struct afile *f, void *data, size_t count)
count = maxwrite;
}
n = write(f->fd, data, count);
if (n < 0) {
if (n == -1) {
log_puts(f->path);
log_puts(": couldn't write\n");
return 0;
@ -833,7 +833,7 @@ afile_seek(struct afile *f, off_t pos)
* seek only if needed to avoid errors with pipes & sockets
*/
if (pos != f->curpos) {
if (lseek(f->fd, pos, SEEK_SET) < 0) {
if (lseek(f->fd, pos, SEEK_SET) == -1) {
log_puts(f->path);
log_puts(": couldn't seek\n");
return 0;
@ -896,7 +896,7 @@ afile_open(struct afile *f, char *path, int hdr, int flags,
} else {
f->path = path;
f->fd = open(f->path, O_RDONLY, 0);
if (f->fd < 0) {
if (f->fd == -1) {
log_puts(f->path);
log_puts(": failed to open for reading\n");
return 0;
@ -925,7 +925,7 @@ afile_open(struct afile *f, char *path, int hdr, int flags,
f->path = path;
f->fd = open(f->path,
O_WRONLY | O_TRUNC | O_CREAT, 0666);
if (f->fd < 0) {
if (f->fd == -1) {
log_puts(f->path);
log_puts(": failed to create file\n");
return 0;

View File

@ -1214,7 +1214,7 @@ playrec(char *dev, int mode, int bufsz, char *port)
nm = mio_pollfd(dev_mh, pfds + ns, POLLIN);
else
nm = 0;
if (poll(pfds, ns + nm, -1) < 0) {
if (poll(pfds, ns + nm, -1) == -1) {
if (errno == EINTR)
continue;
log_puts("poll failed\n");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: audioctl.c,v 1.36 2018/09/17 14:14:39 mestre Exp $ */
/* $OpenBSD: audioctl.c,v 1.37 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2016 Alexandre Ratchov <alex@caoua.org>
*
@ -223,15 +223,15 @@ main(int argc, char **argv)
err(1, "unveil");
fd = open(path, O_RDWR);
if (fd < 0)
if (fd == -1)
err(1, "%s", path);
if (ioctl(fd, AUDIO_GETSTATUS, &rstatus) < 0)
if (ioctl(fd, AUDIO_GETSTATUS, &rstatus) == -1)
err(1, "AUDIO_GETSTATUS");
if (ioctl(fd, AUDIO_GETDEV, &rname) < 0)
if (ioctl(fd, AUDIO_GETDEV, &rname) == -1)
err(1, "AUDIO_GETDEV");
if (ioctl(fd, AUDIO_GETPAR, &rpar) < 0)
if (ioctl(fd, AUDIO_GETPAR, &rpar) == -1)
err(1, "AUDIO_GETPAR");
if (ioctl(fd, AUDIO_GETPOS, &rpos) < 0)
if (ioctl(fd, AUDIO_GETPOS, &rpos) == -1)
err(1, "AUDIO_GETPOS");
if (argc == 0) {
for (f = fields; f->name != NULL; f++) {
@ -269,9 +269,9 @@ main(int argc, char **argv)
close(fd);
return 0;
}
if (ioctl(fd, AUDIO_SETPAR, &wpar) < 0)
if (ioctl(fd, AUDIO_SETPAR, &wpar) == -1)
err(1, "AUDIO_SETPAR");
if (ioctl(fd, AUDIO_GETPAR, &wpar) < 0)
if (ioctl(fd, AUDIO_GETPAR, &wpar) == -1)
err(1, "AUDIO_GETPAR");
for (f = fields; f->name != NULL; f++) {
if (!f->set || quiet)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: biff.c,v 1.16 2018/08/11 10:59:34 mestre Exp $ */
/* $OpenBSD: biff.c,v 1.17 2019/06/28 13:35:00 deraadt Exp $ */
/* $NetBSD: biff.c,v 1.3 1995/03/26 02:34:22 glass Exp $ */
/*
@ -78,11 +78,11 @@ main(int argc, char *argv[])
switch(argv[0][0]) {
case 'n':
if (chmod(name, sb.st_mode & ~S_IXUSR) < 0)
if (chmod(name, sb.st_mode & ~S_IXUSR) == -1)
err(2, "%s", name);
break;
case 'y':
if (chmod(name, sb.st_mode | S_IXUSR) < 0)
if (chmod(name, sb.st_mode | S_IXUSR) == -1)
err(2, "%s", name);
break;
default:

View File

@ -1,4 +1,4 @@
/* $OpenBSD: io.c,v 1.48 2019/01/29 22:28:30 tedu Exp $ */
/* $OpenBSD: io.c,v 1.49 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@ -331,7 +331,7 @@ opencal(void)
}
}
if (pipe(pdes) < 0) {
if (pipe(pdes) == -1) {
close(fdin);
return (NULL);
}
@ -393,7 +393,7 @@ closecal(FILE *fp)
(void)rewind(fp);
if (fstat(fileno(fp), &sbuf) || !sbuf.st_size)
goto done;
if (pipe(pdes) < 0)
if (pipe(pdes) == -1)
goto done;
switch ((pid = vfork())) {
case -1: /* error */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cdio.c,v 1.76 2019/04/01 03:57:07 naddy Exp $ */
/* $OpenBSD: cdio.c,v 1.77 2019/06/28 13:35:00 deraadt Exp $ */
/* Copyright (c) 1995 Serge V. Vakulenko
* All rights reserved.
@ -378,7 +378,7 @@ run(int cmd, char *arg)
return (0);
rc = ioctl(fd, CDIOCRESET);
if (rc < 0)
if (rc == -1)
return rc;
close(fd);
fd = -1;
@ -424,7 +424,7 @@ run(int cmd, char *arg)
(void) ioctl(fd, CDIOCALLOW);
rc = ioctl(fd, CDIOCEJECT);
if (rc < 0)
if (rc == -1)
return (rc);
#if defined(__OpenBSD__)
close(fd);
@ -442,7 +442,7 @@ run(int cmd, char *arg)
(void) ioctl(fd, CDIOCALLOW);
rc = ioctl(fd, CDIOCCLOSE);
if (rc < 0)
if (rc == -1)
return (rc);
close(fd);
fd = -1;
@ -694,7 +694,7 @@ play(char *arg)
rc = ioctl(fd, CDIOREADTOCHEADER, &h);
if (rc < 0)
if (rc == -1)
return (rc);
if (h.starting_track > h.ending_track) {
@ -1037,7 +1037,7 @@ play_prev(char *arg)
trk--;
rc = ioctl(fd, CDIOREADTOCHEADER, &h);
if (rc < 0) {
if (rc == -1) {
warn("getting toc header");
return (rc);
}
@ -1060,7 +1060,7 @@ play_same(char *arg)
if (status (&trk, &min, &sec, &frm) >= 0) {
rc = ioctl(fd, CDIOREADTOCHEADER, &h);
if (rc < 0) {
if (rc == -1) {
warn("getting toc header");
return (rc);
}
@ -1081,7 +1081,7 @@ play_next(char *arg)
if (status(&trk, &min, &sec, &frm) >= 0) {
trk++;
rc = ioctl(fd, CDIOREADTOCHEADER, &h);
if (rc < 0) {
if (rc == -1) {
warn("getting toc header");
return (rc);
}
@ -1474,7 +1474,7 @@ status(int *trk, int *min, int *sec, int *frame)
s.address_format = msf ? CD_MSF_FORMAT : CD_LBA_FORMAT;
s.data_format = CD_CURRENT_POSITION;
if (ioctl(fd, CDIOCREADSUBCHANNEL, (char *) &s) < 0)
if (ioctl(fd, CDIOCREADSUBCHANNEL, (char *) &s) == -1)
return -1;
*trk = s.data->what.position.track_number;
@ -1598,7 +1598,7 @@ open_cd(char *dev, int needwrite)
fd = opendev(dev, O_RDWR, OPENDEV_PART, &realdev);
else
fd = opendev(dev, O_RDONLY, OPENDEV_PART, &realdev);
if (fd < 0) {
if (fd == -1) {
if (errno == ENXIO) {
/* ENXIO has an overloaded meaning here.
* The original "Device not configured" should
@ -1614,7 +1614,7 @@ open_cd(char *dev, int needwrite)
}
sleep(1);
}
if (fd < 0) {
if (fd == -1) {
warn("Can't open %s", realdev);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rip.c,v 1.17 2017/12/23 20:04:23 cheloha Exp $ */
/* $OpenBSD: rip.c,v 1.18 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2007 Alexey Vatchenko <av@bsdua.org>
@ -306,7 +306,7 @@ write_sector(int fd, u_char *sec, u_int32_t secsize)
while (secsize > 0) {
res = write(fd, sec, secsize);
if (res < 0)
if (res == -1)
return (-1);
sec += res;
@ -595,7 +595,7 @@ rip_tracks(char *arg, int (*next_track)(struct track *), int issorted)
int rc;
rc = ioctl(fd, CDIOREADTOCHEADER, &h);
if (rc < 0)
if (rc == -1)
return (rc);
if (h.starting_track > h.ending_track) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.95 2019/05/27 15:11:01 millert Exp $ */
/* $OpenBSD: main.c,v 1.96 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
@ -499,7 +499,7 @@ docompress(const char *in, char *out, const struct compressor *method,
ifd = dup(STDIN_FILENO);
else
ifd = open(in, O_RDONLY);
if (ifd < 0) {
if (ifd == -1) {
if (verbose >= 0)
warn("%s", in);
return (FAILURE);
@ -517,7 +517,7 @@ docompress(const char *in, char *out, const struct compressor *method,
}
ofd = open(out, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR);
}
if (ofd < 0) {
if (ofd == -1) {
if (verbose >= 0)
warn("%s", out);
(void) close(ifd);
@ -636,7 +636,7 @@ dodecompress(const char *in, char *out, struct stat *sb)
ifd = dup(STDIN_FILENO);
else
ifd = open(in, O_RDONLY);
if (ifd < 0) {
if (ifd == -1) {
if (verbose >= 0)
warn("%s", in);
return -1;
@ -691,7 +691,7 @@ dodecompress(const char *in, char *out, struct stat *sb)
}
ofd = open(out, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR);
}
if (ofd < 0) {
if (ofd == -1) {
if (verbose >= 0)
warn("%s", in);
method->close(cookie, NULL, NULL, NULL);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: command.c,v 1.17 2019/03/22 07:03:23 nicm Exp $ */
/* $OpenBSD: command.c,v 1.18 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org>
@ -60,7 +60,7 @@ pipe_command(void)
cu_err(1, "fork");
case 0:
fd = open(_PATH_DEVNULL, O_RDWR);
if (fd < 0 || dup2(fd, STDIN_FILENO) == -1)
if (fd == -1 || dup2(fd, STDIN_FILENO) == -1)
_exit(1);
close(fd);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cu.c,v 1.27 2019/03/22 07:03:23 nicm Exp $ */
/* $OpenBSD: cu.c,v 1.28 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org>
@ -176,7 +176,7 @@ main(int argc, char **argv)
if (is_direct)
flags |= O_NONBLOCK;
line_fd = open(line_path, flags);
if (line_fd < 0)
if (line_fd == -1)
err(1, "open(\"%s\")", line_path);
if (restricted && pledge("stdio tty", NULL) == -1)
err(1, "pledge");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: add.c,v 1.114 2017/06/01 08:08:24 joris Exp $ */
/* $OpenBSD: add.c,v 1.115 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@ -257,7 +257,7 @@ cvs_add_tobranch(struct cvs_file *cf, char *tag)
cf->file_rpath = xstrdup(attic);
cf->repo_fd = open(cf->file_rpath, O_CREAT|O_RDONLY);
if (cf->repo_fd < 0)
if (cf->repo_fd == -1)
fatal("cvs_add_tobranch: %s: %s", cf->file_rpath,
strerror(errno));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: buf.c,v 1.84 2016/10/15 22:20:17 millert Exp $ */
/* $OpenBSD: buf.c,v 1.85 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@ -225,7 +225,7 @@ open:
fatal("buf_write: buf_write_fd: `%s'", path);
}
if (fchmod(fd, mode) < 0)
if (fchmod(fd, mode) == -1)
cvs_log(LP_ERR, "permissions not set on file %s", path);
(void)close(fd);
@ -259,7 +259,7 @@ buf_write_stmp(BUF *b, char *template, struct timeval *tv)
worklist_add(template, &temp_files);
if (lseek(fd, 0, SEEK_SET) < 0)
if (lseek(fd, 0, SEEK_SET) == -1)
fatal("buf_write_stmp: lseek: %s", strerror(errno));
return (fd);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: commit.c,v 1.159 2018/12/30 23:09:58 guenther Exp $ */
/* $OpenBSD: commit.c,v 1.160 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@ -537,7 +537,7 @@ cvs_commit_local(struct cvs_file *cf)
}
cf->repo_fd = open(cf->file_rpath, openflags);
if (cf->repo_fd < 0)
if (cf->repo_fd == -1)
fatal("cvs_commit_local: %s", strerror(errno));
cf->file_rcs = rcs_open(cf->file_rpath, cf->repo_fd,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: diff3.c,v 1.62 2016/10/18 21:06:52 millert Exp $ */
/* $OpenBSD: diff3.c,v 1.63 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@ -207,11 +207,11 @@ cvs_merge_file(struct cvs_file *cf, int verbose)
argv[argc++] = path2;
argv[argc++] = path3;
if (lseek(fds[2], 0, SEEK_SET) < 0)
if (lseek(fds[2], 0, SEEK_SET) == -1)
fatal("cvs_merge_file: lseek fds[2]: %s", strerror(errno));
if (lseek(fds[3], 0, SEEK_SET) < 0)
if (lseek(fds[3], 0, SEEK_SET) == -1)
fatal("cvs_merge_file: lseek fds[3]: %s", strerror(errno));
if (lseek(fds[4], 0, SEEK_SET) < 0)
if (lseek(fds[4], 0, SEEK_SET) == -1)
fatal("cvs_merge_file: lseek fds[4]: %s", strerror(errno));
diff3_conflicts = diff3_internal(argc, argv, cf->file_path, r2);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: diff_internals.c,v 1.39 2016/10/15 22:20:17 millert Exp $ */
/* $OpenBSD: diff_internals.c,v 1.40 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@ -329,7 +329,7 @@ diffreg(const char *file1, const char *file2, int _fd1, int _fd2,
if (fd2 == -1)
fatal("diffreg: dup: %s", strerror(errno));
if (lseek(fd1, 0, SEEK_SET) < 0)
if (lseek(fd1, 0, SEEK_SET) == -1)
fatal("diffreg: lseek: %s", strerror(errno));
f1 = fdopen(fd1, "r");
@ -338,7 +338,7 @@ diffreg(const char *file1, const char *file2, int _fd1, int _fd2,
goto closem;
}
if (lseek(fd2, 0, SEEK_SET) < 0)
if (lseek(fd2, 0, SEEK_SET) == -1)
fatal("diffreg: lseek: %s", strerror(errno));
f2 = fdopen(fd2, "r");
@ -347,12 +347,12 @@ diffreg(const char *file1, const char *file2, int _fd1, int _fd2,
goto closem;
}
if (fstat(fd1, &stb1) < 0) {
if (fstat(fd1, &stb1) == -1) {
cvs_log(LP_ERR, "%s", file1);
goto closem;
}
if (fstat(fd2, &stb2) < 0) {
if (fstat(fd2, &stb2) == -1) {
cvs_log(LP_ERR, "%s", file2);
goto closem;
}
@ -867,7 +867,7 @@ preadline(int fd, size_t rlen, off_t off)
ssize_t nr;
line = xmalloc(rlen + 1);
if ((nr = pread(fd, line, rlen, off)) < 0)
if ((nr = pread(fd, line, rlen, off)) == -1)
fatal("preadline: %s", strerror(errno));
line[nr] = '\0';
return (line);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: import.c,v 1.108 2017/06/01 08:08:24 joris Exp $ */
/* $OpenBSD: import.c,v 1.109 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@ -338,7 +338,7 @@ import_new(struct cvs_file *cf)
fatal("import_new: failed to get first branch revision");
cf->repo_fd = open(cf->file_rpath, O_CREAT | O_RDONLY);
if (cf->repo_fd < 0)
if (cf->repo_fd == -1)
fatal("import_new: %s: %s", cf->file_rpath, strerror(errno));
cf->file_rcs = rcs_open(cf->file_rpath, cf->repo_fd, RCS_CREATE,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rcs.c,v 1.318 2017/08/28 18:52:25 millert Exp $ */
/* $OpenBSD: rcs.c,v 1.319 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@ -2169,7 +2169,7 @@ rcs_rev_write_stmp(RCSFILE *rfp, RCSNUM *rev, char *template, int mode)
worklist_add(template, &temp_files);
rcs_rev_write_fd(rfp, rev, fd, mode);
if (lseek(fd, 0, SEEK_SET) < 0)
if (lseek(fd, 0, SEEK_SET) == -1)
fatal("rcs_rev_write_stmp: lseek: %s", strerror(errno));
return (fd);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: remote.c,v 1.32 2017/08/28 19:33:20 otto Exp $ */
/* $OpenBSD: remote.c,v 1.33 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@ -176,7 +176,7 @@ cvs_remote_send_file(const char *path, int _fd)
if (fd == -1)
fatal("cvs_remote_send_file: dup: %s", strerror(errno));
if (lseek(fd, 0, SEEK_SET) < 0)
if (lseek(fd, 0, SEEK_SET) == -1)
fatal("cvs_remote_send_file: %s: lseek: %s", path,
strerror(errno));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: repository.c,v 1.25 2017/05/31 16:18:20 joris Exp $ */
/* $OpenBSD: repository.c,v 1.26 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@ -82,7 +82,7 @@ cvs_repository_lock(const char *repo, int wantlock)
if (wantlock == 0)
return;
if ((i = open(fpath, O_WRONLY|O_CREAT|O_TRUNC, 0755)) < 0) {
if ((i = open(fpath, O_WRONLY|O_CREAT|O_TRUNC, 0755)) == -1) {
if (errno == EEXIST)
fatal("cvs_repository_lock: somebody beat us");
else

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.161 2017/08/28 19:33:20 otto Exp $ */
/* $OpenBSD: util.c,v 1.162 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
@ -888,7 +888,7 @@ cvs_exec(char *prog, char *in, int needwait)
int fds[2], st;
char *argp[4] = { "sh", "-c", prog, NULL };
if (in != NULL && pipe(fds) < 0) {
if (in != NULL && pipe(fds) == -1) {
cvs_log(LP_ERR, "cvs_exec: pipe failed");
return (-1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: diff.c,v 1.66 2019/01/25 00:19:26 millert Exp $ */
/* $OpenBSD: diff.c,v 1.67 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <millert@openbsd.org>
@ -253,12 +253,12 @@ main(int argc, char **argv)
} else {
if (S_ISDIR(stb1.st_mode)) {
argv[0] = splice(argv[0], argv[1]);
if (stat(argv[0], &stb1) < 0)
if (stat(argv[0], &stb1) == -1)
err(2, "%s", argv[0]);
}
if (S_ISDIR(stb2.st_mode)) {
argv[1] = splice(argv[1], argv[0]);
if (stat(argv[1], &stb2) < 0)
if (stat(argv[1], &stb2) == -1)
err(2, "%s", argv[1]);
}
print_status(diffreg(argv[0], argv[1], dflags), argv[0], argv[1],

View File

@ -1,4 +1,4 @@
/* $OpenBSD: diffreg.c,v 1.92 2019/06/28 05:35:34 deraadt Exp $ */
/* $OpenBSD: diffreg.c,v 1.93 2019/06/28 13:35:00 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@ -315,7 +315,7 @@ diffreg(char *file1, char *file2, int flags)
else {
if (!S_ISREG(stb1.st_mode)) {
if ((f1 = opentemp(file1)) == NULL ||
fstat(fileno(f1), &stb1) < 0) {
fstat(fileno(f1), &stb1) == -1) {
warn("%s", file1);
status |= 2;
goto closem;
@ -336,7 +336,7 @@ diffreg(char *file1, char *file2, int flags)
else {
if (!S_ISREG(stb2.st_mode)) {
if ((f2 = opentemp(file2)) == NULL ||
fstat(fileno(f2), &stb2) < 0) {
fstat(fileno(f2), &stb2) == -1) {
warn("%s", file2);
status |= 2;
goto closem;
@ -452,7 +452,7 @@ opentemp(const char *file)
if (strcmp(file, "-") == 0)
ifd = STDIN_FILENO;
else if ((ifd = open(file, O_RDONLY, 0644)) < 0)
else if ((ifd = open(file, O_RDONLY, 0644)) == -1)
return (NULL);
(void)strlcpy(tempfile, _PATH_TMP "/diff.XXXXXXXX", sizeof(tempfile));
@ -930,7 +930,7 @@ preadline(int fd, size_t rlen, off_t off)
ssize_t nr;
line = xmalloc(rlen + 1);
if ((nr = pread(fd, line, rlen, off)) < 0)
if ((nr = pread(fd, line, rlen, off)) == -1)
err(2, "preadline");
if (nr > 0 && line[nr-1] == '\n')
nr--;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: function.c,v 1.46 2018/09/16 02:44:06 millert Exp $ */
/* $OpenBSD: function.c,v 1.47 2019/06/28 13:35:01 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -331,10 +331,10 @@ f_delete(PLAN *plan, FTSENT *entry)
#endif
/* rmdir directories, unlink everything else */
if (S_ISDIR(entry->fts_statp->st_mode)) {
if (rmdir(entry->fts_accpath) < 0 && errno != ENOTEMPTY)
if (rmdir(entry->fts_accpath) == -1 && errno != ENOTEMPTY)
warn("-delete: rmdir(%s)", entry->fts_path);
} else {
if (unlink(entry->fts_accpath) < 0)
if (unlink(entry->fts_accpath) == -1)
warn("-delete: unlink(%s)", entry->fts_path);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: net.c,v 1.13 2015/01/16 06:40:07 deraadt Exp $ */
/* $OpenBSD: net.c,v 1.14 2019/06/28 13:35:01 deraadt Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@ -72,10 +72,10 @@ netfinger(name)
s = -1;
for (res = res0; res; res = res->ai_next) {
if ((s = socket(res->ai_family, res->ai_socktype,
res->ai_protocol)) < 0) {
res->ai_protocol)) == -1) {
continue;
}
if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
if (connect(s, res->ai_addr, res->ai_addrlen) == -1) {
(void)close(s);
s = -1;
continue;
@ -84,7 +84,7 @@ netfinger(name)
break;
}
if (s < 0) {
if (s == -1) {
perror("finger");
freeaddrinfo(res0);
return;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.34 2018/06/17 15:00:29 deraadt Exp $ */
/* $OpenBSD: util.c,v 1.35 2019/06/28 13:35:01 deraadt Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@ -60,7 +60,7 @@ find_idle_and_ttywrite(WHERE *w)
struct stat sb;
(void)snprintf(tbuf, sizeof(tbuf), "%s%s", _PATH_DEV, w->tty);
if (stat(tbuf, &sb) < 0) {
if (stat(tbuf, &sb) == -1) {
/* Don't bitch about it, just handle it... */
w->idletime = 0;
w->writable = 0;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cmds.c,v 1.82 2019/05/16 12:44:17 florian Exp $ */
/* $OpenBSD: cmds.c,v 1.83 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */
/*
@ -803,7 +803,7 @@ lcd(int argc, char *argv[])
code = -1;
return;
}
if (chdir(argv[1]) < 0) {
if (chdir(argv[1]) == -1) {
warn("local: %s", argv[1]);
code = -1;
} else {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fetch.c,v 1.169 2019/05/16 12:44:17 florian Exp $ */
/* $OpenBSD: fetch.c,v 1.170 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@ -558,7 +558,7 @@ noslash:
cause = "bind";
continue;
}
if (bind(fd, ares->ai_addr, ares->ai_addrlen) < 0) {
if (bind(fd, ares->ai_addr, ares->ai_addrlen) == -1) {
save_errno = errno;
close(fd);
errno = save_errno;
@ -939,7 +939,7 @@ noslash:
#endif /* !SMALL */
out = open(savefile, O_CREAT | O_WRONLY | O_TRUNC,
0666);
if (out < 0) {
if (out == -1) {
warn("Can't open %s", savefile);
goto cleanup_url_get;
}
@ -1530,7 +1530,7 @@ ftp_read(FILE *fp, struct tls *tls, char *buf, size_t len)
do {
tret = tls_read(tls, buf, len);
} while (tret == TLS_WANT_POLLIN || tret == TLS_WANT_POLLOUT);
if (tret < 0)
if (tret == -1)
errx(1, "SSL read error: %s", tls_error(tls));
ret = (size_t)tret;
}
@ -1582,7 +1582,7 @@ SSL_vprintf(struct tls *tls, const char *fmt, va_list ap)
ret = tls_write(tls, buf, len);
if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT)
continue;
if (ret < 0)
if (ret == -1)
errx(1, "SSL write error: %s", tls_error(tls));
buf += ret;
len -= ret;
@ -1611,7 +1611,7 @@ SSL_readline(struct tls *tls, size_t *lenp)
do {
ret = tls_read(tls, &c, 1);
} while (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT);
if (ret < 0)
if (ret == -1)
errx(1, "SSL read error: %s", tls_error(tls));
buf[i] = c;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ftp.c,v 1.104 2019/05/16 12:44:17 florian Exp $ */
/* $OpenBSD: ftp.c,v 1.105 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */
/*
@ -189,7 +189,7 @@ hookup(char *host, char *port)
fprintf(ttyout, "Trying %s...\n", hbuf);
}
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (s < 0) {
if (s == -1) {
cause = "socket";
continue;
}
@ -202,7 +202,7 @@ hookup(char *host, char *port)
cause = "bind";
continue;
}
if (bind(s, ares->ai_addr, ares->ai_addrlen) < 0) {
if (bind(s, ares->ai_addr, ares->ai_addrlen) == -1) {
cause = "bind";
error = errno;
close(s);
@ -236,7 +236,7 @@ hookup(char *host, char *port)
/* finally we got one */
break;
}
if (s < 0) {
if (s == -1) {
warn("%s", cause);
code = -1;
freeaddrinfo(res0);
@ -252,14 +252,14 @@ hookup(char *host, char *port)
ares = NULL;
}
#endif /* !SMALL */
if (getsockname(s, &myctladdr.sa, &namelen) < 0) {
if (getsockname(s, &myctladdr.sa, &namelen) == -1) {
warn("getsockname");
code = -1;
goto bad;
}
if (hisctladdr.sa.sa_family == AF_INET) {
tos = IPTOS_LOWDELAY;
if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0)
if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) == -1)
warn("setsockopt TOS (ignored)");
}
cin = fdopen(s, "r");
@ -288,7 +288,7 @@ hookup(char *host, char *port)
ret = setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on));
#ifndef SMALL
if (ret < 0 && debug)
if (ret == -1 && debug)
warn("setsockopt");
#endif /* !SMALL */
}
@ -659,7 +659,7 @@ sendrequest(const char *cmd, const char *local, const char *remote,
return;
}
closefunc = fclose;
if (fstat(fileno(fin), &st) < 0 ||
if (fstat(fileno(fin), &st) == -1 ||
(st.st_mode & S_IFMT) != S_IFREG) {
fprintf(ttyout, "%s: not a plain file.\n", local);
(void)signal(SIGINT, oldintr);
@ -929,7 +929,7 @@ recvrequest(const char *cmd, const char * volatile local, const char *remote,
oldintr = signal(SIGINT, abortrecv);
oldinti = signal(SIGINFO, psummary);
if (ignorespecial || (strcmp(local, "-") && *local != '|')) {
if (access(local, W_OK) < 0) {
if (access(local, W_OK) == -1) {
char *dir;
if (errno != ENOENT && errno != EACCES) {
@ -945,7 +945,7 @@ recvrequest(const char *cmd, const char * volatile local, const char *remote,
d = access(dir == local ? "/" : dir ? local : ".", W_OK);
if (dir != NULL)
*dir = '/';
if (d < 0) {
if (d == -1) {
warn("local: %s", local);
(void)signal(SIGINT, oldintr);
(void)signal(SIGINFO, oldinti);
@ -953,7 +953,7 @@ recvrequest(const char *cmd, const char * volatile local, const char *remote,
return;
}
if (!runique && errno == EACCES &&
chmod(local, (S_IRUSR|S_IWUSR)) < 0) {
chmod(local, (S_IRUSR|S_IWUSR)) == -1) {
warn("local: %s", local);
(void)signal(SIGINT, oldintr);
(void)signal(SIGINFO, oldinti);
@ -1032,7 +1032,7 @@ recvrequest(const char *cmd, const char * volatile local, const char *remote,
}
closefunc = fclose;
}
if (fstat(fileno(fout), &st) < 0 || st.st_blksize == 0)
if (fstat(fileno(fout), &st) == -1 || st.st_blksize == 0)
st.st_blksize = BUFSIZ;
if (st.st_blksize > bufsize) {
(void)free(buf);
@ -1056,7 +1056,7 @@ recvrequest(const char *cmd, const char * volatile local, const char *remote,
case TYPE_I:
if (restart_point &&
lseek(fileno(fout), restart_point, SEEK_SET) < 0) {
lseek(fileno(fout), restart_point, SEEK_SET) == -1) {
warn("local: %s", local);
progress = oprogress;
preserve = opreserve;
@ -1116,7 +1116,7 @@ recvrequest(const char *cmd, const char * volatile local, const char *remote,
if (restart_point) {
int i, n, ch;
if (fseek(fout, 0L, SEEK_SET) < 0)
if (fseek(fout, 0L, SEEK_SET) == -1)
goto done;
n = restart_point;
for (i = 0; i++ < n;) {
@ -1128,7 +1128,7 @@ recvrequest(const char *cmd, const char * volatile local, const char *remote,
if (ch == '\n')
i++;
}
if (fseek(fout, 0L, SEEK_CUR) < 0) {
if (fseek(fout, 0L, SEEK_CUR) == -1) {
done:
if (errno)
warn("local: %s", local);
@ -1300,13 +1300,13 @@ reinit:
if (passivemode) {
data_addr = myctladdr;
data = socket(data_addr.sa.sa_family, SOCK_STREAM, 0);
if (data < 0) {
if (data == -1) {
warn("socket");
return (1);
}
#ifndef SMALL
if (srcaddr) {
if (bind(data, ares->ai_addr, ares->ai_addrlen) < 0) {
if (bind(data, ares->ai_addr, ares->ai_addrlen) == -1) {
warn("bind");
close(data);
return (1);
@ -1314,7 +1314,7 @@ reinit:
}
if ((options & SO_DEBUG) &&
setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
sizeof(on)) < 0)
sizeof(on)) == -1)
warn("setsockopt (ignored)");
#endif /* !SMALL */
switch (data_addr.sa.sa_family) {
@ -1527,7 +1527,7 @@ reinit:
if (data_addr.sa.sa_family == AF_INET) {
on = IPTOS_THROUGHPUT;
if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on,
sizeof(int)) < 0)
sizeof(int)) == -1)
warn("setsockopt TOS (ignored)");
}
return (0);
@ -1540,7 +1540,7 @@ noport:
if (data != -1)
(void)close(data);
data = socket(data_addr.sa.sa_family, SOCK_STREAM, 0);
if (data < 0) {
if (data == -1) {
warn("socket");
if (tmpno)
sendport = 1;
@ -1548,7 +1548,7 @@ noport:
}
if (!sendport)
if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on,
sizeof(on)) < 0) {
sizeof(on)) == -1) {
warn("setsockopt (reuse address)");
goto bad;
}
@ -1556,32 +1556,32 @@ noport:
case AF_INET:
on = IP_PORTRANGE_HIGH;
if (setsockopt(data, IPPROTO_IP, IP_PORTRANGE,
(char *)&on, sizeof(on)) < 0)
(char *)&on, sizeof(on)) == -1)
warn("setsockopt IP_PORTRANGE (ignored)");
break;
case AF_INET6:
on = IPV6_PORTRANGE_HIGH;
if (setsockopt(data, IPPROTO_IPV6, IPV6_PORTRANGE,
(char *)&on, sizeof(on)) < 0)
(char *)&on, sizeof(on)) == -1)
warn("setsockopt IPV6_PORTRANGE (ignored)");
break;
}
if (bind(data, &data_addr.sa, data_addr.sa.sa_len) < 0) {
if (bind(data, &data_addr.sa, data_addr.sa.sa_len) == -1) {
warn("bind");
goto bad;
}
#ifndef SMALL
if (options & SO_DEBUG &&
setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
sizeof(on)) < 0)
sizeof(on)) == -1)
warn("setsockopt (ignored)");
#endif /* !SMALL */
namelen = sizeof(data_addr);
if (getsockname(data, &data_addr.sa, &namelen) < 0) {
if (getsockname(data, &data_addr.sa, &namelen) == -1) {
warn("getsockname");
goto bad;
}
if (listen(data, 1) < 0)
if (listen(data, 1) == -1)
warn("listen");
#define UC(b) (((int)b)&0xff)
@ -1666,7 +1666,7 @@ noport:
if (data_addr.sa.sa_family == AF_INET) {
on = IPTOS_THROUGHPUT;
if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on,
sizeof(int)) < 0)
sizeof(int)) == -1)
warn("setsockopt TOS (ignored)");
}
return (0);
@ -1688,7 +1688,7 @@ dataconn(const char *lmode)
return (fdopen(data, lmode));
s = accept(data, &from.sa, &fromlen);
if (s < 0) {
if (s == -1) {
warn("accept");
(void)close(data), data = -1;
return (NULL);
@ -1698,7 +1698,7 @@ dataconn(const char *lmode)
if (from.sa.sa_family == AF_INET) {
int tos = IPTOS_THROUGHPUT;
if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos,
sizeof(int)) < 0) {
sizeof(int)) == -1) {
warn("setsockopt TOS (ignored)");
}
}
@ -1930,7 +1930,7 @@ abort:
pfd[0].fd = fileno(cin);
pfd[0].events = POLLIN;
if ((nfnd = poll(pfd, 1, 10 * 1000)) <= 0) {
if (nfnd < 0)
if (nfnd == -1)
warn("abort");
if (ptabflg)
code = -1;
@ -1958,7 +1958,7 @@ reset(int argc, char *argv[])
pfd[0].fd = fileno(cin);
pfd[0].events = POLLIN;
while (nfnd > 0) {
if ((nfnd = poll(pfd, 1, 0)) < 0) {
if ((nfnd = poll(pfd, 1, 0)) == -1) {
warn("reset");
code = -1;
lostpeer();
@ -1982,7 +1982,7 @@ gunique(const char *local)
d = access(cp == local ? "/" : cp ? local : ".", W_OK);
if (cp)
*cp = '/';
if (d < 0) {
if (d == -1) {
warn("local: %s", local);
return ((char *) 0);
}
@ -2000,7 +2000,7 @@ gunique(const char *local)
ext = '0';
else
ext++;
if ((d = access(new, F_OK)) < 0)
if ((d = access(new, F_OK)) == -1)
break;
if (ext != '0')
cp--;
@ -2069,7 +2069,7 @@ abort_remote(FILE *din)
nfds++;
}
if ((nfnd = poll(pfd, nfds, 10 * 1000)) <= 0) {
if (nfnd < 0)
if (nfnd == -1)
warn("abort");
if (ptabflg)
code = -1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ruserpass.c,v 1.32 2019/05/16 12:44:18 florian Exp $ */
/* $OpenBSD: ruserpass.c,v 1.33 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: ruserpass.c,v 1.14 1997/07/20 09:46:01 lukem Exp $ */
/*
@ -94,7 +94,7 @@ ruserpass(const char *host, char **aname, char **apass, char **aacct)
warn("%s", buf);
return (0);
}
if (gethostname(myname, sizeof(myname)) < 0)
if (gethostname(myname, sizeof(myname)) == -1)
myname[0] = '\0';
if ((mydomain = strchr(myname, '.')) == NULL)
mydomain = "";

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.90 2019/06/28 05:35:34 deraadt Exp $ */
/* $OpenBSD: util.c,v 1.91 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */
/*-
@ -1089,7 +1089,7 @@ connect_wait(int s)
if (poll(pfd, 1, -1) == -1)
return -1;
if (getsockopt(s, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
if (getsockopt(s, SOL_SOCKET, SO_ERROR, &error, &len) == -1)
return -1;
if (error != 0) {
errno = error;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: gencat.c,v 1.18 2015/10/10 21:29:59 deraadt Exp $ */
/* $OpenBSD: gencat.c,v 1.19 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: gencat.c,v 1.9 1998/10/09 17:00:56 itohy Exp $ */
/*-
@ -155,13 +155,13 @@ main(int argc, char *argv[])
catfile = *argv++;
for (; *argv; argv++) {
if ((ifd = open(*argv, O_RDONLY)) < 0)
if ((ifd = open(*argv, O_RDONLY)) == -1)
err(1, "Unable to read %s", *argv);
MCParse(ifd);
close(ifd);
}
if ((ofd = open(catfile, O_WRONLY | O_TRUNC | O_CREAT, 0666)) < 0)
if ((ofd = open(catfile, O_WRONLY | O_TRUNC | O_CREAT, 0666)) == -1)
err(1, "Unable to create a new %s", catfile);
MCWriteCat(ofd);
exit(0);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: indent.c,v 1.30 2015/11/11 01:12:09 deraadt Exp $ */
/* $OpenBSD: indent.c,v 1.31 2019/06/28 13:35:01 deraadt Exp $ */
/*
* Copyright (c) 1980, 1993
@ -1185,12 +1185,12 @@ bakcopy(void)
/* copy in_name to backup file */
bakchn = open(bakfile, O_CREAT | O_TRUNC | O_WRONLY, 0600);
if (bakchn < 0)
if (bakchn == -1)
err(1, "%s", bakfile);
while ((n = read(fileno(input), buff, sizeof buff)) > 0)
if (write(bakchn, buff, n) != n)
err(1, "%s", bakfile);
if (n < 0)
if (n == -1)
err(1, "%s", in_name);
close(bakchn);
fclose(input);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ipcs.c,v 1.26 2015/01/16 06:40:08 deraadt Exp $ */
/* $OpenBSD: ipcs.c,v 1.27 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: ipcs.c,v 1.25 2000/06/16 03:58:20 simonb Exp $ */
/*-
@ -448,7 +448,7 @@ msg_sysctl(void)
mib[0] = CTL_KERN;
mib[1] = KERN_SYSVMSG;
len = sizeof(valid);
if (sysctl(mib, 2, &valid, &len, NULL, 0) < 0) {
if (sysctl(mib, 2, &valid, &len, NULL, 0) == -1) {
warn("sysctl(KERN_SYSVMSG)");
return;
}
@ -465,7 +465,7 @@ msg_sysctl(void)
/* totals only */
len = sizeof(struct msginfo);
} else {
if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0) {
if (sysctl(mib, 3, NULL, &len, NULL, 0) == -1) {
warn("sysctl(KERN_SYSVIPC_MSG_INFO)");
return;
}
@ -474,7 +474,7 @@ msg_sysctl(void)
if ((buf = malloc(len)) == NULL)
err(1, "malloc");
msgsi = (struct msg_sysctl_info *)buf;
if (sysctl(mib, 3, msgsi, &len, NULL, 0) < 0) {
if (sysctl(mib, 3, msgsi, &len, NULL, 0) == -1) {
warn("sysctl(KERN_SYSVIPC_MSG_INFO)");
return;
}
@ -519,7 +519,7 @@ shm_sysctl(void)
mib[0] = CTL_KERN;
mib[1] = KERN_SYSVSHM;
len = sizeof(valid);
if (sysctl(mib, 2, &valid, &len, NULL, 0) < 0) {
if (sysctl(mib, 2, &valid, &len, NULL, 0) == -1) {
warn("sysctl(KERN_SYSVSHM)");
return;
}
@ -537,7 +537,7 @@ shm_sysctl(void)
/* totals only */
len = sizeof(struct shminfo);
} else {
if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0) {
if (sysctl(mib, 3, NULL, &len, NULL, 0) == -1) {
warn("sysctl(KERN_SYSVIPC_SHM_INFO)");
return;
}
@ -546,7 +546,7 @@ shm_sysctl(void)
if ((buf = malloc(len)) == NULL)
err(1, "malloc");
shmsi = (struct shm_sysctl_info *)buf;
if (sysctl(mib, 3, shmsi, &len, NULL, 0) < 0) {
if (sysctl(mib, 3, shmsi, &len, NULL, 0) == -1) {
warn("sysctl(KERN_SYSVIPC_SHM_INFO)");
return;
}
@ -590,7 +590,7 @@ sem_sysctl(void)
mib[0] = CTL_KERN;
mib[1] = KERN_SYSVSEM;
len = sizeof(valid);
if (sysctl(mib, 2, &valid, &len, NULL, 0) < 0) {
if (sysctl(mib, 2, &valid, &len, NULL, 0) == -1) {
warn("sysctl(KERN_SYSVSEM)");
return;
}
@ -608,7 +608,7 @@ sem_sysctl(void)
/* totals only */
len = sizeof(struct seminfo);
} else {
if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0) {
if (sysctl(mib, 3, NULL, &len, NULL, 0) == -1) {
warn("sysctl(KERN_SYSVIPC_SEM_INFO)");
return;
}
@ -617,7 +617,7 @@ sem_sysctl(void)
if ((buf = malloc(len)) == NULL)
err(1, "malloc");
semsi = (struct sem_sysctl_info *)buf;
if (sysctl(mib, 3, semsi, &len, NULL, 0) < 0) {
if (sysctl(mib, 3, semsi, &len, NULL, 0) == -1) {
warn("sysctl(KERN_SYSVIPC_SEM_INFO)");
return;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ktrace.c,v 1.35 2019/01/06 18:30:36 tedu Exp $ */
/* $OpenBSD: ktrace.c,v 1.36 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: ktrace.c,v 1.4 1995/08/31 23:01:44 jtc Exp $ */
/*-
@ -163,7 +163,7 @@ main(int argc, char *argv[])
} else
ops |= pid ? KTROP_CLEAR : KTROP_CLEARFILE;
if (ktrace(tracefile, ops, trpoints, pid) < 0) {
if (ktrace(tracefile, ops, trpoints, pid) == -1) {
if (errno == ESRCH)
err(1, "%d", pid);
err(1, "%s", tracefile);
@ -173,7 +173,7 @@ main(int argc, char *argv[])
omask = umask(S_IRWXG|S_IRWXO);
if (append) {
if ((fd = open(tracefile, O_CREAT | O_WRONLY, DEFFILEMODE)) < 0)
if ((fd = open(tracefile, O_CREAT | O_WRONLY, DEFFILEMODE)) == -1)
err(1, "%s", tracefile);
if (fstat(fd, &sb) != 0 || sb.st_uid != getuid())
errx(1, "Refuse to append to %s: not owned by you.",
@ -182,7 +182,7 @@ main(int argc, char *argv[])
if (unlink(tracefile) == -1 && errno != ENOENT)
err(1, "unlink %s", tracefile);
if ((fd = open(tracefile, O_CREAT | O_EXCL | O_WRONLY,
DEFFILEMODE)) < 0)
DEFFILEMODE)) == -1)
err(1, "%s", tracefile);
}
(void)umask(omask);
@ -196,12 +196,12 @@ main(int argc, char *argv[])
setenv("LD_TRACE_PLTSPEC", tracespec, 1) < 0)
err(1, "setenv(LD_TRACE_PLTSPEC)");
}
if (ktrace(tracefile, ops, trpoints, getpid()) < 0)
if (ktrace(tracefile, ops, trpoints, getpid()) == -1)
err(1, "%s", tracefile);
execvp(argv[0], &argv[0]);
err(1, "exec of '%s' failed", argv[0]);
}
else if (ktrace(tracefile, ops, trpoints, pid) < 0) {
else if (ktrace(tracefile, ops, trpoints, pid) == -1) {
if (errno == ESRCH)
err(1, "%d", pid);
err(1, "%s", tracefile);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: last.c,v 1.51 2018/08/03 15:01:28 deraadt Exp $ */
/* $OpenBSD: last.c,v 1.52 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: last.c,v 1.6 1994/12/24 16:49:02 cgd Exp $ */
/*
@ -254,7 +254,7 @@ wtmp(void)
off_t bl;
struct ttytab *T;
if ((wfd = open(file, O_RDONLY, 0)) < 0 || fstat(wfd, &stb) == -1)
if ((wfd = open(file, O_RDONLY, 0)) == -1 || fstat(wfd, &stb) == -1)
err(1, "%s", file);
bl = (stb.st_size + sizeof(buf) - 1) / sizeof(buf);
@ -558,7 +558,7 @@ dateconv(char *arg)
char *p;
/* Start with the current time. */
if (time(&timet) < 0)
if (time(&timet) == -1)
err(1, "time");
if ((t = localtime(&timet)) == NULL)
err(1, "localtime");

View File

@ -1299,7 +1299,7 @@ save_cmdhist(void)
/* Make history file readable only by owner. */
r = fstat(fileno(f), &statbuf);
if (r < 0 || !S_ISREG(statbuf.st_mode))
if (r == -1 || !S_ISREG(statbuf.st_mode))
/* Don't chmod if not a regular file. */
do_chmod = 0;
if (do_chmod)

View File

@ -624,7 +624,7 @@ lesskey(char *filename, int sysvar)
filename = shell_unquote(filename);
f = open(filename, O_RDONLY);
free(filename);
if (f < 0)
if (f == -1)
return (1);
/*

View File

@ -290,7 +290,7 @@ err1:
}
reedit_ifile(was_curr_ifile);
return (1);
} else if ((f = open(qopen_filename, O_RDONLY)) < 0) {
} else if ((f = open(qopen_filename, O_RDONLY)) == -1) {
/*
* Got an error trying to open it.
*/

View File

@ -191,7 +191,7 @@ dirfile(const char *dirname, const char *filename)
*/
qpathname = shell_unquote(pathname);
f = open(qpathname, O_RDONLY);
if (f < 0) {
if (f == -1) {
free(pathname);
pathname = NULL;
} else {
@ -713,7 +713,7 @@ bad_file(char *filename)
struct stat statbuf;
r = stat(filename, &statbuf);
if (r < 0) {
if (r == -1) {
m = errno_message(filename);
} else if (force_open) {
m = NULL;

View File

@ -74,7 +74,7 @@ lsystem(const char *cmd, const char *donemsg)
*/
inp = dup(0);
(void) close(0);
if (open("/dev/tty", O_RDONLY) < 0)
if (open("/dev/tty", O_RDONLY) == -1)
(void) dup(inp);
/*

View File

@ -40,7 +40,7 @@ iread(int fd, unsigned char *buf, unsigned int len)
start:
flush(0);
n = read(fd, buf, len);
if (n < 0) {
if (n == -1) {
/*
* Certain values of errno indicate we should just retry the
* read.

View File

@ -32,7 +32,7 @@ open_getchr(void)
* but also usually lets you read from the keyboard.
*/
tty = open("/dev/tty", O_RDONLY);
if (tty < 0)
if (tty == -1)
tty = STDERR_FILENO;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: lndir.c,v 1.22 2015/10/10 14:23:12 deraadt Exp $ */
/* $OpenBSD: lndir.c,v 1.23 2019/06/28 13:35:01 deraadt Exp $ */
/* $XConsortium: lndir.c /main/15 1995/08/30 10:56:18 gildea $ */
/*
@ -118,15 +118,15 @@ main(int argc, char *argv[])
tn = ".";
/* to directory */
if (stat(tn, &ts) < 0)
if (stat(tn, &ts) == -1)
err(1, "%s", tn);
if (!(S_ISDIR(ts.st_mode)))
errc(2, ENOTDIR, "%s", tn);
if (chdir(tn) < 0)
if (chdir(tn) == -1)
err(1, "%s", tn);
/* from directory */
if (stat(fn, &fs) < 0)
if (stat(fn, &fs) == -1)
err(1, "%s", fn);
if (!(S_ISDIR(fs.st_mode)))
errc(2, ENOTDIR, "%s", fn);
@ -221,7 +221,7 @@ dodir(char *fn, struct stat *fs, struct stat *ts, int rel)
strlcpy(p, dp->d_name, buf + sizeof(buf) - p);
if (n_dirs > 0) {
if (stat(buf, &sb) < 0) {
if (stat(buf, &sb) == -1) {
warn("%s", buf);
continue;
}
@ -247,10 +247,10 @@ dodir(char *fn, struct stat *fs, struct stat *ts, int rel)
curdir = silent ? buf : NULL;
if (!silent)
printf("%s:\n", buf);
if (stat(dp->d_name, &sc) < 0 &&
if (stat(dp->d_name, &sc) == -1 &&
errno == ENOENT) {
if (mkdir(dp->d_name, 0777) < 0 ||
stat(dp->d_name, &sc) < 0) {
if (mkdir(dp->d_name, 0777) == -1 ||
stat(dp->d_name, &sc) == -1) {
warn("%s", dp->d_name);
curdir = rcurdir = ocurdir;
continue;
@ -265,13 +265,13 @@ dodir(char *fn, struct stat *fs, struct stat *ts, int rel)
curdir = rcurdir = ocurdir;
continue;
}
if (chdir(dp->d_name) < 0) {
if (chdir(dp->d_name) == -1) {
warn("%s", dp->d_name);
curdir = rcurdir = ocurdir;
continue;
}
dodir(buf, &sb, &sc, (buf[0] != '/'));
if (chdir("..") < 0)
if (chdir("..") == -1)
err(1, "..");
curdir = rcurdir = ocurdir;
continue;
@ -306,7 +306,7 @@ dodir(char *fn, struct stat *fs, struct stat *ts, int rel)
fprintf(stderr,"%s: %s\n", dp->d_name, symbuf);
} else {
if (symlink(basesymlen >= 0 ? basesym : buf,
dp->d_name) < 0)
dp->d_name) == -1)
warn("%s", dp->d_name);
}
next:

View File

@ -1,4 +1,4 @@
/* $OpenBSD: login.c,v 1.70 2018/08/15 19:38:47 fcambus Exp $ */
/* $OpenBSD: login.c,v 1.71 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: login.c,v 1.13 1996/05/15 23:50:16 jtc Exp $ */
/*-
@ -161,7 +161,7 @@ main(int argc, char *argv[])
backoff = 3;
domain = NULL;
if (gethostname(localhost, sizeof(localhost)) < 0) {
if (gethostname(localhost, sizeof(localhost)) == -1) {
syslog(LOG_ERR, "couldn't get local hostname: %m");
strlcpy(localhost, "localhost", sizeof(localhost));
} else if ((domain = strchr(localhost, '.'))) {
@ -303,12 +303,12 @@ main(int argc, char *argv[])
/*
* Since login deals with sensitive information, turn off coredumps.
*/
if (getrlimit(RLIMIT_CORE, &scds) < 0) {
if (getrlimit(RLIMIT_CORE, &scds) == -1) {
syslog(LOG_ERR, "couldn't get core dump size: %m");
scds.rlim_cur = scds.rlim_max = QUAD_MIN;
}
cds.rlim_cur = cds.rlim_max = 0;
if (setrlimit(RLIMIT_CORE, &cds) < 0) {
if (setrlimit(RLIMIT_CORE, &cds) == -1) {
syslog(LOG_ERR, "couldn't set core dump size to 0: %m");
scds.rlim_cur = scds.rlim_max = QUAD_MIN;
}
@ -698,7 +698,7 @@ failed:
p + 1 : shell, sizeof(tbuf) - 1);
if ((scds.rlim_cur != QUAD_MIN || scds.rlim_max != QUAD_MIN) &&
setrlimit(RLIMIT_CORE, &scds) < 0)
setrlimit(RLIMIT_CORE, &scds) == -1)
syslog(LOG_ERR, "couldn't reset core dump size: %m");
if (lastchance)
@ -795,7 +795,7 @@ motd(void)
motd = login_getcapstr(lc, "welcome", _PATH_MOTDFILE, _PATH_MOTDFILE);
if ((fd = open(motd, O_RDONLY, 0)) < 0)
if ((fd = open(motd, O_RDONLY, 0)) == -1)
return;
memset(&sa, 0, sizeof(sa));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: look.c,v 1.22 2018/08/11 11:00:34 mestre Exp $ */
/* $OpenBSD: look.c,v 1.23 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: look.c,v 1.7 1995/08/31 22:41:02 jtc Exp $ */
/*-
@ -118,7 +118,7 @@ main(int argc, char *argv[])
if (termchar != '\0' && (p = strchr(string, termchar)) != NULL)
*++p = '\0';
if ((fd = open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
if ((fd = open(file, O_RDONLY, 0)) == -1 || fstat(fd, &sb) == -1)
err(2, "%s", file);
if (sb.st_size > SIZE_MAX)
errc(2, EFBIG, "%s", file);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: aux.c,v 1.30 2018/09/16 02:38:57 millert Exp $ */
/* $OpenBSD: aux.c,v 1.31 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */
/*
@ -98,7 +98,7 @@ isdir(char *name)
{
struct stat sbuf;
if (stat(name, &sbuf) < 0)
if (stat(name, &sbuf) == -1)
return(0);
return(S_ISDIR(sbuf.st_mode));
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cmd3.c,v 1.27 2015/10/16 17:56:07 mmcc Exp $ */
/* $OpenBSD: cmd3.c,v 1.28 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: cmd3.c,v 1.8 1997/07/09 05:29:49 mikel Exp $ */
/*
@ -163,7 +163,7 @@ schdir(void *v)
if ((cp = expand(*arglist)) == NULL)
return(1);
}
if (chdir(cp) < 0) {
if (chdir(cp) == -1) {
warn("%s", cp);
return(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: edit.c,v 1.20 2017/03/28 09:14:43 natano Exp $ */
/* $OpenBSD: edit.c,v 1.21 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: edit.c,v 1.5 1996/06/08 19:48:20 christos Exp $ */
/*
@ -172,7 +172,7 @@ run_editor(FILE *fp, off_t size, int type, int readonly)
while ((t = getc(fp)) != EOF)
(void)putc(t, nf);
(void)fflush(nf);
if (fstat(fileno(nf), &statb) < 0)
if (fstat(fileno(nf), &statb) == -1)
modtime = 0;
else
modtime = statb.st_mtime;
@ -211,7 +211,7 @@ run_editor(FILE *fp, off_t size, int type, int readonly)
(void)rm(tempname);
goto out;
}
if (stat(tempname, &statb) < 0) {
if (stat(tempname, &statb) == -1) {
warn("%s", tempname);
goto out;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fio.c,v 1.37 2018/04/26 12:42:51 guenther Exp $ */
/* $OpenBSD: fio.c,v 1.38 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: fio.c,v 1.8 1997/07/07 22:57:55 phil Exp $ */
/*
@ -260,7 +260,7 @@ setinput(struct message *mp)
fflush(otf);
if (fseek(itf, (long)positionof(mp->m_block, mp->m_offset), SEEK_SET)
< 0)
== -1)
err(1, "fseek");
return(itf);
}
@ -313,7 +313,7 @@ rm(char *name)
{
struct stat sb;
if (stat(name, &sb) < 0)
if (stat(name, &sb) == -1)
return(-1);
if (!S_ISREG(sb.st_mode)) {
errno = EISDIR;
@ -391,7 +391,7 @@ fsize(FILE *iob)
{
struct stat sbuf;
if (fstat(fileno(iob), &sbuf) < 0)
if (fstat(fileno(iob), &sbuf) == -1)
return(0);
return(sbuf.st_size);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: lex.c,v 1.40 2018/09/16 02:38:57 millert Exp $ */
/* $OpenBSD: lex.c,v 1.41 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */
/*
@ -72,7 +72,7 @@ setfile(char *name)
return(-1);
}
if (fstat(fileno(ibuf), &stb) < 0) {
if (fstat(fileno(ibuf), &stb) == -1) {
warn("fstat");
(void)Fclose(ibuf);
return(-1);
@ -108,7 +108,7 @@ setfile(char *name)
* and set pointers.
*/
readonly = 0;
if ((i = open(name, O_WRONLY, 0)) < 0)
if ((i = open(name, O_WRONLY, 0)) == -1)
readonly++;
else
(void)close(i);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.33 2015/11/24 00:08:27 deraadt Exp $ */
/* $OpenBSD: main.c,v 1.34 2019/06/28 13:35:02 deraadt Exp $ */
/* $NetBSD: main.c,v 1.7 1997/05/13 06:15:57 mikel Exp $ */
/*
@ -261,9 +261,9 @@ setscreensize(void)
struct winsize ws;
speed_t ospeed;
if (ioctl(1, TIOCGWINSZ, (char *) &ws) < 0)
if (ioctl(1, TIOCGWINSZ, (char *) &ws) == -1)
ws.ws_col = ws.ws_row = 0;
if (tcgetattr(1, &tbuf) < 0)
if (tcgetattr(1, &tbuf) == -1)
ospeed = 9600;
else
ospeed = cfgetospeed(&tbuf);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: names.c,v 1.24 2018/09/16 02:38:57 millert Exp $ */
/* $OpenBSD: names.c,v 1.25 2019/06/28 13:35:02 deraadt Exp $ */
/* $NetBSD: names.c,v 1.5 1996/06/08 19:48:32 christos Exp $ */
/*
@ -245,7 +245,7 @@ outof(struct name *names, FILE *fo, struct header *hp)
}
image = open(tempname, O_RDWR | O_CLOEXEC);
(void)rm(tempname);
if (image < 0) {
if (image == -1) {
warn("%s", tempname);
senderr++;
(void)Fclose(fout);
@ -299,7 +299,7 @@ outof(struct name *names, FILE *fo, struct header *hp)
senderr++;
goto cant;
}
if ((f = dup(image)) < 0) {
if ((f = dup(image)) == -1) {
warn("dup");
fin = NULL;
} else

Some files were not shown because too many files have changed in this diff Show More