From ed7e6e31f2aa8c76223da4ba198cfb0f8c6a8612 Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 16 Nov 2003 11:26:54 +0000 Subject: [PATCH] * configure.ac: + Added -Wsign-compare to the warning flags. * libcaca/caca.c: + Fixed a signed/unsigned bug that caused infinite waits with ee_set_delay(0). * src/weapons.c libcaca/graphics.c libcaca/blit.c libcaca/conic.c: + Fixed minor signed/unsigned comparison warnings. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@188 92316355-f0b4-4df1-b90c-862c8a59935f --- configure.ac | 2 +- libcaca/blit.c | 4 ++-- libcaca/caca.c | 8 ++++---- libcaca/conic.c | 8 ++++---- libcaca/graphics.c | 9 +++++---- src/weapons.c | 5 +++-- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/configure.ac b/configure.ac index 463dbab..10c5451 100644 --- a/configure.ac +++ b/configure.ac @@ -56,7 +56,7 @@ AM_CONDITIONAL(USE_NCURSES, ${USE_NCURSES}) # Optimizations CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer" # Code qui fait des warnings == code de porc == deux baffes dans ta gueule -CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs" +CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare" AC_OUTPUT([ Makefile diff --git a/libcaca/blit.c b/libcaca/blit.c index 44712d3..23bcc89 100644 --- a/libcaca/blit.c +++ b/libcaca/blit.c @@ -51,8 +51,8 @@ void caca_blit(int x1, int y1, int x2, int y2, void *pixels, int w, int h) pitch = (3 * w + 3) / 4 * 4; - for(y = y1 > 0 ? y1 : 0; y <= y2 && y <= caca_get_height(); y++) - for(x = x1 > 0 ? x1 : 0; x <= x2 && x <= caca_get_width(); x++) + for(y = y1 > 0 ? y1 : 0; y <= y2 && y <= (int)caca_get_height(); y++) + for(x = x1 > 0 ? x1 : 0; x <= x2 && x <= (int)caca_get_width(); x++) { int fromx = w * (x - x1) / (x2 - x1 + 1); int fromy = h * (y - y1) / (y2 - y1 + 1); diff --git a/libcaca/caca.c b/libcaca/caca.c index 86e3f08..59948c0 100644 --- a/libcaca/caca.c +++ b/libcaca/caca.c @@ -257,8 +257,8 @@ static unsigned int _caca_getticks(void) void caca_refresh(void) { #define IDLE_USEC 10000 - static unsigned int lastticks = 0; - unsigned int ticks = lastticks + _caca_getticks(); + static int lastticks = 0; + int ticks = lastticks + _caca_getticks(); #if defined(USE_SLANG) SLsmg_refresh(); @@ -274,7 +274,7 @@ void caca_refresh(void) /* Wait until _caca_delay + time of last call */ ticks += _caca_getticks(); - for(; ticks < _caca_delay - IDLE_USEC; ticks += _caca_getticks()) + for(; ticks + IDLE_USEC < (int)_caca_delay; ticks += _caca_getticks()) usleep(IDLE_USEC); /* Update the sliding mean of the render time */ @@ -283,7 +283,7 @@ void caca_refresh(void) lastticks = ticks - _caca_delay; /* If we drifted too much, it's bad, bad, bad. */ - if(lastticks > _caca_delay) + if(lastticks > (int)_caca_delay) lastticks = 0; } diff --git a/libcaca/conic.c b/libcaca/conic.c index bcbb5df..774be6d 100644 --- a/libcaca/conic.c +++ b/libcaca/conic.c @@ -183,13 +183,13 @@ static void ellipsepoints(int xo, int yo, int x, int y, char c) { uint8_t b = 0; - if(xo + x >= 0 && xo + x < caca_get_width()) + if(xo + x >= 0 && xo + x < (int)caca_get_width()) b |= 0x1; - if(xo - x >= 0 && xo - x < caca_get_width()) + if(xo - x >= 0 && xo - x < (int)caca_get_width()) b |= 0x2; - if(yo + y >= 0 && yo + y < caca_get_height()) + if(yo + y >= 0 && yo + y < (int)caca_get_height()) b |= 0x4; - if(yo - y >= 0 && yo - y < caca_get_height()) + if(yo - y >= 0 && yo - y < (int)caca_get_height()) b |= 0x8; if((b & (0x1|0x4)) == (0x1|0x4)) diff --git a/libcaca/graphics.c b/libcaca/graphics.c index d8ac046..0896abc 100644 --- a/libcaca/graphics.c +++ b/libcaca/graphics.c @@ -63,7 +63,8 @@ int caca_get_color(void) void caca_putchar(int x, int y, char c) { - if(x < 0 || x >= caca_get_width() || y < 0 || y >= caca_get_height()) + if(x < 0 || x >= (int)caca_get_width() || + y < 0 || y >= (int)caca_get_height()) return; #if defined(USE_SLANG) @@ -82,9 +83,9 @@ void caca_putchar(int x, int y, char c) void caca_putstr(int x, int y, const char *s) { - int len; + unsigned int len; - if(y < 0 || y >= caca_get_height() || x >= caca_get_width()) + if(y < 0 || y >= (int)caca_get_height() || x >= (int)caca_get_width()) return; len = strlen(s); @@ -129,7 +130,7 @@ void caca_printf(int x, int y, const char *format, ...) char *buf = tmp; va_list args; - if(y < 0 || y >= caca_get_height() || x >= caca_get_width()) + if(y < 0 || y >= (int)caca_get_height() || x >= (int)caca_get_width()) return; if(caca_get_width() - x + 1 > BUFSIZ) diff --git a/src/weapons.c b/src/weapons.c index 9e3f88f..b95e349 100644 --- a/src/weapons.c +++ b/src/weapons.c @@ -49,7 +49,7 @@ void init_weapons(game *g, weapons *wp) void draw_weapons(game *g, weapons *wp) { - int i; + unsigned int i; for(i = 0; i < WEAPONS; i++) { @@ -95,7 +95,8 @@ void draw_weapons(game *g, weapons *wp) void update_weapons(game *g, weapons *wp) { - int i, j, dist, xmin, ymin, dx, dy, xnew, ynew; + unsigned int i, j; + int dist, xmin, ymin, dx, dy, xnew, ynew; for(i = 0; i < WEAPONS; i++) {