]> git.tdb.fi Git - gldbg.git/blobdiff - source/gldecoder.c
Enable warnings and fix them
[gldbg.git] / source / gldecoder.c
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;