summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2019-06-28 13:32:54 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2019-06-28 13:32:54 +0000
commit86ffccf24f66032a89d70a32b3609584c0db7345 (patch)
tree2ae97fac6ea5be57cc953baf8612e8f683da0172 /games
parentce9fea47562d4f179d45680d6aec00ede2877141 (diff)
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.
Diffstat (limited to 'games')
-rw-r--r--games/atc/log.c6
-rw-r--r--games/grdc/grdc.c4
-rw-r--r--games/hack/hack.bones.c8
-rw-r--r--games/hack/hack.do.c6
-rw-r--r--games/hack/hack.main.c8
-rw-r--r--games/hack/hack.pager.c4
-rw-r--r--games/hack/hack.save.c8
-rw-r--r--games/hack/hack.tty.c8
-rw-r--r--games/hack/makedefs.c6
-rw-r--r--games/hangman/ksyms.c6
-rw-r--r--games/hunt/hunt/list.c10
-rw-r--r--games/mille/save.c8
-rw-r--r--games/mille/varpush.c6
-rw-r--r--games/monop/execute.c4
-rw-r--r--games/phantasia/setup.c6
-rw-r--r--games/robots/main.c6
-rw-r--r--games/robots/score.c4
-rw-r--r--games/sail/misc.c4
-rw-r--r--games/sail/pl_1.c4
-rw-r--r--games/sail/sync.c6
-rw-r--r--games/snake/snake.c4
-rw-r--r--games/tetris/scores.c4
-rw-r--r--games/tetris/screen.c6
23 files changed, 68 insertions, 68 deletions
diff --git a/games/atc/log.c b/games/atc/log.c
index 6ff6afc100c..88640f61eff 100644
--- a/games/atc/log.c
+++ b/games/atc/log.c
@@ -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);
diff --git a/games/grdc/grdc.c b/games/grdc/grdc.c
index ea2d3408b92..64a3b1b2196 100644
--- a/games/grdc/grdc.c
+++ b/games/grdc/grdc.c
@@ -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 {
diff --git a/games/hack/hack.bones.c b/games/hack/hack.bones.c
index 9ce8d916a81..4abe525065d 100644
--- a/games/hack/hack.bones.c
+++ b/games/hack/hack.bones.c
@@ -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);
}
diff --git a/games/hack/hack.do.c b/games/hack/hack.do.c
index 435b653ddfe..12d4752d02f 100644
--- a/games/hack/hack.do.c
+++ b/games/hack/hack.do.c
@@ -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");
diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c
index 820efd724d5..51a066600db 100644
--- a/games/hack/hack.main.c
+++ b/games/hack/hack.main.c
@@ -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
diff --git a/games/hack/hack.pager.c b/games/hack/hack.pager.c
index 8dd8b3a0045..32b65ef85b5 100644
--- a/games/hack/hack.pager.c
+++ b/games/hack/hack.pager.c
@@ -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);
}
diff --git a/games/hack/hack.save.c b/games/hack/hack.save.c
index 900196f9c5a..ef498f7caae 100644
--- a/games/hack/hack.save.c
+++ b/games/hack/hack.save.c
@@ -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);
diff --git a/games/hack/hack.tty.c b/games/hack/hack.tty.c
index 321e978ce40..fb0251eb9aa 100644
--- a/games/hack/hack.tty.c
+++ b/games/hack/hack.tty.c
@@ -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)");
}
diff --git a/games/hack/makedefs.c b/games/hack/makedefs.c
index 5a30abe73c9..d8d9bc024df 100644
--- a/games/hack/makedefs.c
+++ b/games/hack/makedefs.c
@@ -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);
}
diff --git a/games/hangman/ksyms.c b/games/hangman/ksyms.c
index bb6866ffb55..12dea84e06f 100644
--- a/games/hangman/ksyms.c
+++ b/games/hangman/ksyms.c
@@ -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)
diff --git a/games/hunt/hunt/list.c b/games/hunt/hunt/list.c
index d4a02c5ab1f..06a4e7c0ac6 100644
--- a/games/hunt/hunt/list.c
+++ b/games/hunt/hunt/list.c
@@ -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;
}
diff --git a/games/mille/save.c b/games/mille/save.c
index 2d620fa4e1a..71140d4a6ae 100644
--- a/games/mille/save.c
+++ b/games/mille/save.c
@@ -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);
diff --git a/games/mille/varpush.c b/games/mille/varpush.c
index 6d3745d19a9..1d828b97ed7 100644
--- a/games/mille/varpush.c
+++ b/games/mille/varpush.c
@@ -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;
}
diff --git a/games/monop/execute.c b/games/monop/execute.c
index 4bea091af72..e8804e1a23d 100644
--- a/games/monop/execute.c
+++ b/games/monop/execute.c
@@ -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);
}
diff --git a/games/phantasia/setup.c b/games/phantasia/setup.c
index 24ff234f8ca..4193afece68 100644
--- a/games/phantasia/setup.c
+++ b/games/phantasia/setup.c
@@ -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 */
diff --git a/games/robots/main.c b/games/robots/main.c
index e7918dfa63d..be6ef3151b7 100644
--- a/games/robots/main.c
+++ b/games/robots/main.c
@@ -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, '/');
diff --git a/games/robots/score.c b/games/robots/score.c
index 029c725ba18..c5d81177509 100644
--- a/games/robots/score.c
+++ b/games/robots/score.c
@@ -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;
}
diff --git a/games/sail/misc.c b/games/sail/misc.c
index ebb18ecc7f0..958cbac6548 100644
--- a/games/sail/misc.c
+++ b/games/sail/misc.c
@@ -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;
diff --git a/games/sail/pl_1.c b/games/sail/pl_1.c
index 35d9dc5058c..e17e403d095 100644
--- a/games/sail/pl_1.c
+++ b/games/sail/pl_1.c
@@ -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);
diff --git a/games/sail/sync.c b/games/sail/sync.c
index 547b7121747..c7ecd5c85ad 100644
--- a/games/sail/sync.c
+++ b/games/sail/sync.c
@@ -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);
diff --git a/games/snake/snake.c b/games/snake/snake.c
index b7a115fb645..b33e85e1173 100644
--- a/games/snake/snake.c
+++ b/games/snake/snake.c
@@ -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);
diff --git a/games/tetris/scores.c b/games/tetris/scores.c
index e52ca152ac8..3b4b791625e 100644
--- a/games/tetris/scores.c
+++ b/games/tetris/scores.c
@@ -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;
diff --git a/games/tetris/screen.c b/games/tetris/screen.c
index 4c5fb73fa4e..e407c3bf3fe 100644
--- a/games/tetris/screen.c
+++ b/games/tetris/screen.c
@@ -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);