From: Mikko Rasa Date: Wed, 4 Nov 2009 11:18:06 +0000 (+0000) Subject: Enable warnings and fix them X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=151c65f1157f3b55d0b794db788b557bbc50ed0c;p=gldbg.git Enable warnings and fix them --- diff --git a/Makefile b/Makefile index a653678..226ff88 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # $Id$ -CFLAGS = -Igensrc -ggdb -CXXFLAGS = -Igensrc -ggdb +CFLAGS = -Igensrc -ggdb -Wall -Wextra -Werror +CXXFLAGS = -Igensrc -ggdb -Wall -Wextra -Werror PACKAGES_gldbg = mspcore mspstrings mspio mspfs CXXFLAGS_gldbg = $(shell pkg-config --cflags $(PACKAGES_gldbg)) diff --git a/gl.io b/gl.io index 027845b..914ff29 100644 --- a/gl.io +++ b/gl.io @@ -12,8 +12,8 @@ sizei, int, %i intptr, int, %i sizeiptr, int, %i handle, int, %i -int64, longlong, %lli -uint64, longlong, %llu +int64, long long, %lli +uint64, long long, %llu half, short, %#x float, float, %g clampf, float, %g diff --git a/glx.io b/glx.io index 8fcad27..78cbd61 100644 --- a/glx.io +++ b/glx.io @@ -6,7 +6,7 @@ unsigned int, int, %u int32_t, int, %i long, long, %li unsigned long, long, %lu -int64_t, longlong, %lli +int64_t, long long, %lli sizei, int, %i float, float, %g unsigned int *, pointer, %p diff --git a/source/enums.c b/source/enums.c index 25fdaef..d3572b8 100644 --- a/source/enums.c +++ b/source/enums.c @@ -7,6 +7,7 @@ Distributed under the GPL #include #include +#include #include "enums.h" #include "tmpalloc.h" diff --git a/source/gldecoder.c b/source/gldecoder.c index 863be92..8d0f15a 100644 --- a/source/gldecoder.c +++ b/source/gldecoder.c @@ -9,6 +9,7 @@ Distributed under the GPL #include #include "functions.h" #include "gldecoder.h" +#include "tmpalloc.h" static unsigned read_short(short *, const char *); static unsigned read_int(int *, const char *); @@ -37,16 +38,16 @@ void gldecoder_delete(GlDecoder *dec) int gldecoder_decode(GlDecoder *dec, const char *data, unsigned len) { unsigned pos = 0; - int pktlen; + unsigned pktlen; unsigned short func; int ret; if(lengldError) dec->gldError(dec->user_data, code); return pos; diff --git a/source/gldecoder.funcs.t b/source/gldecoder.funcs.t index 152b71b..e02c1e8 100644 --- a/source/gldecoder.funcs.t +++ b/source/gldecoder.funcs.t @@ -1,5 +1,5 @@ # $Id$ -wl('static unsigned decode_%s(GlDecoder *dec, const char *data)', func.name) +wl('static unsigned decode_%s(GlDecoder *dec, const char *data __attribute__((unused)))', func.name) wl('{') wl(' unsigned pos = 0;') if ret.ctype!="void": @@ -7,10 +7,10 @@ if ret.ctype!="void": for p in params: wl(' %s p_%s;', p.ctype, p.name) if ret.ctype!="void": - wl(' pos += read_%s(&ret, data+pos);', ret.io[0]) + wl(' pos += read_%s((%s *)&ret, data+pos);', ret.io[0].replace(' ', '_'), ret.io[0]) for p in params: if p.kind=="value": - wl(' pos += read_%s(&p_%s, data+pos);', p.io[0], p.name) + wl(' pos += read_%s((%s *)&p_%s, data+pos);', p.io[0].replace(' ', '_'), p.io[0], p.name) elif p.kind=="array" and p.io and p.io[0]=="string": wl(' pos += read_string_array(&p_%s, data+pos);', p.name) elif p.csize: diff --git a/source/glprint.c b/source/glprint.c index 9721463..3f6db65 100644 --- a/source/glprint.c +++ b/source/glprint.c @@ -8,6 +8,7 @@ Distributed under the GPL #include #include #include +#include #include "arraysize.h" #include "enums.h" #include "glprint.h" diff --git a/source/glprint.funcs.t b/source/glprint.funcs.t index db626c0..cc45979 100644 --- a/source/glprint.funcs.t +++ b/source/glprint.funcs.t @@ -18,7 +18,7 @@ for p in params: if p.io: w('{%s}', p.io[1]) else: - w('', p.type) + w('', p.type) elif p.kind=="array": w('%%s') first = False @@ -37,6 +37,8 @@ for p in params+[ret]: elif p.kind=="reference": if p.io: w(', *%s', p.name) + else: + w(', %s', p.name) elif p.kind=="array": if not p.csize: w(', print_data(%s, 0)', p.name) diff --git a/source/glwrap.c b/source/glwrap.c index 79d6404..d51eb31 100644 --- a/source/glwrap.c +++ b/source/glwrap.c @@ -76,12 +76,7 @@ static inline void write_long(long v) write_bytes((char *)&v, sizeof(long)); } -static inline void write_ulong(unsigned long v) -{ - write_bytes((char *)&v, sizeof(unsigned long)); -} - -static inline void write_longlong(long long v) +static inline void write_long_long(long long v) { write_bytes((char *)&v, sizeof(long long)); } @@ -117,15 +112,15 @@ static inline void write_data(const void *data, unsigned size) write_int(0); } -static inline void write_string(const unsigned char *s) +static inline void write_string(const char *s) { write_data(s, strlen(s)+1); } -static inline void write_string_array(const unsigned char **sa, unsigned size) +static inline void write_string_array(const char **sa, unsigned size) { unsigned i; - size /= sizeof(const unsigned char *); + size /= sizeof(const char *); write_int(size); for(i=0; i