From 22357decdbdd612a00bcfa9291b767e6f068fd9f Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 19 Feb 2013 22:06:09 -0500 Subject: Enable and fix a bunch of GCC warnings. --- diff --git a/configure.ac b/configure.ac index 9e8e2c1..4a28c1c 100644 --- a/configure.ac +++ b/configure.ac @@ -28,7 +28,17 @@ PKG_CHECK_MODULES([EXPAT], [expat]) if test "x$GCC" = "xyes"; then GCC_CFLAGS="-pedantic -Wall -Wextra -Werror" GCC_CFLAGS="${GCC_CFLAGS} -Wformat=2 -Wswitch -Wswitch-enum" - GCC_CFLAGS="${GCC_CFLAGS} -Wstrict-prototypes -Wmissing-prototypes" + GCC_CFLAGS="${GCC_CFLAGS} -Wdeclaration-after-statement -Wundef -Wshadow" + GCC_CFLAGS="${GCC_CFLAGS} -Wpointer-arith -Wbad-function-cast" + GCC_CFLAGS="${GCC_CFLAGS} -Wcast-qual -Wcast-align -Wwrite-strings" + #GCC_CFLAGS="${GCC_CFLAGS} -Wconversion" + GCC_CFLAGS="${GCC_CFLAGS} -Wlogical-op -Waggregate-return" + GCC_CFLAGS="${GCC_CFLAGS} -Wstrict-prototypes -Wold-style-definition" + GCC_CFLAGS="${GCC_CFLAGS} -Wmissing-prototypes -Wmissing-declarations" + GCC_CFLAGS="${GCC_CFLAGS} -Wredundant-decls -Wnested-externs" + GCC_CFLAGS="${GCC_CFLAGS} -Wunreachable-code -Winline" + GCC_CFLAGS="${GCC_CFLAGS} -Wdisabled-optimization" + GCC_CFLAGS="${GCC_CFLAGS} -fstack-protector -Wstack-protector" fi AC_SUBST(GCC_CFLAGS) diff --git a/src/base64.c b/src/base64.c index 6a2c873..d8f5669 100644 --- a/src/base64.c +++ b/src/base64.c @@ -4,7 +4,8 @@ static void base64_decode_block(const char *src, char *dest) { int i; - char buf[4]; + /* GCC's SSP won't wrap functions with arrays smaller than 8 bytes. */ + char buf[8]; /* Convert base 64 characters into values. */ /* Supports ASCII and EBCDIC systems. */ diff --git a/src/compression.c b/src/compression.c index 5f71950..2dac4e5 100644 --- a/src/compression.c +++ b/src/compression.c @@ -36,7 +36,7 @@ zlib_err(int status) } void -decompress(const char *src, size_t src_len, char *dest, size_t dest_len) +decompress(char *src, size_t src_len, char *dest, size_t dest_len) { z_stream d_stream; diff --git a/src/compression.h b/src/compression.h index 387d634..ffa8dc0 100644 --- a/src/compression.h +++ b/src/compression.h @@ -1,6 +1,6 @@ #ifndef COMPRESSION_H #define COMPRESSION_H -void decompress(const char *src, size_t src_len, char *dest, size_t dest_len); +void decompress(char *src, size_t src_len, char *dest, size_t dest_len); #endif diff --git a/src/resources/resource.c b/src/resources/resource.c index ebfcf27..90df5c2 100644 --- a/src/resources/resource.c +++ b/src/resources/resource.c @@ -4,7 +4,7 @@ #include "../logging.h" -inline void * +void * resource_alloc(const char *path, size_t size) { void *new_res; diff --git a/src/resources/resource.h b/src/resources/resource.h index ada91fd..5bec5e8 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -12,7 +12,7 @@ struct resource { struct resource *next; }; -extern inline void *resource_alloc(const char *path, size_t size); +void *resource_alloc(const char *path, size_t size); struct resource *resource_get(struct resource_table *resources, const char *path); void resource_add(struct resource_table *resources, const char *path, diff --git a/src/viewport.c b/src/viewport.c index 05b30a6..5f7805f 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -3,7 +3,7 @@ #include "logging.h" struct viewport * -init_viewport(int width, int height, int bpp) +init_viewport(Uint16 width, Uint16 height, int bpp) { struct viewport *vp; diff --git a/src/viewport.h b/src/viewport.h index 372a285..f21c583 100644 --- a/src/viewport.h +++ b/src/viewport.h @@ -4,13 +4,13 @@ #include struct viewport { - int x; - int y; - int w; - int h; + Sint16 x; + Sint16 y; + Uint16 w; + Uint16 h; SDL_Surface *screen; }; -struct viewport *init_viewport(int width, int height, int bpp); +struct viewport *init_viewport(Uint16 width, Uint16 height, int bpp); #endif diff --git a/src/xml.c b/src/xml.c index b10b4c7..e677fe1 100644 --- a/src/xml.c +++ b/src/xml.c @@ -14,13 +14,13 @@ struct xml_node { struct xml_node *parent; }; -inline int +int xml_check_tag(const char *found, const char *expected) { return strcmp(found, expected) == 0; } -inline void +void xml_unexpected_start_tag(XML_Parser p, const char *found, const char *expected) { warn("Found \"%s\" start tag where expected one of \"%s\" in map", @@ -28,7 +28,7 @@ xml_unexpected_start_tag(XML_Parser p, const char *found, const char *expected) XML_StopParser(p, XML_FALSE); } -inline void +void xml_unexpected_end_tag(XML_Parser p, const char *found, const char *expected) { warn("Found \"%s\" end tag where expected one of \"%s\" in map", diff --git a/src/xml.h b/src/xml.h index f3fc879..5b78e78 100644 --- a/src/xml.h +++ b/src/xml.h @@ -4,10 +4,10 @@ #include #include -extern inline int xml_check_tag(const char *found, const char *expected); -extern inline void xml_unexpected_start_tag(XML_Parser p, const char *found, +int xml_check_tag(const char *found, const char *expected); +void xml_unexpected_start_tag(XML_Parser p, const char *found, const char *expected); -extern inline void xml_unexpected_end_tag(XML_Parser p, const char *found, +void xml_unexpected_end_tag(XML_Parser p, const char *found, const char *expected); void xml_get_int_attr(XML_Parser p, const char **attr, const char *name, int *dest, int req); -- cgit v0.9.1