Only switch on printf format warnings for error_exit() and friends when TOYBOX_DEBUG...
authorRob Landley <rob@landley.net>
Sun, 1 Mar 2015 22:35:05 +0000 (16:35 -0600)
committerRob Landley <rob@landley.net>
Sun, 1 Mar 2015 22:35:05 +0000 (16:35 -0600)
One again gcc manages to be incompetent about producing warnings. For example,
in bzcat we error_exit() with a message that's an error code fed into an
array of string constants, and apparently dereferencing an array of string
literals doesn't give you a string literal according to -Wformat-security.

Not breaking the code to humor the compiler here, the compiler is wrong.

lib/portability.h

index 809f376..a10213e 100644 (file)
 
 #ifdef __GNUC__
 #define noreturn       __attribute__((noreturn))
+#if CFG_TOYBOX_DEBUG
 #define printf_format  __attribute__((format(printf, 1, 2)))
 #else
+#define printf_format
+#endif
+#else
 #define noreturn
 #define printf_format
 #endif