On Mon, Aug 17, 2015 at 01:00:26PM -0300, Vinicios Barros wrote: > Hello all, > > I would like to suggest these changes to remove unused variables > and a respectively unnecessary call of the gettimeofday, also removes > a casting in the malloc, that seems to be unnecessary. >
I improved your diff a little bit to clean up more things. * Kill some unused includes; * Call poll() with time parameter direcly instead of doing some mathematical operations; * Kill commented fflush() code; I'll leave the malloc() bit to another diff, since it might be better and safer to replace it with a calloc(). Btw your diff wouldn't apply because your mail client fucked the spaces up. any oks? Index: worm.c =================================================================== RCS file: /cvs/src/games/worm/worm.c,v retrieving revision 1.28 diff -u -p -r1.28 worm.c --- worm.c 9 Mar 2015 19:52:02 -0000 1.28 +++ worm.c 21 Aug 2015 02:08:18 -0000 @@ -34,14 +34,10 @@ * UCSC */ -#include <sys/types.h> -#include <ctype.h> #include <curses.h> #include <err.h> #include <signal.h> #include <stdlib.h> -#include <string.h> -#include <time.h> #include <unistd.h> #include <poll.h> @@ -88,8 +84,6 @@ int main(int argc, char **argv) { int retval; - struct timeval t, tod; - struct timezone tz; struct pollfd pfd[1]; const char *errstr; @@ -158,14 +152,9 @@ main(int argc, char **argv) } else { - /* fflush(stdout); */ - /* Delay could be a command line option */ - t.tv_sec = 1; - t.tv_usec = 0; - (void)gettimeofday(&tod, &tz); pfd[0].fd = STDIN_FILENO; pfd[0].events = POLLIN; - retval = poll(pfd, 1, t.tv_sec * 1000 + t.tv_usec / 1000); + retval = poll(pfd, 1, 1000); if (retval > 0) process(getch()); else