gcc and clang can check format strings of printf-like functions. Since we don't support any other compilers right now, enable that extension unconditionally.
Fix the bugs found by format string checking.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-printf_format_warning/flash.h =================================================================== --- flashrom-printf_format_warning/flash.h (Revision 1028) +++ flashrom-printf_format_warning/flash.h (Arbeitskopie) @@ -588,7 +588,8 @@ #define NT 1 /* Not tested */
/* cli_output.c */ -int print(int type, const char *fmt, ...); +/* Let gcc and clang check for correct printf-style format strings. */ +int print(int type, const char *fmt, ...) __attribute__((format(printf, 2, 3))); #define MSG_ERROR 0 #define MSG_INFO 1 #define MSG_DEBUG 2 Index: flashrom-printf_format_warning/flashrom.c =================================================================== --- flashrom-printf_format_warning/flashrom.c (Revision 1028) +++ flashrom-printf_format_warning/flashrom.c (Arbeitskopie) @@ -394,7 +394,7 @@ int register_shutdown(void (*function) (void *data), void *data) { if (shutdown_fn_count >= SHUTDOWN_MAXFN) { - msg_perr("Tried to register more than %n shutdown functions.\n", + msg_perr("Tried to register more than %i shutdown functions.\n", SHUTDOWN_MAXFN); return 1; } Index: flashrom-printf_format_warning/udelay.c =================================================================== --- flashrom-printf_format_warning/udelay.c (Revision 1028) +++ flashrom-printf_format_warning/udelay.c (Arbeitskopie) @@ -91,7 +91,7 @@ msg_pinfo("Calibrating delay loop... "); resolution = measure_os_delay_resolution(); if (resolution) { - msg_pdbg("OS timer resolution is %u usecs, ", resolution); + msg_pdbg("OS timer resolution is %lu usecs, ", resolution); } else { msg_pinfo("OS timer resolution is unusable. "); }
On 6/3/10 5:04 PM, Carl-Daniel Hailfinger wrote:
gcc and clang can check format strings of printf-like functions. Since we don't support any other compilers right now, enable that extension unconditionally.
Fix the bugs found by format string checking.
Signed-off-by: Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net
Acked-by: Sean Nelson audiohacked@gmail.com
On 05.06.2010 00:54, Sean Nelson wrote:
On 6/3/10 5:04 PM, Carl-Daniel Hailfinger wrote:
gcc and clang can check format strings of printf-like functions. Since we don't support any other compilers right now, enable that extension unconditionally.
Fix the bugs found by format string checking.
Signed-off-by: Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net
Acked-by: Sean Nelson audiohacked@gmail.com
Thanks, committed in r1032.
Regards, Carl-Daniel