summaryrefslogtreecommitdiffstats
path: root/tetris
diff options
context:
space:
mode:
authorjmmv <jmmv@NetBSD.org>2002-12-26 20:15:11 +0000
committerjmmv <jmmv@NetBSD.org>2002-12-26 20:15:11 +0000
commitd604c014c0bc6f72ada916fbfa3d1dd5bdb360c9 (patch)
tree7acea06eae26f02d892dfcf5113e6783e801f2fa /tetris
parentc58b3d183c9cd2fa6ee8ea199b1775e29f006b10 (diff)
downloadbsdgames-darwin-d604c014c0bc6f72ada916fbfa3d1dd5bdb360c9.tar.gz
bsdgames-darwin-d604c014c0bc6f72ada916fbfa3d1dd5bdb360c9.tar.zst
bsdgames-darwin-d604c014c0bc6f72ada916fbfa3d1dd5bdb360c9.zip
Fix a bug in rwait() introduced during the select() to poll() conversion
that caused tetris to crash when pausing the game. Approved by tron.
Diffstat (limited to 'tetris')
-rw-r--r--tetris/input.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tetris/input.c b/tetris/input.c
index 867bb2e4..81087669 100644
--- a/tetris/input.c
+++ b/tetris/input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: input.c,v 1.6 2002/09/19 21:12:10 mycroft Exp $ */
+/* $NetBSD: input.c,v 1.7 2002/12/26 20:15:11 jmmv Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -80,7 +80,8 @@ rwait(tvp)
struct timeval *tvp;
{
struct pollfd set[1];
- struct timeval starttv, endtv, *s;
+ struct timeval starttv, endtv;
+ int timeout;
#define NILTZ ((struct timezone *)0)
/*
@@ -91,13 +92,13 @@ rwait(tvp)
if (tvp) {
(void) gettimeofday(&starttv, NILTZ);
endtv = *tvp;
- s = &endtv;
+ timeout = tvp->tv_sec * 1000 + tvp->tv_usec / 1000;
} else
- s = 0;
+ timeout = INFTIM;
again:
set[0].fd = STDIN_FILENO;
set[0].events = POLLIN;
- switch (poll(set, 1, s->tv_sec * 1000 + s->tv_usec / 1000)) {
+ switch (poll(set, 1, timeout)) {
case -1:
if (tvp == 0)