X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fworm.c;h=92bdb254986719d46a2fb42c53a70a11ea14a260;hp=1f0a6fcb3fe389aa7eb8d8cf91dc140270844501;hb=58552e8c761a70f8f0bd591fecdf576fa8216e3e;hpb=91fa4688e82518794fcf0c32a36f3fcca5e4c2d5 diff --git a/test/worm.c b/test/worm.c index 1f0a6fcb..92bdb254 100644 --- a/test/worm.c +++ b/test/worm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2008,2012 Free Software Foundation, Inc. * + * Copyright (c) 1998-2013,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -61,7 +61,7 @@ Options: traces will be dumped. The program stops and waits for one character of input at the beginning and end of the interval. - $Id: worm.c,v 1.61 2012/10/27 19:37:17 tom Exp $ + $Id: worm.c,v 1.66 2016/09/17 21:12:30 tom Exp $ */ #include @@ -217,7 +217,7 @@ cleanup(void) endwin(); } -static RETSIGTYPE +static void onsig(int sig GCC_UNUSED) { cleanup(); @@ -324,9 +324,9 @@ draw_worm(WINDOW *win, void *data) static bool quit_worm(int bitnum) { - pending |= (1 << bitnum); + pending = (pending | (unsigned) (1 << bitnum)); napms(10); /* let the other thread(s) have a chance */ - pending &= ~(1 << bitnum); + pending = (pending & (unsigned) ~(1 << bitnum)); return quitting; } @@ -335,7 +335,7 @@ start_worm(void *arg) { unsigned long compare = 0; Trace(("start_worm")); - while (!quit_worm(((struct worm *) arg) - worm)) { + while (!quit_worm((int) (((struct worm *) arg) - worm))) { while (compare < sequence) { ++compare; #if HAVE_USE_WINDOW @@ -362,8 +362,7 @@ draw_all_worms(void) if (first) { first = FALSE; for (n = 0, w = &worm[0]; n < number; n++, w++) { - int rc; - rc = pthread_create(&(w->thread), NULL, start_worm, w); + (void) pthread_create(&(w->thread), NULL, start_worm, w); } } #else @@ -431,6 +430,7 @@ main(int argc, char *argv[]) struct worm *w; int *ip; bool done = FALSE; + int max_refs; setlocale(LC_ALL, ""); @@ -501,7 +501,7 @@ main(int argc, char *argv[]) #define SET_COLOR(num, fg) \ init_pair(num+1, (short) fg, (short) bg); \ - flavor[num] |= COLOR_PAIR(num+1) | A_BOLD + flavor[num] |= (chtype) COLOR_PAIR(num+1) | A_BOLD SET_COLOR(0, COLOR_GREEN); SET_COLOR(1, COLOR_RED); @@ -513,8 +513,9 @@ main(int argc, char *argv[]) } #endif /* A_COLOR */ - refs = typeMalloc(int *, (size_t) LINES); - for (y = 0; y < LINES; y++) { + max_refs = LINES; + refs = typeMalloc(int *, (size_t) max_refs); + for (y = 0; y < max_refs; y++) { refs[y] = typeMalloc(int, (size_t) COLS); for (x = 0; x < COLS; x++) { refs[y][x] = 0; @@ -608,7 +609,7 @@ main(int argc, char *argv[]) Trace(("Cleanup")); cleanup(); #ifdef NO_LEAKS - for (y = 0; y < LINES; y++) { + for (y = 0; y < max_refs; y++) { free(refs[y]); } free(refs);