+ 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-862c8a59935fmaster
@@ -56,7 +56,7 @@ AM_CONDITIONAL(USE_NCURSES, ${USE_NCURSES}) | |||||
# Optimizations | # Optimizations | ||||
CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer" | CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer" | ||||
# Code qui fait des warnings == code de porc == deux baffes dans ta gueule | # 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([ | AC_OUTPUT([ | ||||
Makefile | Makefile | ||||
@@ -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; | 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 fromx = w * (x - x1) / (x2 - x1 + 1); | ||||
int fromy = h * (y - y1) / (y2 - y1 + 1); | int fromy = h * (y - y1) / (y2 - y1 + 1); | ||||
@@ -257,8 +257,8 @@ static unsigned int _caca_getticks(void) | |||||
void caca_refresh(void) | void caca_refresh(void) | ||||
{ | { | ||||
#define IDLE_USEC 10000 | #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) | #if defined(USE_SLANG) | ||||
SLsmg_refresh(); | SLsmg_refresh(); | ||||
@@ -274,7 +274,7 @@ void caca_refresh(void) | |||||
/* Wait until _caca_delay + time of last call */ | /* Wait until _caca_delay + time of last call */ | ||||
ticks += _caca_getticks(); | 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); | usleep(IDLE_USEC); | ||||
/* Update the sliding mean of the render time */ | /* Update the sliding mean of the render time */ | ||||
@@ -283,7 +283,7 @@ void caca_refresh(void) | |||||
lastticks = ticks - _caca_delay; | lastticks = ticks - _caca_delay; | ||||
/* If we drifted too much, it's bad, bad, bad. */ | /* If we drifted too much, it's bad, bad, bad. */ | ||||
if(lastticks > _caca_delay) | |||||
if(lastticks > (int)_caca_delay) | |||||
lastticks = 0; | lastticks = 0; | ||||
} | } | ||||
@@ -183,13 +183,13 @@ static void ellipsepoints(int xo, int yo, int x, int y, char c) | |||||
{ | { | ||||
uint8_t b = 0; | 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; | b |= 0x1; | ||||
if(xo - x >= 0 && xo - x < caca_get_width()) | |||||
if(xo - x >= 0 && xo - x < (int)caca_get_width()) | |||||
b |= 0x2; | b |= 0x2; | ||||
if(yo + y >= 0 && yo + y < caca_get_height()) | |||||
if(yo + y >= 0 && yo + y < (int)caca_get_height()) | |||||
b |= 0x4; | b |= 0x4; | ||||
if(yo - y >= 0 && yo - y < caca_get_height()) | |||||
if(yo - y >= 0 && yo - y < (int)caca_get_height()) | |||||
b |= 0x8; | b |= 0x8; | ||||
if((b & (0x1|0x4)) == (0x1|0x4)) | if((b & (0x1|0x4)) == (0x1|0x4)) | ||||
@@ -63,7 +63,8 @@ int caca_get_color(void) | |||||
void caca_putchar(int x, int y, char c) | 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; | return; | ||||
#if defined(USE_SLANG) | #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) | 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; | return; | ||||
len = strlen(s); | len = strlen(s); | ||||
@@ -129,7 +130,7 @@ void caca_printf(int x, int y, const char *format, ...) | |||||
char *buf = tmp; | char *buf = tmp; | ||||
va_list args; | 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; | return; | ||||
if(caca_get_width() - x + 1 > BUFSIZ) | if(caca_get_width() - x + 1 > BUFSIZ) | ||||
@@ -49,7 +49,7 @@ void init_weapons(game *g, weapons *wp) | |||||
void draw_weapons(game *g, weapons *wp) | void draw_weapons(game *g, weapons *wp) | ||||
{ | { | ||||
int i; | |||||
unsigned int i; | |||||
for(i = 0; i < WEAPONS; 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) | 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++) | for(i = 0; i < WEAPONS; i++) | ||||
{ | { | ||||