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:32:41 +00:00
parent dc3feea064
commit df69c215c7
326 changed files with 1763 additions and 1763 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: more.c,v 1.40 2019/01/25 00:19:25 millert Exp $ */
/* $OpenBSD: more.c,v 1.41 2019/06/28 13:32:52 deraadt Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <millert@openbsd.org>
@ -1322,7 +1322,7 @@ retry:
* Wait until we're in the foreground before we save the
* the terminal modes.
*/
if ((tgrp = tcgetpgrp(STDOUT_FILENO)) < 0) {
if ((tgrp = tcgetpgrp(STDOUT_FILENO)) == -1) {
perror("tcgetpgrp");
exit(1);
}
@ -1333,7 +1333,7 @@ retry:
if ((term = getenv("TERM")) == 0 || tgetent(buf, term) <= 0) {
dumb++; ul_opt = 0;
} else {
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) < 0) {
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == -1) {
Lpp = tgetnum("li");
Mcol = tgetnum("co");
} else {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.24 2017/01/20 00:50:16 krw Exp $ */
/* $OpenBSD: log.c,v 1.25 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: log.c,v 1.3 1995/03/21 15:04:21 cgd Exp $ */
/*-
@ -120,7 +120,7 @@ open_score_file(void)
old_mode = umask(0);
score_fd = open(scorefile, O_CREAT|O_RDWR, 0644);
if (score_fd < 0)
if (score_fd == -1)
err(1, "open");
/*
* This is done to take advantage of stdio, while still
@ -144,7 +144,7 @@ log_score(int list_em)
if (score_fp == NULL)
return (-1);
if (flock(fileno(score_fp), LOCK_EX) < 0)
if (flock(fileno(score_fp), LOCK_EX) == -1)
err(1, "flock");
snprintf(scanstr, 50, "%%%zus %%%zus %%d %%d %%d", sizeof(score[0].name)-1,
sizeof(score[0].game)-1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: grdc.c,v 1.30 2019/01/06 18:27:14 tedu Exp $ */
/* $OpenBSD: grdc.c,v 1.31 2019/06/28 13:32:52 deraadt Exp $ */
/*
*
* Copyright 2002 Amos Shapir. Public domain.
@ -293,7 +293,7 @@ getwinsize(int *wid, int *ht)
{
struct winsize size;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) < 0) {
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == -1) {
*wid = 80; /* Default */
*ht = 24;
} else {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hack.bones.c,v 1.10 2016/01/09 18:33:15 mestre Exp $ */
/* $OpenBSD: hack.bones.c,v 1.11 2019/06/28 13:32:52 deraadt Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@ -131,7 +131,7 @@ savebones(void)
otmp->cursed = 1; /* flag as gotten from a ghost */
}
}
if((fd = open(bones, O_CREAT | O_TRUNC | O_WRONLY, FMASK)) < 0) return;
if((fd = open(bones, O_CREAT | O_TRUNC | O_WRONLY, FMASK)) == -1) return;
savelev(fd,dlevel);
(void) close(fd);
}
@ -144,7 +144,7 @@ getbones(void)
if(rn2(3)) return(0); /* only once in three times do we find bones */
bones[6] = '0' + dlevel/10;
bones[7] = '0' + dlevel%10;
if((fd = open(bones, O_RDONLY)) < 0) return(0);
if((fd = open(bones, O_RDONLY)) == -1) return(0);
if((ok = uptodate(fd)) != 0){
getlev(fd, 0, dlevel);
for(x = 0; x < COLNO; x++) for(y = 0; y < ROWNO; y++)
@ -154,7 +154,7 @@ getbones(void)
#ifdef WIZARD
if(!wizard) /* duvel!frans: don't remove bones while debugging */
#endif /* WiZARD */
if(unlink(bones) < 0){
if(unlink(bones) == -1){
pline("Cannot unlink %s .", bones);
return(0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hack.do.c,v 1.10 2016/01/09 18:33:15 mestre Exp $ */
/* $OpenBSD: hack.do.c,v 1.11 2019/06/28 13:32:52 deraadt Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@ -195,7 +195,7 @@ goto_level(int newlevel, boolean at_stairs)
glo(dlevel);
fd = open(lock, O_CREAT | O_TRUNC | O_WRONLY, FMASK);
if(fd < 0) {
if(fd == -1) {
/*
* This is not quite impossible: e.g., we may have
* exceeded our quota. If that is the case then we
@ -232,7 +232,7 @@ goto_level(int newlevel, boolean at_stairs)
else {
extern int hackpid;
if((fd = open(lock, O_RDONLY)) < 0) {
if((fd = open(lock, O_RDONLY)) == -1) {
pline("Cannot open %s .", lock);
pline("Probably someone removed it.");
done("tricked");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hack.main.c,v 1.23 2019/04/05 09:02:27 bentley Exp $ */
/* $OpenBSD: hack.main.c,v 1.24 2019/06/28 13:32:52 deraadt Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@ -533,7 +533,7 @@ chdirx(char *dir, boolean wr)
dir = HACKDIR;
#endif
if(dir && chdir(dir) < 0) {
if(dir && chdir(dir) == -1) {
perror(dir);
error("Cannot chdir to %s.", dir);
}
@ -548,12 +548,12 @@ chdirx(char *dir, boolean wr)
if(dir == NULL)
dir = ".";
if((fd = open(RECORD, O_RDWR | O_CREAT, FMASK)) < 0) {
if((fd = open(RECORD, O_RDWR | O_CREAT, FMASK)) == -1) {
printf("Warning: cannot write %s/%s", dir, RECORD);
getret();
} else
(void) close(fd);
if((fd = open(HLOCK, O_RDONLY | O_CREAT, FMASK)) < 0) {
if((fd = open(HLOCK, O_RDONLY | O_CREAT, FMASK)) == -1) {
printf("Warning: cannot read %s/%s", dir, HLOCK);
getret();
} else

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hack.pager.c,v 1.24 2016/03/15 19:56:20 mestre Exp $ */
/* $OpenBSD: hack.pager.c,v 1.25 2019/06/28 13:32:52 deraadt Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@ -369,7 +369,7 @@ page_file(char *fnam, boolean silent)
int fd = open(fnam, O_RDONLY);
if(fd < 0) {
if(fd == -1) {
if(!silent) pline("Cannot open %s.", fnam);
return(0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hack.save.c,v 1.13 2016/01/09 18:33:15 mestre Exp $ */
/* $OpenBSD: hack.save.c,v 1.14 2019/06/28 13:32:52 deraadt Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@ -101,7 +101,7 @@ dosave0(int hu)
(void) signal(SIGHUP, SIG_IGN);
(void) signal(SIGINT, SIG_IGN);
if((fd = open(SAVEF, O_CREAT | O_TRUNC | O_WRONLY, FMASK)) < 0) {
if((fd = open(SAVEF, O_CREAT | O_TRUNC | O_WRONLY, FMASK)) == -1) {
if(!hu) pline("Cannot open save file. (Continue or Quit)");
(void) unlink(SAVEF); /* ab@unido */
return(0);
@ -131,7 +131,7 @@ dosave0(int hu)
if(tmp == dlevel || !level_exists[tmp]) continue;
glo(tmp);
if((ofd = open(lock, O_RDONLY)) < 0) {
if((ofd = open(lock, O_RDONLY)) == -1) {
if(!hu) pline("Error while saving: cannot read %s.", lock);
(void) close(fd);
(void) unlink(SAVEF);
@ -193,7 +193,7 @@ dorecover(int fd)
break;
getlev(fd, 0, tmp);
glo(tmp);
if((nfd = open(lock, O_CREAT | O_TRUNC | O_WRONLY, FMASK)) < 0)
if((nfd = open(lock, O_CREAT | O_TRUNC | O_WRONLY, FMASK)) == -1)
panic("Cannot open temp file %s!\n", lock);
savelev(nfd,tmp);
(void) close(nfd);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hack.tty.c,v 1.15 2016/01/09 18:33:15 mestre Exp $ */
/* $OpenBSD: hack.tty.c,v 1.16 2019/06/28 13:32:52 deraadt Exp $ */
/*-
* Copyright (c) 1988, 1993
@ -114,7 +114,7 @@ static void setctty(void);
void
gettty(void)
{
if(tcgetattr(0, &inittyb) < 0)
if(tcgetattr(0, &inittyb) == -1)
perror("Hack (gettty)");
curttyb = inittyb;
erase_char = inittyb.c_cc[VERASE];
@ -137,7 +137,7 @@ settty(char *s)
end_screen();
if(s) printf("%s", s);
(void) fflush(stdout);
if(tcsetattr(0, TCSADRAIN, &inittyb) < 0)
if(tcsetattr(0, TCSADRAIN, &inittyb) == -1)
perror("Hack (settty)");
flags.echo = (inittyb.c_lflag & ECHO) ? ON : OFF;
flags.cbreak = (inittyb.c_lflag & ICANON) ? OFF : ON;
@ -147,7 +147,7 @@ settty(char *s)
static void
setctty(void)
{
if(tcsetattr(0, TCSADRAIN, &curttyb) < 0)
if(tcsetattr(0, TCSADRAIN, &curttyb) == -1)
perror("Hack (setctty)");
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: makedefs.c,v 1.11 2018/08/24 11:14:49 mestre Exp $ */
/* $OpenBSD: makedefs.c,v 1.12 2019/06/28 13:32:52 deraadt Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@ -93,7 +93,7 @@ main(int argc, char **argv)
(void)fprintf(stderr, "usage: makedefs file\n");
return 1;
}
if ((fd = open(argv[1], O_RDONLY)) < 0) {
if ((fd = open(argv[1], O_RDONLY)) == -1) {
perror(argv[1]);
return 1;
}
@ -138,7 +138,7 @@ readline(void)
{
int n = read(fd, lp0, (line+LINSZ)-lp0);
if(n < 0){
if(n == -1){
printf("Input error.\n");
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ksyms.c,v 1.11 2017/10/27 16:47:08 mpi Exp $ */
/* $OpenBSD: ksyms.c,v 1.12 2019/06/28 13:32:52 deraadt Exp $ */
/*
* Copyright (c) 2008 Miodrag Vallat.
@ -44,7 +44,7 @@ sym_getword(void)
if (lseek(symfd, pos + symoffs, SEEK_SET) == -1)
continue;
buflen = read(symfd, symbuf, BUFSIZ);
if (buflen < 0)
if (buflen == -1)
continue;
/*
@ -94,7 +94,7 @@ sym_getword(void)
int
sym_setup(void)
{
if ((symfd = open(Dict_name, O_RDONLY)) < 0)
if ((symfd = open(Dict_name, O_RDONLY)) == -1)
return -1;
if (ksyms_elf_parse() == 0)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: list.c,v 1.9 2016/08/27 02:06:40 guenther Exp $ */
/* $OpenBSD: list.c,v 1.10 2019/06/28 13:32:52 deraadt Exp $ */
/*
* Copyright 2001, David Leonard. All rights reserved.
* Redistribution and use in source and binary forms with or without
@ -261,7 +261,7 @@ probe_drivers(u_int16_t req, char *preferred)
if ((ninbuf = realloc(inbuf, inlen)) == NULL)
err(1, "malloc");
ifc.ifc_buf = inbuf = ninbuf;
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0)
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) == -1)
err(1, "SIOCGIFCONF");
if (ifc.ifc_len + sizeof(*ifr) < inlen)
break;
@ -279,20 +279,20 @@ probe_drivers(u_int16_t req, char *preferred)
if (ifr->ifr_addr.sa_family != AF_INET)
continue;
if (ioctl(fd, SIOCGIFFLAGS, (caddr_t)ifr) < 0) {
if (ioctl(fd, SIOCGIFFLAGS, (caddr_t)ifr) == -1) {
warn("%s: SIOCGIFFLAGS", ifr->ifr_name);
continue;
}
if ((ifr->ifr_flags & IFF_UP) == 0)
continue;
if ((ifr->ifr_flags & IFF_BROADCAST) != 0) {
if (ioctl(fd, SIOCGIFBRDADDR, (caddr_t)ifr) < 0) {
if (ioctl(fd, SIOCGIFBRDADDR, (caddr_t)ifr) == -1) {
warn("%s: SIOCGIFBRDADDR", ifr->ifr_name);
continue;
}
target = (struct sockaddr_in *)&ifr->ifr_dstaddr;
} else if ((ifr->ifr_flags & IFF_POINTOPOINT) != 0) {
if (ioctl(fd, SIOCGIFDSTADDR, (caddr_t)ifr) < 0) {
if (ioctl(fd, SIOCGIFDSTADDR, (caddr_t)ifr) == -1) {
warn("%s: SIOCGIFDSTADDR", ifr->ifr_name);
continue;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: save.c,v 1.13 2016/09/11 14:21:18 tb Exp $ */
/* $OpenBSD: save.c,v 1.14 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: save.c,v 1.4 1995/03/24 05:02:13 cgd Exp $ */
/*
@ -108,7 +108,7 @@ over:
&& getyn(OVERWRITEFILEPROMPT) == FALSE))
return FALSE;
if ((outf = open(buf, O_CREAT | O_TRUNC | O_WRONLY, 0644)) < 0) {
if ((outf = open(buf, O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1) {
error(strerror(errno));
return FALSE;
}
@ -144,9 +144,9 @@ rest_f(const char *file)
char buf[80];
STAT sbuf;
if ((inf = open(file, O_RDONLY)) < 0)
if ((inf = open(file, O_RDONLY)) == -1)
err(1, "%s", file);
if (fstat(inf, &sbuf) < 0) /* get file stats */
if (fstat(inf, &sbuf) == -1) /* get file stats */
err(1, "%s", file);
varpush(inf, readv);
close(inf);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: varpush.c,v 1.11 2016/01/08 18:09:59 mestre Exp $ */
/* $OpenBSD: varpush.c,v 1.12 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: varpush.c,v 1.4 1995/03/24 05:02:35 cgd Exp $ */
/*
@ -73,7 +73,7 @@ varpush(int file, ssize_t (*func)(int, const struct iovec *, int))
}
if (func == readv) {
if ((read(file, (void *) &temp, sizeof temp)) < 0) {
if ((read(file, (void *) &temp, sizeof temp)) == -1) {
error(strerror(errno));
return FALSE;
}
@ -94,7 +94,7 @@ over:
#endif
} else {
temp = Topcard - Deck;
if ((write(file, (void *) &temp, sizeof temp)) < 0) {
if ((write(file, (void *) &temp, sizeof temp)) == -1) {
error(strerror(errno));
return FALSE;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: execute.c,v 1.14 2016/09/11 14:21:18 tb Exp $ */
/* $OpenBSD: execute.c,v 1.15 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: execute.c,v 1.3 1995/03/23 08:34:38 cgd Exp $ */
/*
@ -292,7 +292,7 @@ rest_f(char *file)
long tl;
printf("\"%s\" ", file);
if (stat(file, &sbuf) < 0) { /* get file stats */
if (stat(file, &sbuf) == -1) { /* get file stats */
warn("%s", file);
return(FALSE);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: setup.c,v 1.19 2016/03/07 12:07:56 mestre Exp $ */
/* $OpenBSD: setup.c,v 1.20 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: setup.c,v 1.4 1995/04/24 12:24:41 cgd Exp $ */
/*
@ -116,11 +116,11 @@ main(int argc, char *argv[])
continue;
}
if (unlink(path) < 0)
if (unlink(path) == -1)
Error("Cannot unlink %s.\n", path);
}
if ((fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0660)) < 0)
if ((fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0660)) == -1)
Error("Cannot create %s.\n", path);
close(fd); /* close newly created file */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.27 2018/08/23 06:26:35 mestre Exp $ */
/* $OpenBSD: main.c,v 1.28 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: main.c,v 1.5 1995/04/22 10:08:54 cgd Exp $ */
/*
@ -74,7 +74,7 @@ main(int ac, char *av[])
if (ret < 0 || ret >= PATH_MAX)
errc(1, ENAMETOOLONG, "%s/%s", home, ".robots.scores");
if ((score_wfd = open(Scorefile, O_RDWR | O_CREAT, 0666)) < 0)
if ((score_wfd = open(Scorefile, O_RDWR | O_CREAT, 0666)) == -1)
score_err = errno;
show_only = FALSE;
@ -113,7 +113,7 @@ main(int ac, char *av[])
if (score_wfd >= 0)
close(score_wfd);
/* This file requires no special privileges. */
if ((score_wfd = open(Scorefile, O_RDWR | O_CREAT, 0666)) < 0)
if ((score_wfd = open(Scorefile, O_RDWR | O_CREAT, 0666)) == -1)
score_err = errno;
#ifdef FANCY
sp = strrchr(Scorefile, '/');

View File

@ -1,4 +1,4 @@
/* $OpenBSD: score.c,v 1.15 2017/05/28 20:34:33 tedu Exp $ */
/* $OpenBSD: score.c,v 1.16 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: score.c,v 1.3 1995/04/22 10:09:12 cgd Exp $ */
/*
@ -168,7 +168,7 @@ show_score(void)
int inf;
static int max_score;
if ((inf = open(Scorefile, O_RDONLY)) < 0) {
if ((inf = open(Scorefile, O_RDONLY)) == -1) {
perror(Scorefile);
return;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: misc.c,v 1.10 2016/03/16 15:00:35 mestre Exp $ */
/* $OpenBSD: misc.c,v 1.11 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: misc.c,v 1.3 1995/04/22 10:37:03 cgd Exp $ */
/*
@ -203,7 +203,7 @@ logger(struct ship *s)
}
setegid(gid);
#ifdef LOCK_EX
if (flock(fileno(fp), LOCK_EX) < 0)
if (flock(fileno(fp), LOCK_EX) == -1)
return;
#endif
net = (float)s->file->points / s->specs->pts;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pl_1.c,v 1.12 2016/01/08 20:26:33 mestre Exp $ */
/* $OpenBSD: pl_1.c,v 1.13 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $ */
/*
@ -131,7 +131,7 @@ child(int n __attribute__((unused)))
(void) signal(SIGCHLD, SIG_DFL);
do {
pid = waitpid((pid_t)-1, &status, WNOHANG);
if (pid < 0 || (pid > 0 && !WIFSTOPPED(status)))
if (pid == -1 || (pid > 0 && !WIFSTOPPED(status)))
hasdriver = 0;
} while (pid > 0);
(void) signal(SIGCHLD, child);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sync.c,v 1.15 2016/09/11 14:21:18 tb Exp $ */
/* $OpenBSD: sync.c,v 1.16 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: sync.c,v 1.9 1998/08/30 09:19:40 veego Exp $ */
/*
@ -119,7 +119,7 @@ sync_exists(int game)
(void) snprintf(buf, sizeof buf, SF, game);
(void) time(&t);
setegid(egid);
if (stat(buf, &s) < 0) {
if (stat(buf, &s) == -1) {
setegid(gid);
return 0;
}
@ -144,7 +144,7 @@ sync_open(void)
(void) snprintf(sync_lock, sizeof sync_lock, LF, game);
(void) snprintf(sync_file, sizeof sync_file, SF, game);
setegid(egid);
if (stat(sync_file, &tmp) < 0) {
if (stat(sync_file, &tmp) == -1) {
mode_t omask = umask(002);
sync_fp = fopen(sync_file, "w+");
(void) umask(omask);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: snake.c,v 1.33 2019/01/20 04:14:19 tedu Exp $ */
/* $OpenBSD: snake.c,v 1.34 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $ */
/*
@ -971,7 +971,7 @@ readscores(int create)
errc(1, ENAMETOOLONG, "%s/%s", home, ".snake.scores");
rawscores = open(scorepath, modint, 0666);
if (rawscores < 0) {
if (rawscores == -1) {
if (create == 0)
return 0;
err(1, "cannot open %s", scorepath);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: scores.c,v 1.24 2019/05/20 02:11:22 lteo Exp $ */
/* $OpenBSD: scores.c,v 1.25 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: scores.c,v 1.2 1995/04/22 07:42:38 cgd Exp $ */
/*-
@ -107,7 +107,7 @@ getscores(FILE **fpp)
}
sd = open(scorepath, mint, 0666);
if (sd < 0) {
if (sd == -1) {
if (fpp == NULL) {
nscores = 0;
return;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: screen.c,v 1.18 2017/04/16 18:04:02 tb Exp $ */
/* $OpenBSD: screen.c,v 1.19 2019/06/28 13:32:52 deraadt Exp $ */
/* $NetBSD: screen.c,v 1.4 1995/04/29 01:11:36 mycroft Exp $ */
/*-
@ -279,12 +279,12 @@ scr_set(void)
MINROWS, MINCOLS);
stop(smallscr);
}
if (tcgetattr(0, &oldtt) < 0)
if (tcgetattr(0, &oldtt) == -1)
stop("tcgetattr() fails");
newtt = oldtt;
newtt.c_lflag &= ~(ICANON|ECHO);
newtt.c_oflag &= ~OXTABS;
if (tcsetattr(0, TCSADRAIN, &newtt) < 0)
if (tcsetattr(0, TCSADRAIN, &newtt) == -1)
stop("tcsetattr() fails");
(void) sigprocmask(SIG_BLOCK, &sigset, &osigset);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: alarm.c,v 1.8 2016/01/28 16:40:54 schwarze Exp $ */
/* $OpenBSD: alarm.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@ -40,7 +40,7 @@ alarm(unsigned int secs)
timerclear(&itp->it_interval);
itp->it_value.tv_sec = secs;
itp->it_value.tv_usec = 0;
if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
if (setitimer(ITIMER_REAL, itp, &oitv) == -1)
return ((unsigned int) -1);
if (oitv.it_value.tv_usec)
oitv.it_value.tv_sec++;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: auth_subr.c,v 1.52 2019/03/23 17:03:00 millert Exp $ */
/* $OpenBSD: auth_subr.c,v 1.53 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 2000-2002,2004 Todd C. Miller <millert@openbsd.org>
@ -848,7 +848,7 @@ auth_call(auth_session_t *as, char *path, ...)
argv[argc] = NULL;
if (socketpair(PF_LOCAL, SOCK_STREAM, 0, pfd) < 0) {
if (socketpair(PF_LOCAL, SOCK_STREAM, 0, pfd) == -1) {
syslog(LOG_ERR, "unable to create backchannel %m");
warnx("internal resource failure");
goto fail;
@ -864,10 +864,10 @@ auth_call(auth_session_t *as, char *path, ...)
case 0:
#define COMM_FD 3
#define AUTH_FD 4
if (dup2(pfd[1], COMM_FD) < 0)
if (dup2(pfd[1], COMM_FD) == -1)
err(1, "dup of backchannel");
if (as->fd != -1) {
if (dup2(as->fd, AUTH_FD) < 0)
if (dup2(as->fd, AUTH_FD) == -1)
err(1, "dup of auth fd");
closefrom(AUTH_FD + 1);
} else
@ -1003,7 +1003,7 @@ _recv_fd(auth_session_t *as, int fd)
memset(&msg, 0, sizeof(msg));
msg.msg_control = &cmsgbuf.buf;
msg.msg_controllen = sizeof(cmsgbuf.buf);
if (recvmsg(fd, &msg, 0) < 0)
if (recvmsg(fd, &msg, 0) == -1)
syslog(LOG_ERR, "recvmsg: %m");
else if (msg.msg_flags & MSG_TRUNC)
syslog(LOG_ERR, "message truncated");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: authenticate.c,v 1.26 2016/05/26 15:51:37 millert Exp $ */
/* $OpenBSD: authenticate.c,v 1.27 2019/06/28 13:32:41 deraadt Exp $ */
/*-
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
@ -164,7 +164,7 @@ auth_cat(char *file)
int fd, nchars;
char tbuf[8192];
if ((fd = open(file, O_RDONLY, 0)) < 0)
if ((fd = open(file, O_RDONLY, 0)) == -1)
return (0);
while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0)
(void)write(fileno(stdout), tbuf, nchars);
@ -282,7 +282,7 @@ auth_approval(auth_session_t *as, login_cap_t *lc, char *name, char *type)
pwd->pw_dir[0]) {
struct stat sb;
if (stat(pwd->pw_dir, &sb) < 0 || !S_ISDIR(sb.st_mode) ||
if (stat(pwd->pw_dir, &sb) == -1 || !S_ISDIR(sb.st_mode) ||
(pwd->pw_uid && sb.st_uid == pwd->pw_uid &&
(sb.st_mode & S_IXUSR) == 0)) {
auth_setstate(as, (auth_getstate(as) & ~AUTH_ALLOW));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ftok.c,v 1.8 2014/11/15 22:38:47 guenther Exp $ */
/* $OpenBSD: ftok.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
* All rights reserved.
@ -34,7 +34,7 @@ ftok(const char *path, int id)
{
struct stat st;
if (stat(path, &st) < 0)
if (stat(path, &st) == -1)
return (key_t)-1;
return (key_t)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fts.c,v 1.58 2017/03/17 15:14:40 deraadt Exp $ */
/* $OpenBSD: fts.c,v 1.59 2019/06/28 13:32:41 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -160,7 +160,7 @@ fts_open(char * const *argv, int options,
* descriptor we run anyway, just more slowly.
*/
if (!ISSET(FTS_NOCHDIR) &&
(sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC)) < 0)
(sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC)) == -1)
SET(FTS_NOCHDIR);
if (nitems == 0)
@ -287,7 +287,7 @@ fts_read(FTS *sp)
p->fts_info = fts_stat(sp, p, 1, -1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd =
open(".", O_RDONLY | O_CLOEXEC)) < 0) {
open(".", O_RDONLY | O_CLOEXEC)) == -1) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
} else
@ -377,7 +377,7 @@ next: tmp = p;
p->fts_info = fts_stat(sp, p, 1, -1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd =
open(".", O_RDONLY | O_CLOEXEC)) < 0) {
open(".", O_RDONLY | O_CLOEXEC)) == -1) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
} else
@ -517,7 +517,7 @@ fts_children(FTS *sp, int instr)
ISSET(FTS_NOCHDIR))
return (sp->fts_child = fts_build(sp, instr));
if ((fd = open(".", O_RDONLY | O_CLOEXEC)) < 0)
if ((fd = open(".", O_RDONLY | O_CLOEXEC)) == -1)
return (NULL);
sp->fts_child = fts_build(sp, instr);
if (fchdir(fd)) {
@ -1028,9 +1028,9 @@ fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
newfd = fd;
if (ISSET(FTS_NOCHDIR))
return (0);
if (fd < 0 && (newfd = open(path, O_RDONLY|O_DIRECTORY|O_CLOEXEC)) < 0)
if (fd == -1 && (newfd = open(path, O_RDONLY|O_DIRECTORY|O_CLOEXEC)) == -1)
return (-1);
if (fstat(newfd, &sb)) {
if (fstat(newfd, &sb) == -1) {
ret = -1;
goto bail;
}
@ -1042,7 +1042,7 @@ fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
ret = fchdir(newfd);
bail:
oerrno = errno;
if (fd < 0)
if (fd == -1)
(void)close(newfd);
errno = oerrno;
return (ret);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: getloadavg.c,v 1.7 2015/01/16 16:48:51 deraadt Exp $ */
/* $OpenBSD: getloadavg.c,v 1.8 2019/06/28 13:32:41 deraadt Exp $ */
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -52,7 +52,7 @@ getloadavg(double loadavg[], int nelem)
mib[0] = CTL_VM;
mib[1] = VM_LOADAVG;
size = sizeof(loadinfo);
if (sysctl(mib, 2, &loadinfo, &size, NULL, 0) < 0)
if (sysctl(mib, 2, &loadinfo, &size, NULL, 0) == -1)
return (-1);
nelem = MINIMUM(nelem, sizeof(loadinfo.ldavg) / sizeof(fixpt_t));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: getmntinfo.c,v 1.10 2015/09/14 16:09:13 tedu Exp $ */
/* $OpenBSD: getmntinfo.c,v 1.11 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -42,18 +42,18 @@ getmntinfo(struct statfs **mntbufp, int flags)
static int mntsize;
static size_t bufsize;
if (mntsize <= 0 && (mntsize = getfsstat(0, 0, MNT_NOWAIT)) < 0)
if (mntsize <= 0 && (mntsize = getfsstat(0, 0, MNT_NOWAIT)) == -1)
return (0);
if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, flags)) < 0)
if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, flags)) == -1)
return (0);
while (bufsize <= mntsize * sizeof(struct statfs)) {
free(mntbuf);
bufsize = (mntsize + 1) * sizeof(struct statfs);
if ((mntbuf = malloc(bufsize)) == 0) {
if ((mntbuf = malloc(bufsize)) == NULL) {
bufsize = 0;
return (0);
}
if ((mntsize = getfsstat(mntbuf, bufsize, flags)) < 0)
if ((mntsize = getfsstat(mntbuf, bufsize, flags)) == -1)
return (0);
}
*mntbufp = mntbuf;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: initgroups.c,v 1.10 2015/09/12 14:56:50 guenther Exp $ */
/* $OpenBSD: initgroups.c,v 1.11 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@ -41,7 +41,7 @@ initgroups(const char *uname, gid_t agroup)
ngroups = NGROUPS_MAX;
(void) getgrouplist(uname, agroup, groups, &ngroups);
if (setgroups(ngroups, groups) < 0)
if (setgroups(ngroups, groups) == -1)
return (-1);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: login_cap.c,v 1.36 2019/03/23 17:03:00 millert Exp $ */
/* $OpenBSD: login_cap.c,v 1.37 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 2000-2004 Todd C. Miller <millert@openbsd.org>
@ -598,7 +598,7 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags)
if (flags & LOGIN_SETPRIORITY) {
p = login_getcapnum(lc, "priority", 0, 0);
if (setpriority(PRIO_PROCESS, 0, (int)p) < 0)
if (setpriority(PRIO_PROCESS, 0, (int)p) == -1)
syslog(LOG_ERR, "%s: setpriority: %m", lc->lc_class);
}
@ -608,14 +608,14 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags)
}
if (flags & LOGIN_SETGROUP) {
if (setresgid(pwd->pw_gid, pwd->pw_gid, pwd->pw_gid) < 0) {
if (setresgid(pwd->pw_gid, pwd->pw_gid, pwd->pw_gid) == -1) {
syslog(LOG_ERR, "setresgid(%u,%u,%u): %m",
pwd->pw_gid, pwd->pw_gid, pwd->pw_gid);
login_close(flc);
return (-1);
}
if (initgroups(pwd->pw_name, pwd->pw_gid) < 0) {
if (initgroups(pwd->pw_name, pwd->pw_gid) == -1) {
syslog(LOG_ERR, "initgroups(%s,%u): %m",
pwd->pw_name, pwd->pw_gid);
login_close(flc);
@ -624,7 +624,7 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags)
}
if (flags & LOGIN_SETLOGIN)
if (setlogin(pwd->pw_name) < 0) {
if (setlogin(pwd->pw_name) == -1) {
syslog(LOG_ERR, "setlogin(%s) failure: %m",
pwd->pw_name);
login_close(flc);
@ -632,7 +632,7 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags)
}
if (flags & LOGIN_SETUSER) {
if (setresuid(uid, uid, uid) < 0) {
if (setresuid(uid, uid, uid) == -1) {
syslog(LOG_ERR, "setresuid(%u,%u,%u): %m",
uid, uid, uid);
login_close(flc);
@ -968,7 +968,7 @@ secure_path(char *path)
* If not a regular file, or is owned/writeable by someone
* other than root, quit.
*/
if (lstat(path, &sb) < 0) {
if (lstat(path, &sb) == -1) {
syslog(LOG_ERR, "cannot stat %s: %m", path);
return (-1);
} else if (!S_ISREG(sb.st_mode)) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: nlist.c,v 1.70 2019/05/13 17:18:10 guenther Exp $ */
/* $OpenBSD: nlist.c,v 1.71 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -102,7 +102,7 @@ __fdnlist(int fd, struct nlist *list)
/* Make sure obj is OK */
if (pread(fd, &ehdr, sizeof(Elf_Ehdr), 0) != sizeof(Elf_Ehdr) ||
!__elf_is_okay__(&ehdr) || fstat(fd, &st) < 0)
!__elf_is_okay__(&ehdr) || fstat(fd, &st) == -1)
return (-1);
/* calculate section header table size */
@ -293,7 +293,7 @@ nlist(const char *name, struct nlist *list)
int fd, n;
fd = open(name, O_RDONLY | O_CLOEXEC);
if (fd < 0)
if (fd == -1)
return (-1);
n = __fdnlist(fd, list);
(void)close(fd);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: popen.c,v 1.21 2015/08/31 02:53:57 guenther Exp $ */
/* $OpenBSD: popen.c,v 1.22 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@ -70,7 +70,7 @@ popen(const char *program, const char *type)
if ((cur = malloc(sizeof(struct pid))) == NULL)
return (NULL);
if (pipe2(pdes, O_CLOEXEC) < 0) {
if (pipe2(pdes, O_CLOEXEC) == -1) {
free(cur);
return (NULL);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: posix_spawn.c,v 1.9 2016/03/13 18:34:20 guenther Exp $ */
/* $OpenBSD: posix_spawn.c,v 1.10 2019/06/28 13:32:41 deraadt Exp $ */
/*-
* Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
* All rights reserved.
@ -141,7 +141,7 @@ process_file_actions_entry(posix_spawn_file_actions_entry_t *fae)
case FAE_OPEN:
/* Perform an open(), make it use the right fd */
fd = open(fae->fae_path, fae->fae_oflag, fae->fae_mode);
if (fd < 0)
if (fd == -1)
return (errno);
if (fd != fae->fae_fildes) {
if (dup2(fd, fae->fae_fildes) == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: scandir.c,v 1.20 2015/08/20 21:49:29 deraadt Exp $ */
/* $OpenBSD: scandir.c,v 1.21 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@ -70,7 +70,7 @@ scandir(const char *dirname, struct dirent ***namelist,
if ((dirp = opendir(dirname)) == NULL)
return (-1);
if (fstat(dirp->dd_fd, &stb) < 0)
if (fstat(dirp->dd_fd, &stb) == -1)
goto fail;
/*
@ -97,7 +97,7 @@ scandir(const char *dirname, struct dirent ***namelist,
if (nitems >= arraysz) {
struct dirent **nnames;
if (fstat(dirp->dd_fd, &stb) < 0)
if (fstat(dirp->dd_fd, &stb) == -1)
goto fail;
arraysz *= 2;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: siginterrupt.c,v 1.8 2015/10/23 04:39:24 guenther Exp $ */
/* $OpenBSD: siginterrupt.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -40,7 +40,7 @@ siginterrupt(int sig, int flag)
struct sigaction sa;
int ret;
if ((ret = WRAP(sigaction)(sig, NULL, &sa)) < 0)
if ((ret = WRAP(sigaction)(sig, NULL, &sa)) == -1)
return (ret);
if (flag) {
sigaddset(&__sigintr, sig);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: signal.c,v 1.10 2015/10/25 04:13:59 guenther Exp $ */
/* $OpenBSD: signal.c,v 1.11 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1985, 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -47,7 +47,7 @@ signal(int s, sig_t a)
sa.sa_flags = 0;
if (!sigismember(&__sigintr, s))
sa.sa_flags |= SA_RESTART;
if (WRAP(sigaction)(s, &sa, &osa) < 0)
if (WRAP(sigaction)(s, &sa, &osa) == -1)
return (SIG_ERR);
return (osa.sa_handler);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: time.c,v 1.7 2015/10/29 03:58:55 mmcc Exp $ */
/* $OpenBSD: time.c,v 1.8 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@ -36,7 +36,7 @@ time(time_t *t)
{
struct timeval tt;
if (gettimeofday(&tt, NULL) < 0)
if (gettimeofday(&tt, NULL) == -1)
return (-1);
if (t)
*t = (time_t)tt.tv_sec;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: times.c,v 1.8 2018/03/02 16:35:58 cheloha Exp $ */
/* $OpenBSD: times.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -44,11 +44,11 @@ times(struct tms *tp)
struct rusage ru;
struct timespec ts;
if (getrusage(RUSAGE_SELF, &ru) < 0)
if (getrusage(RUSAGE_SELF, &ru) == -1)
return ((clock_t)-1);
tp->tms_utime = CONVTCK(ru.ru_utime);
tp->tms_stime = CONVTCK(ru.ru_stime);
if (getrusage(RUSAGE_CHILDREN, &ru) < 0)
if (getrusage(RUSAGE_CHILDREN, &ru) == -1)
return ((clock_t)-1);
tp->tms_cutime = CONVTCK(ru.ru_utime);
tp->tms_cstime = CONVTCK(ru.ru_stime);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: gmon.c,v 1.30 2016/09/21 04:38:56 guenther Exp $ */
/* $OpenBSD: gmon.c,v 1.31 2019/06/28 13:32:41 deraadt Exp $ */
/*-
* Copyright (c) 1983, 1992, 1993
* The Regents of the University of California. All rights reserved.
@ -162,7 +162,7 @@ _mcleanup(void)
size = sizeof(clockinfo);
mib[0] = CTL_KERN;
mib[1] = KERN_CLOCKRATE;
if (sysctl(mib, 2, &clockinfo, &size, NULL, 0) < 0) {
if (sysctl(mib, 2, &clockinfo, &size, NULL, 0) == -1) {
/*
* Best guess
*/
@ -221,13 +221,13 @@ _mcleanup(void)
}
fd = open(proffile , O_CREAT|O_TRUNC|O_WRONLY, 0664);
if (fd < 0) {
if (fd == -1) {
perror( proffile );
return;
}
#ifdef DEBUG
log = open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664);
if (log < 0) {
if (log == -1) {
perror("mcount: gmon.log");
close(fd);
return;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: helper.c,v 1.17 2017/10/23 14:33:07 millert Exp $ */
/* $OpenBSD: helper.c,v 1.18 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org>
@ -67,7 +67,7 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
HASHInit(&ctx);
if ((fd = open(filename, O_RDONLY)) < 0)
if ((fd = open(filename, O_RDONLY)) == -1)
return (NULL);
if (len == 0) {
if (fstat(fd, &sb) == -1) {
@ -78,7 +78,7 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
}
len = sb.st_size;
}
if (off > 0 && lseek(fd, off, SEEK_SET) < 0) {
if (off > 0 && lseek(fd, off, SEEK_SET) == -1) {
save_errno = errno;
close(fd);
errno = save_errno;
@ -94,7 +94,7 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
save_errno = errno;
close(fd);
errno = save_errno;
return (nr < 0 ? NULL : HASHEnd(&ctx, buf));
return (nr == -1 ? NULL : HASHEnd(&ctx, buf));
}
DEF_WEAK(HASHFileChunk);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rune.c,v 1.7 2016/09/05 09:47:03 schwarze Exp $ */
/* $OpenBSD: rune.c,v 1.8 2019/06/28 13:32:41 deraadt Exp $ */
/* $NetBSD: rune.c,v 1.26 2004/05/09 11:26:33 kleink Exp $ */
/*-
@ -227,7 +227,7 @@ _Read_RuneMagi(FILE *fp)
int x;
uint32_t runetype_nranges, maplower_nranges, mapupper_nranges, var_len;
if (fstat(fileno(fp), &sb) < 0)
if (fstat(fileno(fp), &sb) == -1)
return NULL;
if (sb.st_size < sizeof(_FileRuneLocale))

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rcmdsh.c,v 1.19 2016/05/28 15:46:00 millert Exp $ */
/* $OpenBSD: rcmdsh.c,v 1.20 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2001, MagniComp
@ -89,13 +89,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
}
/* Get a socketpair we'll use for stdin and stdout. */
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) < 0) {
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) == -1) {
perror("rcmdsh: socketpair");
return(-1);
}
cpid = fork();
if (cpid < 0) {
if (cpid == -1) {
perror("rcmdsh: fork failed");
return(-1);
} else if (cpid == 0) {
@ -103,13 +103,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
* Child. We use sp[1] to be stdin/stdout, and close sp[0].
*/
(void) close(sp[0]);
if (dup2(sp[1], 0) < 0 || dup2(0, 1) < 0) {
if (dup2(sp[1], 0) == -1 || dup2(0, 1) == -1) {
perror("rcmdsh: dup2 failed");
_exit(255);
}
/* Fork again to lose parent. */
cpid = fork();
if (cpid < 0) {
if (cpid == -1) {
perror("rcmdsh: fork to lose parent failed");
_exit(255);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rresvport.c,v 1.11 2015/09/12 14:56:50 guenther Exp $ */
/* $OpenBSD: rresvport.c,v 1.12 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 1995, 1996, 1998 Theo de Raadt. All rights reserved.
* Copyright (c) 1983, 1993, 1994
@ -82,12 +82,12 @@ rresvport_af(int *alport, int af)
sa->sa_family = af;
s = socket(af, SOCK_STREAM, 0);
if (s < 0)
if (s == -1)
return (-1);
*portp = htons(*alport);
if (*alport < IPPORT_RESERVED - 1) {
if (bind(s, sa, sa->sa_len) >= 0)
if (bind(s, sa, sa->sa_len) != -1)
return (s);
if (errno != EADDRINUSE) {
(void)close(s);

View File

@ -131,11 +131,11 @@ again:
* user or root or if writeable by anyone but the owner, quit.
*/
cp = NULL;
if (lstat(pbuf, &sbuf) < 0)
if (lstat(pbuf, &sbuf) == -1)
cp = ".rhosts lstat failed";
else if (!S_ISREG(sbuf.st_mode))
cp = ".rhosts not regular file";
else if (fstat(fileno(hostf), &sbuf) < 0)
else if (fstat(fileno(hostf), &sbuf) == -1)
cp = ".rhosts fstat failed";
else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid)
cp = "bad .rhosts owner";

View File

@ -1,4 +1,4 @@
/* $OpenBSD: auth_unix.c,v 1.26 2015/11/01 03:45:29 guenther Exp $ */
/* $OpenBSD: auth_unix.c,v 1.27 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -194,7 +194,7 @@ authunix_create_default(void)
machname[MAX_MACHINE_NAME] = 0;
uid = geteuid();
gid = getegid();
if ((len = getgroups(NGRPS, gids)) < 0)
if ((len = getgroups(NGRPS, gids)) == -1)
return (NULL);
if (len > maxgrplist)
len = maxgrplist;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bindresvport.c,v 1.18 2015/09/14 11:01:47 guenther Exp $ */
/* $OpenBSD: bindresvport.c,v 1.19 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright 1996, Jason Downs. All rights reserved.
@ -92,12 +92,12 @@ bindresvport_sa(int sd, struct sockaddr *sa)
socklen_t oldlen = sizeof(old);
error = getsockopt(sd, proto, portrange, &old, &oldlen);
if (error < 0)
if (error == -1)
return (error);
error = setsockopt(sd, proto, portrange, &portlow,
sizeof(portlow));
if (error < 0)
if (error == -1)
return (error);
}
@ -108,14 +108,14 @@ bindresvport_sa(int sd, struct sockaddr *sa)
if (error) {
if (setsockopt(sd, proto, portrange, &old,
sizeof(old)) < 0)
sizeof(old)) == -1)
errno = saved_errno;
return (error);
}
if (sa != (struct sockaddr *)&myaddr) {
/* Hmm, what did the kernel assign... */
if (getsockname(sd, sa, &salen) < 0)
if (getsockname(sd, sa, &salen) == -1)
errno = saved_errno;
return (error);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: clnt_tcp.c,v 1.32 2018/01/06 15:37:36 cheloha Exp $ */
/* $OpenBSD: clnt_tcp.c,v 1.33 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -148,9 +148,9 @@ clnttcp_create(struct sockaddr_in *raddr, u_long prog, u_long vers, int *sockp,
if (*sockp < 0) {
*sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
(void)bindresvport(*sockp, NULL);
if ((*sockp < 0)
if ((*sockp == -1)
|| (connect(*sockp, (struct sockaddr *)raddr,
sizeof(*raddr)) < 0)) {
sizeof(*raddr)) == -1)) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
if (*sockp != -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: clnt_udp.c,v 1.35 2018/01/06 15:37:36 cheloha Exp $ */
/* $OpenBSD: clnt_udp.c,v 1.36 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -158,7 +158,7 @@ clntudp_bufcreate(struct sockaddr_in *raddr, u_long program, u_long version,
if (*sockp < 0) {
*sockp = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK,
IPPROTO_UDP);
if (*sockp < 0) {
if (*sockp == -1) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
@ -299,8 +299,8 @@ send_again:
inlen = recvfrom(cu->cu_sock, cu->cu_inbuf,
(int) cu->cu_recvsz, 0,
(struct sockaddr *)&from, &fromlen);
} while (inlen < 0 && errno == EINTR);
if (inlen < 0) {
} while (inlen == -1 && errno == EINTR);
if (inlen == -1) {
if (errno == EWOULDBLOCK)
continue;
cu->cu_error.re_errno = errno;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pmap_rmt.c,v 1.34 2015/12/28 22:08:18 mmcc Exp $ */
/* $OpenBSD: pmap_rmt.c,v 1.35 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -238,12 +238,12 @@ clnt_broadcast(u_long prog, /* program number */
* initialization: create a socket, a broadcast address, and
* preserialize the arguments into a send buffer.
*/
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
stat = RPC_CANTSEND;
goto done_broad;
}
#ifdef SO_BROADCAST
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) {
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) == -1) {
stat = RPC_CANTSEND;
goto done_broad;
}
@ -338,7 +338,7 @@ clnt_broadcast(u_long prog, /* program number */
fromlen = sizeof(struct sockaddr);
inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0,
(struct sockaddr *)&raddr, &fromlen);
if (inlen < 0) {
if (inlen == -1) {
if (errno == EINTR)
goto try_again;
stat = RPC_CANTRECV;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: svc_tcp.c,v 1.39 2017/12/14 18:56:22 jca Exp $ */
/* $OpenBSD: svc_tcp.c,v 1.40 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -134,18 +134,18 @@ svctcp_create(int sock, u_int sendsize, u_int recvsize)
socklen_t len = sizeof(struct sockaddr_in);
if (sock == RPC_ANYSOCK) {
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
return (NULL);
madesock = TRUE;
}
memset(&addr, 0, sizeof (addr));
addr.sin_len = sizeof(struct sockaddr_in);
addr.sin_family = AF_INET;
if (bindresvport(sock, &addr)) {
if (bindresvport(sock, &addr) == -1) {
addr.sin_port = 0;
(void)bind(sock, (struct sockaddr *)&addr, len);
}
if ((getsockname(sock, (struct sockaddr *)&addr, &len) != 0) ||
if ((getsockname(sock, (struct sockaddr *)&addr, &len) == -1) ||
(listen(sock, 2) != 0)) {
if (madesock)
(void)close(sock);
@ -241,7 +241,7 @@ rendezvous_request(SVCXPRT *xprt, struct rpc_msg *ignored)
again:
len = sizeof(struct sockaddr_in);
if ((sock = accept(xprt->xp_sock, (struct sockaddr *)&addr,
&len)) < 0) {
&len)) == -1) {
if (errno == EINTR || errno == EWOULDBLOCK ||
errno == ECONNABORTED)
goto again;
@ -254,8 +254,9 @@ rendezvous_request(SVCXPRT *xprt, struct rpc_msg *ignored)
socklen_t optsize = sizeof(opts);
int i;
if (!getsockopt(sock, IPPROTO_IP, IP_OPTIONS, (char *)&opts,
&optsize) && optsize != 0) {
if (getsockopt(sock, IPPROTO_IP, IP_OPTIONS,
(char *)&opts, &optsize) == 0 &&
optsize != 0) {
for (i = 0; (char *)&opts.ipopt_list[i] - (char *)&opts <
optsize; ) {
u_char c = (u_char)opts.ipopt_list[i];
@ -377,7 +378,7 @@ writetcp(SVCXPRT *xprt, caddr_t buf, int len)
int i, cnt;
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
if ((i = write(xprt->xp_sock, buf, cnt)) < 0) {
if ((i = write(xprt->xp_sock, buf, cnt)) == -1) {
((struct tcp_conn *)(xprt->xp_p1))->strm_stat =
XPRT_DIED;
return (-1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: svc_udp.c,v 1.25 2015/11/01 03:45:29 guenther Exp $ */
/* $OpenBSD: svc_udp.c,v 1.26 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -104,7 +104,7 @@ svcudp_bufcreate(int sock, u_int sendsz, u_int recvsz)
socklen_t len = sizeof(struct sockaddr_in);
if (sock == RPC_ANYSOCK) {
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
return (NULL);
madesock = TRUE;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: xdr_stdio.c,v 1.14 2015/11/01 03:45:29 guenther Exp $ */
/* $OpenBSD: xdr_stdio.c,v 1.15 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -144,7 +144,7 @@ static bool_t
xdrstdio_setpos(XDR *xdrs, u_int pos)
{
return ((fseek((FILE *)xdrs->x_private, (long)pos, SEEK_SET) < 0) ?
return ((fseek((FILE *)xdrs->x_private, (long)pos, SEEK_SET) == -1) ?
FALSE : TRUE);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fdopen.c,v 1.9 2016/03/20 00:01:21 krw Exp $ */
/* $OpenBSD: fdopen.c,v 1.10 2019/06/28 13:32:42 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -55,7 +55,7 @@ fdopen(int fd, const char *mode)
return (NULL);
/* Make sure the mode the user wants is a subset of the actual mode. */
if ((fdflags = fcntl(fd, F_GETFL)) < 0)
if ((fdflags = fcntl(fd, F_GETFL)) == -1)
return (NULL);
tmp = fdflags & O_ACCMODE;
if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fopen.c,v 1.9 2016/09/21 04:38:56 guenther Exp $ */
/* $OpenBSD: fopen.c,v 1.10 2019/06/28 13:32:42 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -51,7 +51,7 @@ fopen(const char *file, const char *mode)
return (NULL);
if ((fp = __sfp()) == NULL)
return (NULL);
if ((f = open(file, oflags, DEFFILEMODE)) < 0) {
if ((f = open(file, oflags, DEFFILEMODE)) == -1) {
fp->_flags = 0; /* release */
return (NULL);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fseek.c,v 1.12 2015/08/31 02:53:57 guenther Exp $ */
/* $OpenBSD: fseek.c,v 1.13 2019/06/28 13:32:42 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -127,7 +127,7 @@ fseeko(FILE *fp, off_t offset, int whence)
goto dumb;
if ((fp->_flags & __SOPT) == 0) {
if (seekfn != __sseek ||
fp->_file < 0 || fstat(fp->_file, &st) ||
fp->_file < 0 || fstat(fp->_file, &st) == -1 ||
(st.st_mode & S_IFMT) != S_IFREG) {
fp->_flags |= __SNPT;
goto dumb;
@ -143,7 +143,7 @@ fseeko(FILE *fp, off_t offset, int whence)
if (whence == SEEK_SET)
target = offset;
else {
if (fstat(fp->_file, &st))
if (fstat(fp->_file, &st) == -1)
goto dumb;
target = st.st_size + offset;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: makebuf.c,v 1.9 2015/01/13 07:18:21 guenther Exp $ */
/* $OpenBSD: makebuf.c,v 1.10 2019/06/28 13:32:42 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -81,7 +81,7 @@ __swhatbuf(FILE *fp, size_t *bufsize, int *couldbetty)
{
struct stat st;
if (fp->_file < 0 || fstat(fp->_file, &st) < 0) {
if (fp->_file < 0 || fstat(fp->_file, &st) == -1) {
*couldbetty = 0;
*bufsize = BUFSIZ;
return (__SNPT);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: remove.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */
/* $OpenBSD: remove.c,v 1.9 2019/06/28 13:32:42 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -41,7 +41,7 @@ remove(const char *file)
{
struct stat st;
if (lstat(file, &st) < 0)
if (lstat(file, &st) == -1)
return (-1);
if (S_ISDIR(st.st_mode))
return (rmdir(file));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: malloc.c,v 1.261 2019/05/23 06:43:18 otto Exp $ */
/* $OpenBSD: malloc.c,v 1.262 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@ -897,7 +897,7 @@ omalloc_make_chunks(struct dir_info *d, int bits, int listnum)
return NULL;
/* memory protect the page allocated in the malloc(0) case */
if (bits == 0 && mprotect(pp, MALLOC_PAGESIZE, PROT_NONE) < 0)
if (bits == 0 && mprotect(pp, MALLOC_PAGESIZE, PROT_NONE) == -1)
goto err;
bp = alloc_chunk_info(d, bits);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tcgetpgrp.c,v 1.7 2014/12/16 03:32:21 millert Exp $ */
/* $OpenBSD: tcgetpgrp.c,v 1.8 2019/06/28 13:32:42 deraadt Exp $ */
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -36,7 +36,7 @@ tcgetpgrp(int fd)
{
int s;
if (ioctl(fd, TIOCGPGRP, &s) < 0)
if (ioctl(fd, TIOCGPGRP, &s) == -1)
return (-1);
return (s);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tcgetsid.c,v 1.3 2013/12/17 22:12:07 millert Exp $ */
/* $OpenBSD: tcgetsid.c,v 1.4 2019/06/28 13:32:42 deraadt Exp $ */
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -36,7 +36,7 @@ tcgetsid(int fd)
{
int s;
if (ioctl(fd, TIOCGSID, &s) < 0)
if (ioctl(fd, TIOCGSID, &s) == -1)
return (-1);
return (s);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: localtime.c,v 1.60 2019/05/12 12:49:52 schwarze Exp $ */
/* $OpenBSD: localtime.c,v 1.61 2019/06/28 13:32:42 deraadt Exp $ */
/*
** This file is in the public domain, so clarified as of
** 1996-06-05 by Arthur David Olson.
@ -342,7 +342,7 @@ tzload(const char *name, struct state *sp, int doextend)
goto oops;
nread = read(fid, up->buf, sizeof up->buf);
if (close(fid) < 0 || nread <= 0)
if (close(fid) == -1 || nread <= 0)
goto oops;
for (stored = 4; stored <= 8; stored *= 2) {
int ttisstdcnt;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: readline.c,v 1.27 2016/05/31 16:12:00 schwarze Exp $ */
/* $OpenBSD: readline.c,v 1.28 2019/06/28 13:32:42 deraadt Exp $ */
/* $NetBSD: readline.c,v 1.91 2010/08/28 15:44:59 christos Exp $ */
/*-
@ -1265,7 +1265,7 @@ history_truncate_file (const char *filename, int nlines)
if (nlines <= 0 || count == 0)
break;
count--;
if (fseeko(tp, (off_t)sizeof(buf) * count, SEEK_SET) < 0) {
if (fseeko(tp, (off_t)sizeof(buf) * count, SEEK_SET) == -1) {
ret = errno;
break;
}
@ -2092,16 +2092,16 @@ _rl_event_read_char(EditLine *el, wchar_t *wc)
(*rl_event_hook)();
#if defined(FIONREAD)
if (ioctl(el->el_infd, FIONREAD, &n) < 0)
if (ioctl(el->el_infd, FIONREAD, &n) == -1)
return -1;
if (n)
num_read = read(el->el_infd, &ch, 1);
else
num_read = 0;
#elif defined(F_SETFL) && defined(O_NDELAY)
if ((n = fcntl(el->el_infd, F_GETFL)) < 0)
if ((n = fcntl(el->el_infd, F_GETFL)) == -1)
return -1;
if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0)
if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) == -1)
return -1;
num_read = read(el->el_infd, &ch, 1);
if (fcntl(el->el_infd, F_SETFL, n))

View File

@ -1,4 +1,4 @@
/* $OpenBSD: evutil.c,v 1.10 2016/03/20 00:01:22 krw Exp $ */
/* $OpenBSD: evutil.c,v 1.11 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2007 Niels Provos <provos@citi.umich.edu>
@ -54,7 +54,7 @@ evutil_make_socket_nonblocking(int fd)
{
int flags;
if ((flags = fcntl(fd, F_GETFL)) < 0) {
if ((flags = fcntl(fd, F_GETFL)) == -1) {
event_warn("fcntl(%d, F_GETFL)", fd);
return -1;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fuse.c,v 1.50 2018/11/16 02:16:17 tedu Exp $ */
/* $OpenBSD: fuse.c,v 1.51 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@ -121,7 +121,7 @@ ifuse_try_unmount(struct fuse *f)
/* unmount in another thread so fuse_loop() doesn't deadlock */
child = fork();
if (child < 0) {
if (child == -1) {
DPERROR(__func__);
return;
}
@ -218,7 +218,7 @@ fuse_loop(struct fuse *fuse)
ioexch.fbxch_data = fbuf.fb_dat;
if (ioctl(fuse->fc->fd, FIOCGETFBDAT,
&ioexch)) {
&ioexch) == -1) {
free(fbuf.fb_dat);
return (-1);
}
@ -249,7 +249,7 @@ fuse_loop(struct fuse *fuse)
ioexch.fbxch_len = fbuf.fb_len;
ioexch.fbxch_data = fbuf.fb_dat;
if (ioctl(fuse->fc->fd, FIOCSETFBDAT, &ioexch)) {
if (ioctl(fuse->fc->fd, FIOCSETFBDAT, &ioexch) == -1) {
free(fbuf.fb_dat);
return (-1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: keynote-sign.c,v 1.18 2015/11/19 07:00:58 guenther Exp $ */
/* $OpenBSD: keynote-sign.c,v 1.19 2019/06/28 13:32:42 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
*
@ -104,13 +104,13 @@ keynote_sign(int argc, char *argv[])
/* Read assertion */
fd = open(argv[2 + flg], O_RDONLY, 0);
if (fd < 0)
if (fd == -1)
{
perror(argv[2 + flg]);
exit(1);
}
if (fstat(fd, &sb) < 0)
if (fstat(fd, &sb) == -1)
{
perror("fstat()");
exit(1);
@ -130,7 +130,7 @@ keynote_sign(int argc, char *argv[])
exit(1);
}
if (read(fd, buf, buflen - 1) < 0)
if (read(fd, buf, buflen - 1) == -1)
{
perror("read()");
exit(1);
@ -140,13 +140,13 @@ keynote_sign(int argc, char *argv[])
/* Read private key file */
fd = open(argv[3 + flg], O_RDONLY, 0);
if (fd < 0)
if (fd == -1)
{
perror(argv[3 + flg]);
exit(1);
}
if (fstat(fd, &sb) < 0)
if (fstat(fd, &sb) == -1)
{
perror("fstat()");
exit(1);
@ -165,7 +165,7 @@ keynote_sign(int argc, char *argv[])
exit(1);
}
if (read(fd, buf2, sb.st_size) < 0)
if (read(fd, buf2, sb.st_size) == -1)
{
perror("read()");
exit(1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: keynote-sigver.c,v 1.16 2015/11/19 02:35:24 mmcc Exp $ */
/* $OpenBSD: keynote-sigver.c,v 1.17 2019/06/28 13:32:42 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
*
@ -57,13 +57,13 @@ keynote_sigver(int argc, char *argv[])
/* Open and read assertion file */
fd = open(argv[1], O_RDONLY, 0);
if (fd < 0)
if (fd == -1)
{
perror(argv[1]);
exit(1);
}
if (fstat(fd, &sb) < 0)
if (fstat(fd, &sb) == -1)
{
perror("fstat()");
exit(1);
@ -82,7 +82,7 @@ keynote_sigver(int argc, char *argv[])
exit(1);
}
if (read(fd, buf, sb.st_size) < 0)
if (read(fd, buf, sb.st_size) == -1)
{
perror("read()");
exit(1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: keynote-verify.c,v 1.17 2015/11/19 05:20:19 mmcc Exp $ */
/* $OpenBSD: keynote-verify.c,v 1.18 2019/06/28 13:32:42 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
*
@ -102,13 +102,13 @@ keynote_verify(int argc, char *argv[])
case 'k':
sk = 1;
if ((fd = open(optarg, O_RDONLY, 0)) < 0)
if ((fd = open(optarg, O_RDONLY, 0)) == -1)
{
perror(optarg);
exit(1);
}
if (fstat(fd, &sb) < 0)
if (fstat(fd, &sb) == -1)
{
perror("fstat()");
exit(1);
@ -127,7 +127,7 @@ keynote_verify(int argc, char *argv[])
}
i = read(fd, buf, sb.st_size);
if (i < 0)
if (i == -1)
{
perror("read()");
exit(1);
@ -222,13 +222,13 @@ keynote_verify(int argc, char *argv[])
break;
case 'l':
if ((fd = open(optarg, O_RDONLY, 0)) < 0)
if ((fd = open(optarg, O_RDONLY, 0)) == -1)
{
perror(optarg);
exit(1);
}
if (fstat(fd, &sb) < 0)
if (fstat(fd, &sb) == -1)
{
perror("fstat()");
exit(1);
@ -247,7 +247,7 @@ keynote_verify(int argc, char *argv[])
}
i = read(fd, buf, sb.st_size);
if (i < 0)
if (i == -1)
{
perror("read()");
exit(1);
@ -306,13 +306,13 @@ keynote_verify(int argc, char *argv[])
while (argc--)
{
if ((fd = open(argv[argc], O_RDONLY, 0)) < 0)
if ((fd = open(argv[argc], O_RDONLY, 0)) == -1)
{
perror(argv[argc]);
exit(1);
}
if (fstat(fd, &sb) < 0)
if (fstat(fd, &sb) == -1)
{
perror("fstat()");
exit(1);
@ -331,7 +331,7 @@ keynote_verify(int argc, char *argv[])
}
i = read(fd, buf, sb.st_size);
if (i < 0)
if (i == -1)
{
perror("read()");
exit(1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kvm.c,v 1.65 2018/05/03 16:42:07 zhuk Exp $ */
/* $OpenBSD: kvm.c,v 1.66 2019/06/28 13:32:42 deraadt Exp $ */
/* $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $ */
/*-
@ -219,11 +219,11 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, const char *sf,
if (mf == 0)
mf = _PATH_MEM;
if ((kd->pmfd = open(mf, flag)) < 0) {
if ((kd->pmfd = open(mf, flag)) == -1) {
_kvm_syserr(kd, kd->program, "%s", mf);
goto failed;
}
if (fstat(kd->pmfd, &st) < 0) {
if (fstat(kd->pmfd, &st) == -1) {
_kvm_syserr(kd, kd->program, "%s", mf);
goto failed;
}
@ -239,12 +239,12 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, const char *sf,
"%s: not physical memory device", mf);
goto failed;
}
if ((kd->vmfd = open(_PATH_KMEM, flag)) < 0) {
if ((kd->vmfd = open(_PATH_KMEM, flag)) == -1) {
_kvm_syserr(kd, kd->program, "%s", _PATH_KMEM);
goto failed;
}
kd->alive = 1;
if (sf != NULL && (kd->swfd = open(sf, flag)) < 0) {
if (sf != NULL && (kd->swfd = open(sf, flag)) == -1) {
_kvm_syserr(kd, kd->program, "%s", sf);
goto failed;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kvm_proc.c,v 1.59 2018/05/03 15:47:41 zhuk Exp $ */
/* $OpenBSD: kvm_proc.c,v 1.60 2019/06/28 13:32:42 deraadt Exp $ */
/* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -491,7 +491,7 @@ again:
mib[3] = isenv ? KERN_PROC_ENV : KERN_PROC_ARGV;
len = orglen;
ret = (sysctl(mib, 4, *pargbuf, &len, NULL, 0) < 0);
ret = (sysctl(mib, 4, *pargbuf, &len, NULL, 0) == -1);
if (ret && errno == ENOMEM) {
buf = _kvm_reallocarray(kd, *pargbuf, orglen, 2);
if (buf == NULL)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ossaudio.c,v 1.19 2018/10/26 14:46:05 miko Exp $ */
/* $OpenBSD: ossaudio.c,v 1.20 2019/06/28 13:32:42 deraadt Exp $ */
/* $NetBSD: ossaudio.c,v 1.14 2001/05/10 01:53:48 augustss Exp $ */
/*-
@ -194,7 +194,7 @@ getdevinfo(int fd)
}
for(i = 0; i < MAX_MIXER_DEVS; i++) {
mi.index = i;
if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) < 0)
if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) == -1)
break;
switch(mi.type) {
case AUDIO_MIXER_VALUE:
@ -215,12 +215,12 @@ getdevinfo(int fd)
}
for(i = 0; i < MAX_MIXER_DEVS; i++) {
mi.index = i;
if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) < 0)
if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) == -1)
break;
if (strcmp(mi.label.name, AudioNsource) != 0)
continue;
cl.index = mi.mixer_class;
if (ioctl(fd, AUDIO_MIXER_DEVINFO, &cl) < 0)
if (ioctl(fd, AUDIO_MIXER_DEVINFO, &cl) == -1)
break;
if ((cl.type != AUDIO_MIXER_CLASS) ||
(strcmp(cl.label.name, AudioCrecord) != 0))
@ -274,7 +274,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp)
case SOUND_MIXER_INFO:
case SOUND_OLD_MIXER_INFO:
error = ioctl(fd, AUDIO_GETDEV, &adev);
if (error)
if (error == -1)
return (error);
omi = argp;
if (com == SOUND_MIXER_INFO)
@ -289,7 +289,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp)
if (di->caps & SOUND_CAP_EXCL_INPUT) {
mc.type = AUDIO_MIXER_ENUM;
retval = ioctl(fd, AUDIO_MIXER_READ, &mc);
if (retval < 0)
if (retval == -1)
return retval;
e = opaque_to_enum(di, NULL, mc.un.ord);
if (e >= 0)
@ -297,7 +297,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp)
} else {
mc.type = AUDIO_MIXER_SET;
retval = ioctl(fd, AUDIO_MIXER_READ, &mc);
if (retval < 0)
if (retval == -1)
return retval;
e = opaque_to_enum(di, NULL, mc.un.mask);
if (e >= 0)
@ -354,7 +354,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp)
doread:
mc.un.value.num_channels = di->stereomask & (1<<n) ? 2 : 1;
retval = ioctl(fd, AUDIO_MIXER_READ, &mc);
if (retval < 0)
if (retval == -1)
return retval;
if (mc.type != AUDIO_MIXER_VALUE)
return EINVAL;
@ -387,7 +387,7 @@ mixer_ioctl(int fd, unsigned long com, void *argp)
mc.un.value.level[AUDIO_MIXER_LEVEL_MONO] = (l+r)/2;
}
retval = ioctl(fd, AUDIO_MIXER_WRITE, &mc);
if (retval < 0)
if (retval == -1)
return retval;
if (MIXER_WRITE(SOUND_MIXER_FIRST) <= com &&
com < MIXER_WRITE(SOUND_MIXER_NRDEVICES))

View File

@ -1,4 +1,4 @@
/* $OpenBSD: inet.c,v 1.24 2015/12/22 19:51:04 mmcc Exp $ */
/* $OpenBSD: inet.c,v 1.25 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 1994, 1995, 1996, 1997, 1998
@ -161,7 +161,7 @@ pcap_lookupdev(errbuf)
static char device[sizeof(ifrp->ifr_name) + 1];
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
if (fd == -1) {
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
pcap_strerror(errno));
return (NULL);
@ -170,7 +170,7 @@ pcap_lookupdev(errbuf)
ifc.ifc_buf = (caddr_t)ibuf;
memset((char *)ibuf, 0, sizeof(ibuf));
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 ||
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) == -1 ||
ifc.ifc_len < sizeof(struct ifreq)) {
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFCONF: %s",
pcap_strerror(errno));
@ -202,7 +202,7 @@ pcap_lookupdev(errbuf)
*/
(void)strlcpy(ifr.ifr_name, ifrp->ifr_name,
sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) {
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) == -1) {
if (errno == ENXIO)
continue;
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
@ -247,7 +247,7 @@ pcap_lookupnet(const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp,
struct ifreq ifr;
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
if (fd == -1) {
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
pcap_strerror(errno));
return (-1);
@ -258,7 +258,7 @@ pcap_lookupnet(const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp,
ifr.ifr_addr.sa_family = AF_INET;
#endif
(void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) {
if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) == -1) {
if (errno == EADDRNOTAVAIL) {
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
"%s: no IPv4 address assigned", device);
@ -272,7 +272,7 @@ pcap_lookupnet(const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp,
}
sin = (struct sockaddr_in *)&ifr.ifr_addr;
*netp = sin->sin_addr.s_addr;
if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) {
if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) == -1) {
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno));
(void)close(fd);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pcap-bpf.c,v 1.36 2018/04/05 03:47:27 lteo Exp $ */
/* $OpenBSD: pcap-bpf.c,v 1.37 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1998
@ -55,7 +55,7 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps)
{
struct bpf_stat s;
if (ioctl(p->fd, BIOCGSTATS, (caddr_t)&s) < 0) {
if (ioctl(p->fd, BIOCGSTATS, (caddr_t)&s) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGSTATS: %s",
pcap_strerror(errno));
return (PCAP_ERROR);
@ -90,7 +90,7 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
cc = p->cc;
if (p->cc == 0) {
cc = read(p->fd, (char *)p->buffer, p->bufsize);
if (cc < 0) {
if (cc == -1) {
/* Don't choke when we get ptraced */
switch (errno) {
@ -246,7 +246,7 @@ get_dlt_list(int fd, int v, struct bpf_dltlist *bdlp, char *ebuf)
return (PCAP_ERROR);
}
if (ioctl(fd, BIOCGDLTLIST, (caddr_t)bdlp) < 0) {
if (ioctl(fd, BIOCGDLTLIST, (caddr_t)bdlp) == -1) {
(void)snprintf(ebuf, PCAP_ERRBUF_SIZE,
"BIOCGDLTLIST: %s", pcap_strerror(errno));
free(bdlp->bfl_list);
@ -321,7 +321,7 @@ pcap_cleanup_bpf(pcap_t *p)
memset(&req, 0, sizeof(req));
(void)strlcpy(req.ifm_name, p->opt.source,
sizeof(req.ifm_name));
if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) {
if (ioctl(sock, SIOCGIFMEDIA, &req) == -1) {
fprintf(stderr,
"Can't restore interface flags "
"(SIOCGIFMEDIA failed: %s).\n"
@ -437,7 +437,7 @@ pcap_activate(pcap_t *p)
p->fd = fd;
if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0) {
if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCVERSION: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
@ -470,7 +470,7 @@ pcap_activate(pcap_t *p)
* A buffer size was explicitly specified; use it.
*/
if (ioctl(fd, BIOCSBLEN,
(caddr_t)&p->opt.buffer_size) < 0) {
(caddr_t)&p->opt.buffer_size) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCSBLEN: %s: %s", p->opt.source,
pcap_strerror(errno));
@ -483,12 +483,12 @@ pcap_activate(pcap_t *p)
* Now bind to the device.
*/
(void)strlcpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name));
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) == -1) {
status = check_setif_failure(p, errno);
goto bad;
}
/* Get the data link layer type. */
if (ioctl(fd, BIOCGDLT, (caddr_t)&v) < 0) {
if (ioctl(fd, BIOCGDLT, (caddr_t)&v) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGDLT: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
@ -557,7 +557,7 @@ pcap_activate(pcap_t *p)
struct timeval to;
to.tv_sec = p->md.timeout / 1000;
to.tv_usec = (p->md.timeout * 1000) % 1000000;
if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) < 0) {
if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCSRTIMEOUT: %s", pcap_strerror(errno));
status = PCAP_ERROR;
@ -567,7 +567,7 @@ pcap_activate(pcap_t *p)
if (p->opt.immediate) {
v = 1;
if (ioctl(p->fd, BIOCIMMEDIATE, &v) < 0) {
if (ioctl(p->fd, BIOCIMMEDIATE, &v) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCIMMEDIATE: %s", pcap_strerror(errno));
status = PCAP_ERROR;
@ -577,14 +577,14 @@ pcap_activate(pcap_t *p)
if (p->opt.promisc) {
/* set promiscuous mode, just warn if it fails */
if (ioctl(p->fd, BIOCPROMISC, NULL) < 0) {
if (ioctl(p->fd, BIOCPROMISC, NULL) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCPROMISC: %s",
pcap_strerror(errno));
status = PCAP_WARNING_PROMISC_NOTSUP;
}
}
if (ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) {
if (ioctl(fd, BIOCGBLEN, (caddr_t)&v) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGBLEN: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
@ -645,7 +645,7 @@ monitor_mode(pcap_t *p, int set)
/*
* Find out how many media types we have.
*/
if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) {
if (ioctl(sock, SIOCGIFMEDIA, &req) == -1) {
/*
* Can't get the media types.
*/
@ -693,7 +693,7 @@ monitor_mode(pcap_t *p, int set)
return (PCAP_ERROR);
}
req.ifm_ulist = media_list;
if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) {
if (ioctl(sock, SIOCGIFMEDIA, &req) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFMEDIA: %s",
pcap_strerror(errno));
free(media_list);
@ -931,7 +931,7 @@ pcap_setfilter(pcap_t *p, struct bpf_program *fp)
}
memcpy(p->fcode.bf_insns, fp->bf_insns,
fp->bf_len * sizeof(*fp->bf_insns));
} else if (ioctl(p->fd, BIOCSETF, (caddr_t)fp) < 0) {
} else if (ioctl(p->fd, BIOCSETF, (caddr_t)fp) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETF: %s",
pcap_strerror(errno));
return (-1);
@ -958,7 +958,7 @@ pcap_setdirection(pcap_t *p, pcap_direction_t d)
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Invalid direction");
return (-1);
}
if (ioctl(p->fd, BIOCSDIRFILT, &dirfilt) < 0) {
if (ioctl(p->fd, BIOCSDIRFILT, &dirfilt) == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSDIRFILT: %s",
pcap_strerror(errno));
return (-1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sio_sun.c,v 1.27 2018/09/19 14:01:52 miko Exp $ */
/* $OpenBSD: sio_sun.c,v 1.28 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@ -79,12 +79,12 @@ sio_sun_adjpar(struct sio_sun_hdl *hdl, struct audio_swpar *ap)
{
if (hdl->sio.eof)
return 0;
if (ioctl(hdl->fd, AUDIO_SETPAR, ap)) {
if (ioctl(hdl->fd, AUDIO_SETPAR, ap) == -1) {
DPERROR("AUDIO_SETPAR");
hdl->sio.eof = 1;
return 0;
}
if (ioctl(hdl->fd, AUDIO_GETPAR, ap)) {
if (ioctl(hdl->fd, AUDIO_GETPAR, ap) == -1) {
DPERROR("AUDIO_GETPAR");
hdl->sio.eof = 1;
return 0;
@ -163,7 +163,7 @@ sio_sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
unsigned int enc_map = 0, rchan_map = 0, pchan_map = 0, rate_map;
unsigned int i, j, conf;
if (ioctl(hdl->fd, AUDIO_GETPAR, &savepar)) {
if (ioctl(hdl->fd, AUDIO_GETPAR, &savepar) == -1) {
DPERROR("AUDIO_GETPAR");
hdl->sio.eof = 1;
return 0;
@ -256,7 +256,7 @@ sio_sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
}
cap->nconf = nconf;
if (ioctl(hdl->fd, AUDIO_SETPAR, &savepar)) {
if (ioctl(hdl->fd, AUDIO_SETPAR, &savepar) == -1) {
DPERROR("AUDIO_SETPAR");
hdl->sio.eof = 1;
return 0;
@ -298,7 +298,7 @@ sio_sun_getfd(const char *str, unsigned int mode, int nbio)
flags = O_RDWR;
else
flags = (mode & SIO_PLAY) ? O_WRONLY : O_RDONLY;
while ((fd = open(path, flags | O_NONBLOCK | O_CLOEXEC)) < 0) {
while ((fd = open(path, flags | O_NONBLOCK | O_CLOEXEC)) == -1) {
if (errno == EINTR)
continue;
DPERROR(path);
@ -323,7 +323,7 @@ sio_sun_fdopen(int fd, unsigned int mode, int nbio)
/*
* pause the device
*/
if (ioctl(fd, AUDIO_STOP) < 0) {
if (ioctl(fd, AUDIO_STOP) == -1) {
DPERROR("AUDIO_STOP");
free(hdl);
return NULL;
@ -340,12 +340,12 @@ _sio_sun_open(const char *str, unsigned int mode, int nbio)
int fd;
fd = sio_sun_getfd(str, mode, nbio);
if (fd < 0)
if (fd == -1)
return NULL;
hdl = sio_sun_fdopen(fd, mode, nbio);
if (hdl != NULL)
return hdl;
while (close(fd) < 0 && errno == EINTR)
while (close(fd) == -1 && errno == EINTR)
; /* retry */
return NULL;
}
@ -355,7 +355,7 @@ sio_sun_close(struct sio_hdl *sh)
{
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
while (close(hdl->fd) < 0 && errno == EINTR)
while (close(hdl->fd) == -1 && errno == EINTR)
; /* retry */
free(hdl);
}
@ -384,7 +384,7 @@ sio_sun_start(struct sio_hdl *sh)
/*
* no play buffers to fill, start now!
*/
if (ioctl(hdl->fd, AUDIO_START) < 0) {
if (ioctl(hdl->fd, AUDIO_START) == -1) {
DPERROR("AUDIO_START");
hdl->sio.eof = 1;
return 0;
@ -403,7 +403,7 @@ sio_sun_stop(struct sio_hdl *sh)
hdl->filling = 0;
return 1;
}
if (ioctl(hdl->fd, AUDIO_STOP) < 0) {
if (ioctl(hdl->fd, AUDIO_STOP) == -1) {
DPERROR("AUDIO_STOP");
hdl->sio.eof = 1;
return 0;
@ -438,7 +438,7 @@ sio_sun_setpar(struct sio_hdl *sh, struct sio_par *par)
ap.round = par->appbufsz / 2;
ap.nblks = 2;
}
if (ioctl(hdl->fd, AUDIO_SETPAR, &ap) < 0) {
if (ioctl(hdl->fd, AUDIO_SETPAR, &ap) == -1) {
DPERROR("AUDIO_SETPAR");
hdl->sio.eof = 1;
return 0;
@ -452,7 +452,7 @@ sio_sun_getpar(struct sio_hdl *sh, struct sio_par *par)
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
struct audio_swpar ap;
if (ioctl(hdl->fd, AUDIO_GETPAR, &ap) < 0) {
if (ioctl(hdl->fd, AUDIO_GETPAR, &ap) == -1) {
DPERROR("AUDIO_GETPAR");
hdl->sio.eof = 1;
return 0;
@ -477,7 +477,7 @@ sio_sun_read(struct sio_hdl *sh, void *buf, size_t len)
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
ssize_t n;
while ((n = read(hdl->fd, buf, len)) < 0) {
while ((n = read(hdl->fd, buf, len)) == -1) {
if (errno == EINTR)
continue;
if (errno != EAGAIN) {
@ -502,7 +502,7 @@ sio_sun_write(struct sio_hdl *sh, const void *buf, size_t len)
ssize_t n, todo;
todo = len;
while ((n = write(hdl->fd, data, todo)) < 0) {
while ((n = write(hdl->fd, data, todo)) == -1) {
if (errno == EINTR)
continue;
if (errno != EAGAIN) {
@ -530,7 +530,7 @@ sio_sun_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
if (hdl->filling && hdl->sio.wused == hdl->sio.par.bufsz *
hdl->sio.par.pchan * hdl->sio.par.bps) {
hdl->filling = 0;
if (ioctl(hdl->fd, AUDIO_START) < 0) {
if (ioctl(hdl->fd, AUDIO_START) == -1) {
DPERROR("AUDIO_START");
hdl->sio.eof = 1;
return 0;
@ -551,7 +551,7 @@ sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
if ((pfd->revents & POLLHUP) ||
(pfd->revents & (POLLIN | POLLOUT)) == 0)
return pfd->revents;
if (ioctl(hdl->fd, AUDIO_GETPOS, &ap) < 0) {
if (ioctl(hdl->fd, AUDIO_GETPOS, &ap) == -1) {
DPERROR("sio_sun_revents: GETPOS");
hdl->sio.eof = 1;
return POLLHUP;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: descr.c,v 1.6 2012/07/16 19:57:17 jasper Exp $ */
/* $OpenBSD: descr.c,v 1.7 2019/06/28 13:32:42 deraadt Exp $ */
/* $NetBSD: descr.c,v 1.2 2002/02/20 20:31:07 christos Exp $ */
/*
@ -46,7 +46,7 @@ hid_get_report_desc(int fd)
struct usb_ctl_report_desc rep;
rep.ucrd_size = 0;
if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0)
if (ioctl(fd, USB_GET_REPORT_DESC, &rep) == -1)
return (NULL);
return hid_use_report_desc(rep.ucrd_data, (unsigned int)rep.ucrd_size);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: check_expire.c,v 1.12 2015/11/26 23:32:52 millert Exp $ */
/* $OpenBSD: check_expire.c,v 1.13 2019/06/28 13:32:43 deraadt Exp $ */
/*
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
@ -166,7 +166,7 @@ pwd_update(const struct passwd *pwd, const struct passwd *opwd)
pw_init();
tfd = pw_lock(0);
if (tfd < 0) {
if (tfd == -1) {
if (errno == EEXIST)
return("the passwd file is busy.");
else
@ -174,13 +174,13 @@ pwd_update(const struct passwd *pwd, const struct passwd *opwd)
}
pfd = open(_PATH_MASTERPASSWD, O_RDONLY|O_CLOEXEC, 0);
if (pfd < 0) {
if (pfd == -1) {
pw_abort();
return(strerror(errno));
}
pw_copy(pfd, tfd, pwd, opwd);
if (pw_mkdb(pwd->pw_name, 0) < 0) {
if (pw_mkdb(pwd->pw_name, 0) == -1) {
pw_abort();
return("unable to update password database");
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: getmaxpartitions.c,v 1.9 2016/08/27 03:54:20 guenther Exp $ */
/* $OpenBSD: getmaxpartitions.c,v 1.10 2019/06/28 13:32:43 deraadt Exp $ */
/* $NetBSD: getmaxpartitions.c,v 1.1 1996/05/16 07:03:31 thorpej Exp $ */
/*-
@ -45,7 +45,7 @@ getmaxpartitions(void)
mib[0] = CTL_KERN;
mib[1] = KERN_MAXPARTITIONS;
varlen = sizeof(maxpart);
if (sysctl(mib, 2, &maxpart, &varlen, NULL, (size_t)0) < 0)
if (sysctl(mib, 2, &maxpart, &varlen, NULL, (size_t)0) == -1)
return (-1);
return (maxpart);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: getrawpartition.c,v 1.9 2016/08/27 03:54:20 guenther Exp $ */
/* $OpenBSD: getrawpartition.c,v 1.10 2019/06/28 13:32:43 deraadt Exp $ */
/* $NetBSD: getrawpartition.c,v 1.1 1996/05/16 07:03:33 thorpej Exp $ */
/*-
@ -45,7 +45,7 @@ getrawpartition(void)
mib[0] = CTL_KERN;
mib[1] = KERN_RAWPARTITION;
varlen = sizeof(rawpart);
if (sysctl(mib, 2, &rawpart, &varlen, NULL, (size_t)0) < 0)
if (sysctl(mib, 2, &rawpart, &varlen, NULL, (size_t)0) == -1)
return (-1);
return (rawpart);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: logout.c,v 1.9 2015/12/28 20:11:36 guenther Exp $ */
/* $OpenBSD: logout.c,v 1.10 2019/06/28 13:32:43 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@ -47,7 +47,7 @@ logout(const char *line)
int fd, rval;
UTMP ut;
if ((fd = open(_PATH_UTMP, O_RDWR|O_CLOEXEC)) < 0)
if ((fd = open(_PATH_UTMP, O_RDWR|O_CLOEXEC)) == -1)
return(0);
rval = 0;
while (read(fd, &ut, sizeof(UTMP)) == sizeof(UTMP)) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: logwtmp.c,v 1.10 2016/08/30 14:44:45 guenther Exp $ */
/* $OpenBSD: logwtmp.c,v 1.11 2019/06/28 13:32:43 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@ -46,7 +46,7 @@ logwtmp(const char *line, const char *name, const char *host)
struct utmp ut;
int fd;
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND|O_CLOEXEC)) < 0)
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND|O_CLOEXEC)) == -1)
return;
if (fstat(fd, &buf) == 0) {
(void) strncpy(ut.ut_line, line, sizeof(ut.ut_line));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: passwd.c,v 1.55 2018/08/10 17:03:26 deraadt Exp $ */
/* $OpenBSD: passwd.c,v 1.56 2019/06/28 13:32:43 deraadt Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
@ -101,7 +101,7 @@ pw_lock(int retries)
/* Acquire the lock file. */
old_mode = umask(0);
fd = open(pw_lck, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0600);
for (i = 0; i < retries && fd < 0 && errno == EEXIST; i++) {
for (i = 0; i < retries && fd == -1 && errno == EEXIST; i++) {
sleep(1);
fd = open(pw_lck, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0600);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: readlabel.c,v 1.14 2016/08/30 14:44:45 guenther Exp $ */
/* $OpenBSD: readlabel.c,v 1.15 2019/06/28 13:32:43 deraadt Exp $ */
/*
* Copyright (c) 1996, Jason Downs. All rights reserved.
@ -74,7 +74,7 @@ readlabelfs(char *device, int verbose)
}
/* Assuming device is of the form /dev/??p, build a raw partition. */
if (stat(device, &sbuf) < 0) {
if (stat(device, &sbuf) == -1) {
if (verbose)
warn("%s", device);
return (NULL);
@ -106,12 +106,12 @@ readlabelfs(char *device, int verbose)
/* If rpath doesn't exist, change that partition back. */
fd = open(rpath, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
if (fd == -1) {
if (errno == ENOENT) {
rpath[strlen(rpath) - 1] = part;
fd = open(rpath, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
if (fd == -1) {
if (verbose)
warn("%s", rpath);
return (NULL);
@ -125,7 +125,7 @@ readlabelfs(char *device, int verbose)
disklabel:
if (ioctl(fd, DIOCGDINFO, &dk) < 0) {
if (ioctl(fd, DIOCGDINFO, &dk) == -1) {
if (verbose)
warn("%s: couldn't read disklabel", rpath);
close(fd);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uucplock.c,v 1.19 2016/08/30 14:52:09 guenther Exp $ */
/* $OpenBSD: uucplock.c,v 1.20 2019/06/28 13:32:43 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@ -71,11 +71,11 @@ uu_lock(const char *ttyname)
(void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT,
ttyname);
tmpfd = open(lcktmpname, O_CREAT|O_TRUNC|O_WRONLY|O_CLOEXEC, 0664);
if (tmpfd < 0)
if (tmpfd == -1)
GORET(0, UU_LOCK_CREAT_ERR);
for (i = 0; i < MAXTRIES; i++) {
if (link(lcktmpname, lckname) < 0) {
if (link(lcktmpname, lckname) == -1) {
if (errno != EEXIST)
GORET(1, UU_LOCK_LINK_ERR);
/*
@ -83,7 +83,7 @@ uu_lock(const char *ttyname)
* check to see if the process holding the lock
* still exists
*/
if ((fd = open(lckname, O_RDONLY | O_CLOEXEC)) < 0)
if ((fd = open(lckname, O_RDONLY | O_CLOEXEC)) == -1)
GORET(1, UU_LOCK_OPEN_ERR);
if ((pid_old = get_pid(fd, &err)) == -1)
@ -127,7 +127,7 @@ uu_lock_txfr(const char *ttyname, pid_t pid)
snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, ttyname);
if ((fd = open(lckname, O_RDWR | O_CLOEXEC)) < 0)
if ((fd = open(lckname, O_RDWR | O_CLOEXEC)) == -1)
return UU_LOCK_OWNER_ERR;
if (get_pid(fd, &err) != getpid())
ret = UU_LOCK_OWNER_ERR;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fingerd.c,v 1.40 2018/08/03 15:14:18 deraadt Exp $ */
/* $OpenBSD: fingerd.c,v 1.41 2019/06/28 13:32:53 deraadt Exp $ */
/*
* Copyright (c) 1983, 1993
@ -119,7 +119,7 @@ main(int argc, char *argv[])
socklen_t sval;
sval = sizeof(ss);
if (getpeername(0, (struct sockaddr *)&ss, &sval) < 0)
if (getpeername(0, (struct sockaddr *)&ss, &sval) == -1)
err(1, "getpeername");
sa = (struct sockaddr *)&ss;
@ -197,7 +197,7 @@ main(int argc, char *argv[])
}
}
if (pipe(p) < 0)
if (pipe(p) == -1)
logerr("pipe: %s", strerror(errno));
switch (vfork()) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ftpcmd.y,v 1.67 2019/05/08 23:56:48 tedu Exp $ */
/* $OpenBSD: ftpcmd.y,v 1.68 2019/06/28 13:32:53 deraadt Exp $ */
/* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */
/*
@ -530,7 +530,7 @@ cmd
reply(550,
"No permission to change mode of %s.",
$8);
else if (chmod($8, $6) < 0)
else if (chmod($8, $6) == -1)
perror_reply(550, $8);
else
reply(200,
@ -605,7 +605,7 @@ cmd
{
if ($2 && $4 != NULL) {
struct stat stbuf;
if (stat($4, &stbuf) < 0)
if (stat($4, &stbuf) == -1)
reply(550, "%s: %s",
$4, strerror(errno));
else if (!S_ISREG(stbuf.st_mode)) {
@ -1514,7 +1514,7 @@ sizecmd(filename)
case TYPE_L:
case TYPE_I: {
struct stat stbuf;
if (stat(filename, &stbuf) < 0 || !S_ISREG(stbuf.st_mode))
if (stat(filename, &stbuf) == -1 || !S_ISREG(stbuf.st_mode))
reply(550, "%s: not a plain file.", filename);
else
reply(213, "%lld", (long long)stbuf.st_size);
@ -1529,7 +1529,7 @@ sizecmd(filename)
perror_reply(550, filename);
return;
}
if (fstat(fileno(fin), &stbuf) < 0 || !S_ISREG(stbuf.st_mode)) {
if (fstat(fileno(fin), &stbuf) == -1 || !S_ISREG(stbuf.st_mode)) {
reply(550, "%s: not a plain file.", filename);
(void) fclose(fin);
return;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ftpd.c,v 1.226 2019/05/08 23:56:48 tedu Exp $ */
/* $OpenBSD: ftpd.c,v 1.227 2019/06/28 13:32:53 deraadt Exp $ */
/* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */
/*
@ -398,7 +398,7 @@ main(int argc, char *argv[])
/*
* Detach from parent.
*/
if (daemon(1, 1) < 0) {
if (daemon(1, 1) == -1) {
syslog(LOG_ERR, "failed to become a daemon");
exit(1);
}
@ -435,29 +435,29 @@ main(int argc, char *argv[])
for (res = res0; res; res = res->ai_next) {
fds[n] = socket(res->ai_family, res->ai_socktype,
res->ai_protocol);
if (fds[n] < 0)
if (fds[n] == -1)
continue;
if (setsockopt(fds[n], SOL_SOCKET, SO_KEEPALIVE,
&on, sizeof(on)) < 0) {
&on, sizeof(on)) == -1) {
close(fds[n]);
fds[n] = -1;
continue;
}
if (setsockopt(fds[n], SOL_SOCKET, SO_REUSEADDR,
&on, sizeof(on)) < 0) {
&on, sizeof(on)) == -1) {
close(fds[n]);
fds[n] = -1;
continue;
}
if (bind(fds[n], res->ai_addr, res->ai_addrlen) < 0) {
if (bind(fds[n], res->ai_addr, res->ai_addrlen) == -1) {
close(fds[n]);
fds[n] = -1;
continue;
}
if (listen(fds[n], 32) < 0) {
if (listen(fds[n], 32) == -1) {
close(fds[n]);
fds[n] = -1;
continue;
@ -479,7 +479,7 @@ main(int argc, char *argv[])
* children to handle them.
*/
while (1) {
if (poll(pfds, n, INFTIM) < 0) {
if (poll(pfds, n, INFTIM) == -1) {
if (errno == EINTR)
continue;
syslog(LOG_ERR, "poll: %m");
@ -508,7 +508,7 @@ main(int argc, char *argv[])
} else {
addrlen = sizeof(his_addr);
if (getpeername(0, (struct sockaddr *)&his_addr,
&addrlen) < 0) {
&addrlen) == -1) {
/* syslog(LOG_ERR, "getpeername (%s): %m", argv[0]); */
exit(1);
}
@ -520,7 +520,7 @@ main(int argc, char *argv[])
set_slave_signals();
addrlen = sizeof(ctrl_addr);
if (getsockname(0, (struct sockaddr *)&ctrl_addr, &addrlen) < 0) {
if (getsockname(0, (struct sockaddr *)&ctrl_addr, &addrlen) == -1) {
syslog(LOG_ERR, "getsockname: %m");
exit(1);
}
@ -535,19 +535,19 @@ main(int argc, char *argv[])
switch (his_addr.su_family) {
case AF_INET:
if (setsockopt(0, IPPROTO_IP, IP_TOS, &tos,
sizeof(int)) < 0)
sizeof(int)) == -1)
syslog(LOG_WARNING, "setsockopt (IP_TOS): %m");
break;
case AF_INET6:
if (setsockopt(0, IPPROTO_IPV6, IPV6_TCLASS, &tos,
sizeof(int)) < 0)
sizeof(int)) == -1)
syslog(LOG_WARNING, "setsockopt (IPV6_TCLASS): %m");
break;
}
data_source.su_port = htons(ntohs(ctrl_addr.su_port) - 1);
/* Try to handle urgent data inline */
if (setsockopt(0, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on)) < 0)
if (setsockopt(0, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on)) == -1)
syslog(LOG_ERR, "setsockopt: %m");
dolog((struct sockaddr *)&his_addr);
@ -971,7 +971,7 @@ pass(char *passwd)
/* open stats file before chroot */
if (guest && (stats == 1) && (statfd < 0))
if ((statfd = open(_PATH_FTPDSTATFILE, O_WRONLY|O_APPEND)) < 0)
if ((statfd = open(_PATH_FTPDSTATFILE, O_WRONLY|O_APPEND)) == -1)
stats = 0;
logged_in = 1;
@ -1006,7 +1006,7 @@ pass(char *passwd)
/* Compute root directory. */
snprintf(rootdir, sizeof(rootdir), "%s/%s",
pw->pw_dir, dhostname);
if (stat(rootdir, &ts) < 0) {
if (stat(rootdir, &ts) == -1) {
snprintf(rootdir, sizeof(rootdir), "%s/%s",
pw->pw_dir, hostname);
}
@ -1019,7 +1019,7 @@ pass(char *passwd)
* the old current directory will be accessible as "."
* outside the new root!
*/
if (chroot(rootdir) < 0 || chdir("/") < 0) {
if (chroot(rootdir) == -1 || chdir("/") == -1) {
reply(550, "Can't set guest privileges.");
goto bad;
}
@ -1029,7 +1029,7 @@ pass(char *passwd)
goto bad;
}
} else if (dochroot) {
if (chroot(rootdir) < 0 || chdir("/") < 0) {
if (chroot(rootdir) == -1 || chdir("/") == -1) {
reply(550, "Can't change root.");
goto bad;
}
@ -1038,19 +1038,19 @@ pass(char *passwd)
reply(550, "Can't setup environment.");
goto bad;
}
} else if (chdir(pw->pw_dir) < 0) {
if (chdir("/") < 0) {
} else if (chdir(pw->pw_dir) == -1) {
if (chdir("/") == -1) {
reply(530, "User %s: can't change directory to %s.",
pw->pw_name, pw->pw_dir);
goto bad;
} else
lreply(230, "No directory! Logging in with home=/");
}
if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) < 0) {
if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1) {
reply(550, "Can't set gid.");
goto bad;
}
if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) < 0) {
if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1) {
reply(550, "Can't set uid.");
goto bad;
}
@ -1139,7 +1139,7 @@ retrieve(enum ret_cmd cmd, char *name)
}
byte_count = -1;
if (cmd == RET_FILE &&
(fstat(fileno(fin), &st) < 0 || !S_ISREG(st.st_mode))) {
(fstat(fileno(fin), &st) == -1 || !S_ISREG(st.st_mode))) {
reply(550, "%s: not a plain file.", name);
goto done;
}
@ -1161,7 +1161,7 @@ retrieve(enum ret_cmd cmd, char *name)
if (c == '\n')
i++;
}
} else if (lseek(fileno(fin), restart_point, SEEK_SET) < 0) {
} else if (lseek(fileno(fin), restart_point, SEEK_SET) == -1) {
perror_reply(550, name);
goto done;
}
@ -1242,11 +1242,11 @@ store(char *name, char *mode, int unique)
* because we are changing from reading to
* writing.
*/
if (fseek(fout, 0, SEEK_CUR) < 0) {
if (fseek(fout, 0, SEEK_CUR) == -1) {
perror_reply(550, name);
goto done;
}
} else if (lseek(fileno(fout), restart_point, SEEK_SET) < 0) {
} else if (lseek(fileno(fout), restart_point, SEEK_SET) == -1) {
perror_reply(550, name);
goto done;
}
@ -1282,7 +1282,7 @@ getdatasock(char *mode)
goto bad;
opt = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
&opt, sizeof(opt)) < 0)
&opt, sizeof(opt)) == -1)
goto bad;
/* anchor socket to avoid multi-homing problems */
data_source = ctrl_addr;
@ -1301,12 +1301,12 @@ getdatasock(char *mode)
switch (ctrl_addr.su_family) {
case AF_INET:
if (setsockopt(s, IPPROTO_IP, IP_TOS, &opt,
sizeof(opt)) < 0)
sizeof(opt)) == -1)
syslog(LOG_WARNING, "setsockopt (IP_TOS): %m");
break;
case AF_INET6:
if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &opt,
sizeof(opt)) < 0)
sizeof(opt)) == -1)
syslog(LOG_WARNING, "setsockopt (IPV6_TCLASS): %m");
break;
}
@ -1317,10 +1317,10 @@ getdatasock(char *mode)
* in heavy-load situations.
*/
opt = 1;
if (setsockopt(s, IPPROTO_TCP, TCP_NOPUSH, &opt, sizeof(opt)) < 0)
if (setsockopt(s, IPPROTO_TCP, TCP_NOPUSH, &opt, sizeof(opt)) == -1)
syslog(LOG_WARNING, "setsockopt (TCP_NOPUSH): %m");
opt = 65536;
if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)) < 0)
if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)) == -1)
syslog(LOG_WARNING, "setsockopt (SO_SNDBUF): %m");
return (fdopen(s, mode));
@ -1360,7 +1360,7 @@ dataconn(char *name, off_t size, char *mode)
(void) alarm ((unsigned) timeout);
s = accept(pdata, (struct sockaddr *)&from, &fromlen);
(void) alarm (0);
if (s < 0) {
if (s == -1) {
reply(425, "Can't open data connection.");
(void) close(pdata);
pdata = -1;
@ -1590,7 +1590,7 @@ oldway:
transflag = 0;
(void)free(buf);
if (cnt != 0) {
if (cnt < 0)
if (cnt == -1)
goto file_err;
goto data_err;
}
@ -1658,7 +1658,7 @@ receive_data(FILE *instr, FILE *outstr)
}
} while (cnt > 0);
(void) sigaction(SIGALRM, &sa_saved, NULL);
if (cnt < 0)
if (cnt == -1)
goto data_err;
transflag = 0;
return (0);
@ -1995,18 +1995,18 @@ delete(char *name)
struct stat st;
LOGCMD("delete", name);
if (stat(name, &st) < 0) {
if (stat(name, &st) == -1) {
perror_reply(550, name);
return;
}
if ((st.st_mode&S_IFMT) == S_IFDIR) {
if (rmdir(name) < 0) {
if (rmdir(name) == -1) {
perror_reply(550, name);
return;
}
goto done;
}
if (unlink(name) < 0) {
if (unlink(name) == -1) {
perror_reply(550, name);
return;
}
@ -2019,7 +2019,7 @@ cwd(char *path)
{
FILE *message;
if (chdir(path) < 0)
if (chdir(path) == -1)
perror_reply(550, path);
else {
if ((message = fopen(_PATH_CWDMESG, "r")) != NULL) {
@ -2065,7 +2065,7 @@ makedir(char *name)
{
LOGCMD("mkdir", name);
if (mkdir(name, 0777) < 0)
if (mkdir(name, 0777) == -1)
perror_reply(550, name);
else
replydirname(name, "directory created.");
@ -2076,7 +2076,7 @@ removedir(char *name)
{
LOGCMD("rmdir", name);
if (rmdir(name) < 0)
if (rmdir(name) == -1)
perror_reply(550, name);
else
ack("RMD");
@ -2098,7 +2098,7 @@ renamefrom(char *name)
{
struct stat st;
if (stat(name, &st) < 0) {
if (stat(name, &st) == -1) {
perror_reply(550, name);
return (NULL);
}
@ -2111,7 +2111,7 @@ renamecmd(char *from, char *to)
{
LOGCMD2("rename", from, to);
if (rename(from, to) < 0)
if (rename(from, to) == -1)
perror_reply(550, "rename");
else
ack("RNTO");
@ -2233,30 +2233,30 @@ passive(void)
* resources.
*/
pdata = socket(AF_INET, SOCK_STREAM, 0);
if (pdata < 0) {
if (pdata == -1) {
perror_reply(425, "Can't open passive connection");
return;
}
if (setsockopt(pdata, SOL_SOCKET, SO_KEEPALIVE,
&on, sizeof(on)) < 0)
&on, sizeof(on)) == -1)
goto pasv_error;
on = IP_PORTRANGE_HIGH;
if (setsockopt(pdata, IPPROTO_IP, IP_PORTRANGE,
&on, sizeof(on)) < 0)
&on, sizeof(on)) == -1)
goto pasv_error;
pasv_addr = ctrl_addr;
pasv_addr.su_sin.sin_port = 0;
if (bind(pdata, (struct sockaddr *)&pasv_addr,
pasv_addr.su_len) < 0)
pasv_addr.su_len) == -1)
goto pasv_error;
len = sizeof(pasv_addr);
if (getsockname(pdata, (struct sockaddr *)&pasv_addr, &len) < 0)
if (getsockname(pdata, (struct sockaddr *)&pasv_addr, &len) == -1)
goto pasv_error;
if (listen(pdata, 1) < 0)
if (listen(pdata, 1) == -1)
goto pasv_error;
a = (u_char *)&pasv_addr.su_sin.sin_addr;
p = (u_char *)&pasv_addr.su_sin.sin_port;
@ -2336,38 +2336,38 @@ long_passive(char *cmd, int pf)
* resources.
*/
pdata = socket(ctrl_addr.su_family, SOCK_STREAM, 0);
if (pdata < 0) {
if (pdata == -1) {
perror_reply(425, "Can't open passive connection");
return;
}
if (setsockopt(pdata, SOL_SOCKET, SO_KEEPALIVE,
&on, sizeof(on)) < 0)
&on, sizeof(on)) == -1)
goto pasv_error;
switch (ctrl_addr.su_family) {
case AF_INET:
on = IP_PORTRANGE_HIGH;
if (setsockopt(pdata, IPPROTO_IP, IP_PORTRANGE,
&on, sizeof(on)) < 0)
&on, sizeof(on)) == -1)
goto pasv_error;
break;
case AF_INET6:
on = IPV6_PORTRANGE_HIGH;
if (setsockopt(pdata, IPPROTO_IPV6, IPV6_PORTRANGE,
&on, sizeof(on)) < 0)
&on, sizeof(on)) == -1)
goto pasv_error;
break;
}
pasv_addr = ctrl_addr;
pasv_addr.su_port = 0;
if (bind(pdata, (struct sockaddr *)&pasv_addr, pasv_addr.su_len) < 0)
if (bind(pdata, (struct sockaddr *)&pasv_addr, pasv_addr.su_len) == -1)
goto pasv_error;
len = pasv_addr.su_len;
if (getsockname(pdata, (struct sockaddr *)&pasv_addr, &len) < 0)
if (getsockname(pdata, (struct sockaddr *)&pasv_addr, &len) == -1)
goto pasv_error;
if (listen(pdata, 1) < 0)
if (listen(pdata, 1) == -1)
goto pasv_error;
p = (u_char *)&pasv_addr.su_port;
@ -2545,7 +2545,7 @@ guniquefd(char *local, char **nam)
cp = strrchr(local, '/');
if (cp)
*cp = '\0';
if (stat(cp ? local : ".", &st) < 0) {
if (stat(cp ? local : ".", &st) == -1) {
perror_reply(553, cp ? local : ".");
return (-1);
}
@ -2619,7 +2619,7 @@ send_file_list(char *whichf)
}
while ((dirname = *dirlist++)) {
if (stat(dirname, &st) < 0) {
if (stat(dirname, &st) == -1) {
/*
* If user typed "ls -l", etc, and the client
* used NLST, do what the user meant.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: logutmp.c,v 1.13 2016/08/14 22:57:31 guenther Exp $ */
/* $OpenBSD: logutmp.c,v 1.14 2019/06/28 13:32:53 deraadt Exp $ */
/*
* Portions Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@ -70,7 +70,7 @@ ftpd_login(struct utmp *ut)
topslot++;
}
if ((topslot < 0) || ((fd < 0) &&
(fd = open(_PATH_UTMP, O_RDWR|O_CREAT, 0644)) < 0))
(fd = open(_PATH_UTMP, O_RDWR|O_CREAT, 0644)) == -1))
return;
/*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: logwtmp.c,v 1.11 2009/10/27 23:59:31 deraadt Exp $ */
/* $OpenBSD: logwtmp.c,v 1.12 2019/06/28 13:32:53 deraadt Exp $ */
/* $NetBSD: logwtmp.c,v 1.4 1995/04/11 02:44:58 cgd Exp $ */
/*
@ -60,7 +60,7 @@ ftpdlogwtmp(char *line, char *name, char *host)
struct stat buf;
struct utmp ut;
if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) == -1)
return;
if (fstat(fd, &buf) == 0) {
(void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: monitor.c,v 1.25 2017/04/17 21:48:26 deraadt Exp $ */
/* $OpenBSD: monitor.c,v 1.26 2019/06/28 13:32:53 deraadt Exp $ */
/*
* Copyright (c) 2004 Moritz Jodeit <moritz@openbsd.org>
@ -310,7 +310,7 @@ handle_cmds(void)
send_data(fd_slave, &slavequit,
sizeof(slavequit));
while (waitpid(preauth_slave_pid, NULL, 0) < 0 &&
while (waitpid(preauth_slave_pid, NULL, 0) == -1 &&
errno == EINTR)
;
break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: popen.c,v 1.27 2019/05/08 23:56:48 tedu Exp $ */
/* $OpenBSD: popen.c,v 1.28 2019/06/28 13:32:53 deraadt Exp $ */
/* $NetBSD: popen.c,v 1.5 1995/04/11 02:45:00 cgd Exp $ */
/*
@ -68,7 +68,7 @@ ftpd_ls(char *arg, char *path, pid_t *pidptr)
pid_t pid;
char **pop, *argv[MAX_ARGV], *gargv[MAX_GARGV];
if (pipe(pdes) < 0)
if (pipe(pdes) == -1)
return (NULL);
/* break up string into pieces */
@ -154,10 +154,10 @@ ftpd_pclose(FILE *iop, pid_t pid)
sigaddset(&sigset, SIGQUIT);
sigaddset(&sigset, SIGHUP);
sigprocmask(SIG_BLOCK, &sigset, &osigset);
while ((rv = waitpid(pid, &status, 0)) < 0 && errno == EINTR)
while ((rv = waitpid(pid, &status, 0)) == -1 && errno == EINTR)
continue;
sigprocmask(SIG_SETMASK, &osigset, NULL);
if (rv < 0)
if (rv == -1)
return (-1);
if (WIFEXITED(status))
return (WEXITSTATUS(status));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.53 2019/06/23 18:54:24 rob Exp $ */
/* $OpenBSD: main.c,v 1.54 2019/06/28 13:32:53 deraadt Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -256,7 +256,7 @@ main(int argc, char *argv[])
}
/* Start with default tty settings */
if (tcgetattr(0, &tmode) < 0) {
if (tcgetattr(0, &tmode) == -1) {
syslog(LOG_ERR, "%s: %m", ttyn);
exit(1);
}
@ -286,7 +286,7 @@ main(int argc, char *argv[])
cfsetospeed(&tmode, SP);
setflags(0);
setchars();
if (tcsetattr(0, TCSANOW, &tmode) < 0) {
if (tcsetattr(0, TCSANOW, &tmode) == -1) {
syslog(LOG_ERR, "%s: %m", ttyn);
exit(1);
}
@ -334,7 +334,7 @@ main(int argc, char *argv[])
tmode.c_oflag &= ~OLCUC;
tmode.c_lflag &= ~XCASE;
}
if (tcsetattr(0, TCSANOW, &tmode) < 0) {
if (tcsetattr(0, TCSANOW, &tmode) == -1) {
syslog(LOG_ERR, "%s: %m", ttyn);
exit(1);
}
@ -376,7 +376,7 @@ getname(void)
sleep(PF);
PF = 0;
}
if (tcsetattr(0, TCSANOW, &tmode) < 0) {
if (tcsetattr(0, TCSANOW, &tmode) == -1) {
syslog(LOG_ERR, "%s: %m", ttyn);
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: raddauth.c,v 1.29 2016/09/03 11:04:23 gsoares Exp $ */
/* $OpenBSD: raddauth.c,v 1.30 2019/06/28 13:32:53 deraadt Exp $ */
/*-
* Copyright (c) 1996, 1997 Berkeley Software Design, Inc. All rights reserved.
@ -233,7 +233,7 @@ raddauth(char *username, char *class, char *style, char *challenge,
getsecret();
/* set up socket */
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
snprintf(_pwstate, sizeof(_pwstate), "%s", strerror(errno));
*emsg = _pwstate;
return (1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: login_skey.c,v 1.27 2019/01/25 00:19:26 millert Exp $ */
/* $OpenBSD: login_skey.c,v 1.28 2019/06/28 13:32:53 deraadt Exp $ */
/*
* Copyright (c) 2000, 2001, 2004 Todd C. Miller <millert@openbsd.org>
@ -287,6 +287,6 @@ send_fd(int sock)
*(int *)CMSG_DATA(cmp) = fileno(skey.keyfile);
if (sendmsg(sock, &msg, 0) < 0)
if (sendmsg(sock, &msg, 0) == -1)
syslog(LOG_ERR, "sendmsg: %m");
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: login_token.c,v 1.15 2015/12/22 08:54:16 mmcc Exp $ */
/* $OpenBSD: login_token.c,v 1.16 2019/06/28 13:32:53 deraadt Exp $ */
/*-
* Copyright (c) 1995, 1996 Berkeley Software Design, Inc. All rights reserved.
@ -78,7 +78,7 @@ main(int argc, char *argv[])
cds.rlim_cur = 0;
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");
if (pledge("stdio rpath wpath cpath fattr flock getpw tty", NULL) == -1) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tokendb.c,v 1.10 2015/10/05 17:31:17 millert Exp $ */
/* $OpenBSD: tokendb.c,v 1.11 2019/06/28 13:32:53 deraadt Exp $ */
/*-
* Copyright (c) 1995 Migration Associates Corp. All Rights Reserved
@ -176,7 +176,7 @@ tokendb_open(void)
return (-1);
}
if (stat(tt->db, &statb) < 0) {
if (stat(tt->db, &statb) == -1) {
if (errno != ENOENT)
return (-1);
must_set_perms++;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mail.local.c,v 1.35 2015/12/12 20:09:28 mmcc Exp $ */
/* $OpenBSD: mail.local.c,v 1.36 2019/06/28 13:32:53 deraadt Exp $ */
/*-
* Copyright (c) 1996-1998 Theo de Raadt <deraadt@theos.com>
@ -201,7 +201,7 @@ retry:
goto bad;
}
if ((mbfd = open(path, O_APPEND|O_CREAT|O_EXCL|O_WRONLY|O_EXLOCK,
S_IRUSR|S_IWUSR)) < 0) {
S_IRUSR|S_IWUSR)) == -1) {
if (errno == EEXIST) {
/* file appeared since lstat */
goto retry;
@ -216,7 +216,7 @@ retry:
* that if the ownership or permissions were changed there
* was a reason for doing so.
*/
if (fchown(mbfd, pw->pw_uid, pw->pw_gid) < 0) {
if (fchown(mbfd, pw->pw_uid, pw->pw_gid) == -1) {
merr(NOTFATAL, "chown %u:%u: %s",
pw->pw_uid, pw->pw_gid, name);
goto bad;
@ -227,11 +227,11 @@ retry:
goto bad;
}
if ((mbfd = open(path, O_APPEND|O_WRONLY|O_EXLOCK,
S_IRUSR|S_IWUSR)) < 0) {
S_IRUSR|S_IWUSR)) == -1) {
merr(NOTFATAL, "%s: %s", path, strerror(errno));
goto bad;
}
if (fstat(mbfd, &fsb)) {
if (fstat(mbfd, &fsb) == -1) {
/* relating error to path may be bad style */
merr(NOTFATAL, "%s: %s", path, strerror(errno));
goto bad;
@ -256,7 +256,7 @@ retry:
while ((nr = read(fd, buf, sizeof(buf))) > 0)
for (off = 0; off < nr; off += nw)
if ((nw = write(mbfd, buf + off, nr - off)) < 0) {
if ((nw = write(mbfd, buf + off, nr - off)) == -1) {
merr(NOTFATAL, "%s: %s", path, strerror(errno));
(void)ftruncate(mbfd, curoff);
goto bad;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rquotad.c,v 1.22 2015/01/16 06:39:50 deraadt Exp $ */
/* $OpenBSD: rquotad.c,v 1.23 2019/06/28 13:32:53 deraadt Exp $ */
/*
* by Manuel Bouyer (bouyer@ensta.fr). Public domain.
@ -67,7 +67,7 @@ main(int argc, char *argv[])
socklen_t fromlen;
fromlen = sizeof(from);
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
if (getsockname(0, (struct sockaddr *)&from, &fromlen) == -1) {
from_inetd = 0;
sock = RPC_ANYSOCK;
proto = IPPROTO_UDP;
@ -231,7 +231,7 @@ getfsquota(long id, char *path, struct dqblk *dqblk)
struct fs_stat *fs;
int qcmd, fd, ret = 0;
if (stat(path, &st_path) < 0)
if (stat(path, &st_path) == -1)
return (0);
qcmd = QCMD(Q_GETQUOTA, USRQUOTA);
@ -245,7 +245,7 @@ getfsquota(long id, char *path, struct dqblk *dqblk)
if (quotactl(fs->fs_file, qcmd, id, (char *)dqblk) == 0)
return (1);
if ((fd = open(fs->qfpathname, O_RDONLY)) < 0) {
if ((fd = open(fs->qfpathname, O_RDONLY)) == -1) {
syslog(LOG_ERR, "open error: %s: %m", fs->qfpathname);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rstat_proc.c,v 1.35 2017/05/27 07:44:28 tedu Exp $ */
/* $OpenBSD: rstat_proc.c,v 1.36 2019/06/28 13:32:53 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -208,7 +208,7 @@ updatestat(void)
mib[0] = CTL_KERN;
mib[1] = KERN_BOOTTIME;
len = sizeof(btm);
if (sysctl(mib, 2, &btm, &len, NULL, 0) < 0) {
if (sysctl(mib, 2, &btm, &len, NULL, 0) == -1) {
syslog(LOG_ERR, "can't sysctl kern.boottime: %m");
_exit(1);
}
@ -225,7 +225,7 @@ updatestat(void)
mib[0] = CTL_VM;
mib[1] = VM_UVMEXP;
len = sizeof(uvmexp);
if (sysctl(mib, 2, &uvmexp, &len, NULL, 0) < 0) {
if (sysctl(mib, 2, &uvmexp, &len, NULL, 0) == -1) {
syslog(LOG_ERR, "can't sysctl vm.uvmexp: %m");
_exit(1);
}

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