From ca46503607f19443e0546c235ca317b77cfed679 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 13 Jul 2004 19:14:01 +0000 Subject: [PATCH] add -Wsign-compare (default for -Wall only in C++) and fix up the warnings --- configure.ac | 1 + libs/gib/gib_builtin.c | 2 +- libs/image/png.c | 10 +++++----- libs/ruamoko/rua_init.c | 2 +- libs/video/renderer/gl/gl_lightmap.c | 6 ++++-- qtv/source/client.c | 2 +- qtv/source/qtv.c | 2 +- qw/source/sv_pr_qwe.c | 2 +- qw/source/sv_send.c | 2 +- qw/source/sv_user.c | 3 ++- tools/qfcc/source/linker.c | 5 +++-- tools/qfcc/source/options.c | 4 ++-- tools/wad/wad.c | 2 +- 13 files changed, 24 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 5965c3b36..dbe20734b 100644 --- a/configure.ac +++ b/configure.ac @@ -1409,6 +1409,7 @@ if test "x$optimize" = xyes; then CFLAGS="" QF_CC_OPTION(-frename-registers) QF_CC_OPTION(-finline-limit=32000 -Winline) + QF_CC_OPTION(-Wsign-compare) heavy="-O2 $CFLAGS -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations" CFLAGS="$saved_cflags" light="-O2" diff --git a/libs/gib/gib_builtin.c b/libs/gib/gib_builtin.c index 8def62c46..00e8a57f0 100644 --- a/libs/gib/gib_builtin.c +++ b/libs/gib/gib_builtin.c @@ -719,7 +719,7 @@ GIB_Text_From_Decimal_f (void) if (GIB_Argc () < 2) GIB_USAGE ("num1 [...]"); else if (GIB_CanReturn ()) { - unsigned int i; + int i; dstring_t *dstr; char *str; diff --git a/libs/image/png.c b/libs/image/png.c index 1006738ee..f31d18f89 100644 --- a/libs/image/png.c +++ b/libs/image/png.c @@ -192,11 +192,11 @@ LoadPNG (QFile *infile) void WritePNG (const char *fileName, byte *data, int width, int height) { - QFile *outfile; - png_uint_32 i; - png_structp png_ptr; - png_infop info_ptr; - png_bytepp row_pointers = NULL; + QFile *outfile; + int i; + png_structp png_ptr; + png_infop info_ptr; + png_bytepp row_pointers = NULL; /* initialize write struct */ png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); diff --git a/libs/ruamoko/rua_init.c b/libs/ruamoko/rua_init.c index 40ad5998e..6fa0e9912 100644 --- a/libs/ruamoko/rua_init.c +++ b/libs/ruamoko/rua_init.c @@ -54,7 +54,7 @@ static void (*init_funcs[])(progs_t *, int) = { void RUA_Init (progs_t *pr, int secure) { - int i; + size_t i; PR_Resources_Init (pr); for (i = 0; i < sizeof (init_funcs) / sizeof (init_funcs[0]); i++) diff --git a/libs/video/renderer/gl/gl_lightmap.c b/libs/video/renderer/gl/gl_lightmap.c index fb19f92d9..c3a5f9c6b 100644 --- a/libs/video/renderer/gl/gl_lightmap.c +++ b/libs/video/renderer/gl/gl_lightmap.c @@ -114,7 +114,8 @@ static inline void R_AddDynamicLights_1 (msurface_t *surf) { float dist; - int maxdist, maxdist2, maxdist3, smax, smax_bytes, tmax, + unsigned int maxdist, maxdist2, maxdist3; + int smax, smax_bytes, tmax, grey, s, t; unsigned int lnum, td, i, j; unsigned int sdtable[18]; @@ -178,7 +179,8 @@ static inline void R_AddDynamicLights_3 (msurface_t *surf) { float dist; - int maxdist, maxdist2, maxdist3, smax, smax_bytes, tmax, + unsigned int maxdist, maxdist2, maxdist3; + int smax, smax_bytes, tmax, red, green, blue, s, t; unsigned int lnum, td, i, j; unsigned int sdtable[18]; diff --git a/qtv/source/client.c b/qtv/source/client.c index d51f9e29d..8fc1c406f 100644 --- a/qtv/source/client.c +++ b/qtv/source/client.c @@ -442,7 +442,7 @@ ucmds_getkey (void *_a, void *unused) void Client_Init (void) { - int i; + size_t i; ucmd_table = Hash_NewTable (251, ucmds_getkey, 0, 0); for (i = 0; i < sizeof (ucmds) / sizeof (ucmds[0]); i++) diff --git a/qtv/source/qtv.c b/qtv/source/qtv.c index 39dfede9a..8f0dd62a4 100644 --- a/qtv/source/qtv.c +++ b/qtv/source/qtv.c @@ -134,7 +134,7 @@ void qtv_flush_redirect (void) { char send[8000 + 6]; - int count; + size_t count; int bytes; const char *p; diff --git a/qw/source/sv_pr_qwe.c b/qw/source/sv_pr_qwe.c index 15884fb74..a23cb2ab2 100644 --- a/qw/source/sv_pr_qwe.c +++ b/qw/source/sv_pr_qwe.c @@ -544,7 +544,7 @@ qwe_user_cmd (void) static int qwe_load (progs_t * pr) { - int i; + size_t i; for (i = 0; i < sizeof (qwe_func_list) / sizeof (qwe_func_list[0]); i++) { dfunction_t *f = ED_FindFunction (pr, qwe_func_list[i].name); diff --git a/qw/source/sv_send.c b/qw/source/sv_send.c index bb4de8e16..ec5f0b176 100644 --- a/qw/source/sv_send.c +++ b/qw/source/sv_send.c @@ -72,7 +72,7 @@ static void SV_FlushRedirect (void) { char send[8000 + 6]; - int count; + size_t count; int bytes; const char *p; diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index c81f30a80..c277632ae 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -571,7 +571,8 @@ static void SV_NextDownload_f (void *unused) { byte buffer[768]; // FIXME protocol limit? could be bigger? - int percent, size, r; + int percent, size; + size_t r; if (!host_client->download) return; diff --git a/tools/qfcc/source/linker.c b/tools/qfcc/source/linker.c index 1e9b35089..5d67a5cf5 100644 --- a/tools/qfcc/source/linker.c +++ b/tools/qfcc/source/linker.c @@ -842,9 +842,10 @@ undefined_def (qfo_def_t *def) line = lines.lines + best->line_info; line_def.file = best->file; line_def.line = best->line; - if (!line->line && line->fa.func == best - funcs.funcs) { + if (!line->line + && line->fa.func == (unsigned int) (best - funcs.funcs)) { while (line - lines.lines < lines.num_lines - 1 && line[1].line - && line[1].fa.addr <= reloc->ofs) + && line[1].fa.addr <= (unsigned int) reloc->ofs) line++; line_def.line = line->line + best->line; } diff --git a/tools/qfcc/source/options.c b/tools/qfcc/source/options.c index 3ded420f7..48cdf953d 100644 --- a/tools/qfcc/source/options.c +++ b/tools/qfcc/source/options.c @@ -416,14 +416,14 @@ DecodeArgs (int argc, char **argv) options.traditional = true; options.advanced = false; options.code.progsversion = PROG_ID_VERSION; - if (options.code.short_circuit == -1) + if (options.code.short_circuit == (qboolean) -1) options.code.short_circuit = false; } if (!options.traditional) { options.advanced = true; add_cpp_def ("-D__RUAMOKO__=1"); add_cpp_def ("-D__RAUMOKO__=1"); - if (options.code.short_circuit == -1) + if (options.code.short_circuit == (qboolean) -1) options.code.short_circuit = true; } if (options.code.progsversion == PROG_ID_VERSION) diff --git a/tools/wad/wad.c b/tools/wad/wad.c index 20ba73f09..bf305a837 100644 --- a/tools/wad/wad.c +++ b/tools/wad/wad.c @@ -264,7 +264,7 @@ wad_extract (wad_t *wad, lumpinfo_t *pf) case TYP_PALETTE: count = 768; memset (buffer, 0, count); - if (count > pf->size) + if ((int) count > pf->size) count = pf->size; for (i = 0; i < 256; i++) buffer[i + 768] = i;