[hatari-devel] Using more GCC warnings?
Eero Tamminen
oak at helsinkinet.fi
Fri Sep 17 23:20:04 CEST 2010
Hi,
I was contemplating adding few more warning options to Hatari
GCC compilation flags:
--- a/CMakeLists.txt Sat Sep 18 00:09:34 2010 +0300
+++ b/CMakeLists.txt Sat Sep 18 00:19:17 2010 +0300
@@ -175,7 +175,8 @@
- set(CMAKE_C_FLAGS "-Wall -Wwrite-strings -Wsign-compare
${CMAKE_C_FLAGS}")
+ set(CMAKE_C_FLAGS "-Wall -Wextra -Wwrite-strings ${CMAKE_C_FLAGS}")
+ set(CMAKE_C_FLAGS "-Wformat-security -DFORTIFY_SOURCE=2
${CMAKE_C_FLAGS}
See:
http://wiki.debian.org/Hardening#DEBBUILDHARDENINGFORMAT.28gcc.2BAC8-g.2B-.2B--Wformat-Wformat-security.29
(-Wextra already include -Wsign-compare check and -Wall includes -Wformat.)
I already fixed couple of things this complains about, but quite a few
functions would need after -Wextra to be explicitly declared as not using
all of the arguments given to them. What do you think of adding stuff like
this:
--- a/src/includes/main.h Sat Sep 18 00:09:34 2010 +0300
+++ b/src/includes/main.h Sat Sep 18 00:13:08 2010 +0300
@@ -24,10 +24,16 @@
+/*
+ * Portable wrappers around useful GCC extensions, see:
+ * http://blog.rlove.org/2005/10/with-little-help-from-your-compiler.html
+ */
#if __GNUC__ >= 3
+# define __unused __attribute__ ((unused))
# define likely(x) __builtin_expect (!!(x), 1)
# define unlikely(x) __builtin_expect (!!(x), 0)
#else
+# define __unused /* no unused */
--- a/src/debug/debugInfo.c Sat Sep 18 00:09:34 2010 +0300
+++ b/src/debug/debugInfo.c Sat Sep 18 00:13:08 2010 +0300
@@ -569,7 +569,7 @@
-static void DebugInfo_Default(Uint32 dummy)
+static void DebugInfo_Default(Uint32 dummy __unused)
?
- Eero
More information about the hatari-devel
mailing list