]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Fix clang warnings
authorDale Weiler <killfieldengine@gmail.com>
Tue, 17 Apr 2012 21:31:07 +0000 (17:31 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Tue, 17 Apr 2012 21:31:07 +0000 (17:31 -0400)
Makefile
gmqcc.h
lex.c
parse.c
util.c

index 9d1faf52202a644454afe96c6f297013e7fe60eb..10198d069d5756d56c71f7b50b0847a2e4471088 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CC      = gcc
+CC      = clang
 CFLAGS += -Wall
 OBJ     = main.o      \
           lex.o       \
diff --git a/gmqcc.h b/gmqcc.h
index ae2b8f189d22d605ebf2f4ef5cf54a4e68abc1dd..f62e3c62f519a02ba13ab6619428e9a3d9ca6788 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -67,7 +67,7 @@ typedef char int16_size_if_correct  [sizeof(int16_t)  == 2?1:-1];
 typedef char int32_size_is_correct  [sizeof(int32_t)  == 4?1:-1];
 /* intptr_t / uintptr_t correct size check */
 typedef char uintptr_size_is_correct[sizeof(intptr_t) == sizeof(int*)?1:-1];
-typedef char uintptr_size_is_correct[sizeof(uintptr_t)== sizeof(int*)?1:-1];
+typedef char intptr_size_is_correct [sizeof(uintptr_t)== sizeof(int*)?1:-1];
 
 //===================================================================
 //============================ lex.c ================================
diff --git a/lex.c b/lex.c
index 48f58d8f6e81683a429823035af526f82b24e3e8..f30073fc9fdcc48aa8e9e16987c0c42559ada90e 100644 (file)
--- a/lex.c
+++ b/lex.c
@@ -293,7 +293,7 @@ int lex_token(struct lex_file *file) {
         
         /* look inside the table for a keyword .. */
         for (it = 0; it < sizeof(lex_keywords)/sizeof(*lex_keywords); it++)
-            if (!strncmp(file->lastok, lex_keywords[it], sizeof(lex_keywords[it])))
+            if (!strncmp(file->lastok, lex_keywords[it], strlen(lex_keywords[it])))
                 return it;
                 
         /* try a type? */
diff --git a/parse.c b/parse.c
index 8e7f0a65298730ded7e0bafa3848eb4f84c8b6e0..2d52efdec35e8b14e6c4f4854b6ef669d33e3d9e 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -293,7 +293,7 @@ int parse_gen(struct lex_file *file) {
     lex_reset(file);
     /* free constants */
     {
-               size_t i;
+               size_t i = 0;
                for (; i < compile_constants_elements; i++) {
                        mem_d(compile_constants_data[i].name);
                        mem_d(compile_constants_data[i].string);
diff --git a/util.c b/util.c
index 3f085eae6429623b94a9437f9b33b3b22de8d3a9..5b66524799ee9bec543e545dbf8947b28ae47abe 100644 (file)
--- a/util.c
+++ b/util.c
@@ -43,7 +43,7 @@ void *util_memory_a(unsigned int byte, unsigned int line, const char *file) {
     info->byte = byte;
     info->file = file;
     
-    util_debug("MEM", "allocation: %08u (bytes) address 0x%08X @ %s:%u\n", byte, data, file, line);
+    util_debug("MEM", "allocation: % 8u (bytes) address 0x%08X @ %s:%u\n", byte, data, file, line);
     mem_at++;
     mem_ab += info->byte;
     return data;
@@ -54,7 +54,7 @@ void util_memory_d(void *ptrn, unsigned int line, const char *file) {
     void              *data = (void*)((uintptr_t)ptrn-sizeof(struct memblock_t));
     struct memblock_t *info = (struct memblock_t*)data;
     
-    util_debug("MEM", "released:   %08u (bytes) address 0x%08X @ %s:%u\n", info->byte, data, file, line);
+    util_debug("MEM", "released:   % 8u (bytes) address 0x%08X @ %s:%u\n", info->byte, data, file, line);
     mem_db += info->byte;
     mem_dt++;
     free(data);
@@ -142,7 +142,7 @@ void util_debug(const char *area, const char *ms, ...) {
     va_start(va, ms);
     fprintf (stdout, "DEBUG: ");
     fputc   ('[',  stdout);
-    fprintf (stdout, area);
+    fprintf(stdout, "%s",area);
     fputs   ("] ", stdout);
     vfprintf(stdout, ms, va);
     va_end  (va);
@@ -177,13 +177,14 @@ int util_getline(char **lineptr, size_t *n, FILE *stream) {
             
             chr = *n + *lineptr - pos;
             strcpy(tmp,*lineptr);
-            if (!(*lineptr = tmp))
+            if (!(*lineptr = tmp)) {
+                               mem_d (tmp);
                 return -1;
-                
+            } 
             pos = *n - chr + *lineptr;
         }
 
-        if (ferror(stream)) 
+        if (ferror(stream))
             return -1;
         if (c == EOF) {
             if (pos == *lineptr)