From: Dale Weiler Date: Tue, 17 Apr 2012 21:31:07 +0000 (-0400) Subject: Fix clang warnings X-Git-Tag: 0.1-rc1~650 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=32b804864ebfce0ed4f8ae891683d11c71ae389a;p=xonotic%2Fgmqcc.git Fix clang warnings --- diff --git a/Makefile b/Makefile index 9d1faf5..10198d0 100644 --- 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 ae2b8f1..f62e3c6 100644 --- 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 48f58d8..f30073f 100644 --- 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 8e7f0a6..2d52efd 100644 --- 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 3f085ea..5b66524 100644 --- 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)