From 9f5f2158a743fc2d7de63c05d38d8133c6b4d15d Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Fri, 4 Jun 2010 23:20:21 +0000 Subject: 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. Corresponding to flashrom svn r1032. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Sean Nelson --- flash.h | 3 ++- flashrom.c | 2 +- udelay.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/flash.h b/flash.h index 84ee5118c..cf3bd21ca 100644 --- a/flash.h +++ b/flash.h @@ -591,7 +591,8 @@ int doit(struct flashchip *flash, int force, char *filename, int read_it, int wr #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 diff --git a/flashrom.c b/flashrom.c index 8a9745493..73145a9a7 100644 --- a/flashrom.c +++ b/flashrom.c @@ -394,7 +394,7 @@ struct shutdown_func_data { 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; } diff --git a/udelay.c b/udelay.c index b39597135..8bfba6399 100644 --- a/udelay.c +++ b/udelay.c @@ -91,7 +91,7 @@ void myusec_calibrate_delay(void) 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. "); } -- cgit v1.2.3