On Fri, Nov 07, 2014 at 11:57:50AM -0800, patrick keshishian wrote: [...]
> > > > I propose getting rid of the s pointer all together as such: > > After replacing select() with poll(), not removing > `struct timeval *s' seems an oversight; Its use was > solely for select()'s benefit. > > Once more, proposing removal of `struct timeval *s' and > using an `int timo' for the time-out value, that gets fed > into poll(). It also improves readability of the code; > rumors floating around that that is a good thing. > > Index: input.c > =================================================================== > RCS file: /cvs/obsd/src/games/tetris/input.c,v > retrieving revision 1.14 > diff -u -p -u -r1.14 input.c > --- input.c 5 Nov 2014 20:23:38 -0000 1.14 > +++ input.c 7 Nov 2014 19:37:07 -0000 > @@ -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); [...] I believe this mail was overlooked since patrick's solution is surely better than mine that went in. If somebody finds the time to submit this patch, that would be great.