Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/tetris Fix a bug in rwait() introduced during the sele...



details:   https://anonhg.NetBSD.org/src/rev/ac1f7936f024
branches:  trunk
changeset: 540858:ac1f7936f024
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Thu Dec 26 20:15:11 2002 +0000

description:
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:

 games/tetris/input.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (36 lines):

diff -r d7b9df127d1e -r ac1f7936f024 games/tetris/input.c
--- a/games/tetris/input.c      Thu Dec 26 19:17:23 2002 +0000
+++ b/games/tetris/input.c      Thu Dec 26 20:15:11 2002 +0000
@@ -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 @@
        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 @@
        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)



Home | Main Index | Thread Index | Old Index