summaryrefslogtreecommitdiff
path: root/games/tetris
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2014-12-31 15:42:09 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2014-12-31 15:42:09 +0000
commite67f58aa35f31c23ce54efccc2c4167de45873a5 (patch)
treeb170e9ed035bbcdf75a9d8bf17469549dd1f0b8b /games/tetris
parent98b69a5f37fb292a29f2f4b59727f0faf5f3f067 (diff)
simplify poll() conversion. from patrick keshishian
Diffstat (limited to 'games/tetris')
-rw-r--r--games/tetris/input.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/games/tetris/input.c b/games/tetris/input.c
index b2cd21c3905..cd3e34d7f3f 100644
--- a/games/tetris/input.c
+++ b/games/tetris/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.14 2014/11/05 20:23:38 tedu Exp $ */
+/* $OpenBSD: input.c,v 1.15 2014/12/31 15:42:08 tedu Exp $ */
/* $NetBSD: input.c,v 1.3 1996/02/06 22:47:33 jtc Exp $ */
/*-
@@ -76,7 +76,8 @@
int
rwait(struct timeval *tvp)
{
- struct timeval starttv, endtv, *s;
+ int timo = INFTIM;
+ struct timeval starttv, endtv;
struct pollfd pfd[1];
#define NILTZ ((struct timezone *)0)
@@ -84,15 +85,12 @@ rwait(struct timeval *tvp)
if (tvp) {
(void) gettimeofday(&starttv, NILTZ);
endtv = *tvp;
- s = &endtv;
- } else
- s = NULL;
+ timo = endtv.tv_sec * 1000 + endtv.tv_usec / 1000;
+ }
again:
pfd[0].fd = STDIN_FILENO;
pfd[0].events = POLLIN;
- switch (poll(pfd, 1, s ? s->tv_sec * 1000 + s->tv_usec / 1000 :
- INFTIM)) {
-
+ switch (poll(pfd, 1, timo)) {
case -1:
if (tvp == 0)
return (-1);