]> git.tdb.fi Git - gldbg.git/commitdiff
Enable warnings and fix them
authorMikko Rasa <tdb@tdb.fi>
Wed, 4 Nov 2009 11:18:06 +0000 (11:18 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 4 Nov 2009 11:18:06 +0000 (11:18 +0000)
Makefile
gl.io
glx.io
source/enums.c
source/gldecoder.c
source/gldecoder.funcs.t
source/glprint.c
source/glprint.funcs.t
source/glwrap.c
source/glwrap.funcs.t

index a653678324a147aa950e926b0d1ea12aa1c3a224..226ff88a684d8c58a39088a2e6bc7f1b8b4aa956 100644 (file)
--- 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 027845b47d34bc2f67465910417b3524450bfa76..914ff295e321d0fb5cb66d9d5d538a22e2403c30 100644 (file)
--- 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 8fcad27ed9b9bb5b5662f8ddb835461a94a72254..78cbd61a94790176a8e1e18d5c85124e59533d09 100644 (file)
--- 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
index 25fdaefda4eaff4fc7fcc0957b81593de9d93257..d3572b8a0d185e8aad5eb9d4c910bff23fe9747d 100644 (file)
@@ -7,6 +7,7 @@ Distributed under the GPL
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include "enums.h"
 #include "tmpalloc.h"
 
index 863be925aeaaf55eee6961c9114ddaae7e0e3ebf..8d0f15a1287f57b555bdd6ca18b1269f72f1aa9d 100644 (file)
@@ -9,6 +9,7 @@ Distributed under the GPL
 #include <string.h>
 #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(len<sizeof(int)+sizeof(short))
                return -1;
-       pos += read_int(&pktlen, data);
+       pos += read_int((int *)&pktlen, data);
        if(len<pktlen)
                return -1;
-       pos += read_short(&func, data+pos);
+       pos += read_short((short *)&func, data+pos);
        if(dec)
        {
                if(func&0x8000)
@@ -83,13 +84,7 @@ static unsigned read_long(long *v, const char *data)
        return sizeof(long);
 }
 
-static unsigned read_ulong(unsigned long *v, const char *data)
-{
-       *v = *(unsigned long *)data;
-       return sizeof(unsigned long);
-}
-
-static unsigned read_longlong(long long *v, const char *data)
+static unsigned read_long_long(long long *v, const char *data)
 {
        *v = *(long long *)data;
        return sizeof(long long);
@@ -107,7 +102,9 @@ static unsigned read_double(double *v, const char *data)
        return sizeof(double);
 }
 
-static unsigned read_pointer(void **v, const char *data)
+typedef void *pointer;
+
+static unsigned read_pointer(pointer *v, const char *data)
 {
        *v = *(void **)data;
        return sizeof(void *);
@@ -125,18 +122,20 @@ static unsigned read_data(const void **v, const char *data)
        return pos+vlen;
 }
 
-static unsigned read_string(const unsigned char **v, const char *data)
+typedef const char *string;
+
+static unsigned read_string(string *v, const char *data)
 {
        return read_data((const void **)v, data);
 }
 
-static unsigned read_string_array(const unsigned char ***v, const char *data)
+static unsigned read_string_array(string **v, const char *data)
 {
        int count;
        unsigned pos = 0;
        int i;
        pos += read_int(&count, data);
-       *v = (const unsigned char **)tmpalloc(count*sizeof(const unsigned char *));
+       *v = (string *)tmpalloc(count*sizeof(string));
        for(i=0; i<count; ++i)
                pos += read_string(*v+i, data+pos);
        return pos;
@@ -148,7 +147,7 @@ static int decode_gldError(GlDecoder *dec, const char *data)
 {
        unsigned pos = 0;
        GLenum code;
-       pos += read_int(&code, data);
+       pos += read_int((int *)&code, data);
        if(dec->gldError)
                dec->gldError(dec->user_data, code);
        return pos;
index 152b71b5155aef93a253215d9a87251a81948e87..e02c1e815277fca0833a47489ff0aff3e5fe0e74 100644 (file)
@@ -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:
index 9721463eff76a4f552f954886553b4cf8f6c244c..3f6db656ebb2064a620555b246d50bbaa8432b93 100644 (file)
@@ -8,6 +8,7 @@ Distributed under the GPL
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
 #include "arraysize.h"
 #include "enums.h"
 #include "glprint.h"
index db626c0539efecdb4a3530fb2b88f79625198a04..cc459790308eab864af19aebd93804dd3c181426 100644 (file)
@@ -18,7 +18,7 @@ for p in params:
                if p.io:
                        w('{%s}', p.io[1])
                else:
-                       w('<ref:%s>', p.type)
+                       w('<ref:%s %%p>', 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)
index 79d6404d2a34b21cf9cfeb3bfb045e6ecb7bda0b..d51eb3192106b9ce94fa77b200a2c6797565f0de 100644 (file)
@@ -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<size; ++i)
                write_string(sa[i]);
index fbba906909d5e803a3037a43a8d1c85c953d232e..547d53f1529d91fcaeaf766a45b99a2becfb8ce3 100644 (file)
@@ -15,10 +15,10 @@ if ret.ctype!='void':
 wl('orig(%s);', ", ".join([p.name for p in params]))
 wl('   begin_packet(FUNC_%s);', func.name.upper())
 if ret.ctype!='void':
-       wl('    write_%s(ret);', ret.io[0])
+       wl('    write_%s(ret);', ret.io[0].replace(' ', '_'))
 for p in params:
        if p.kind=="value":
-               wl('    write_%s(%s);', p.io[0], p.name)
+               wl('    write_%s(%s);', p.io[0].replace(' ', '_'), p.name)
        elif p.kind=="array" and p.io and p.io[0]=="string":
                wl('  write_string_array(%s, %s);', p.name, p.csize)
        elif p.csize: