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 <[email protected]>

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. ");
        }


-- 
http://www.hailfinger.org/


_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to