[PATCH] repair: check repair message printflike arguments

Eric Sandeen sandeen at sandeen.net
Tue Mar 16 17:37:03 CDT 2010


Unfortunately this lights up warnings like a christmas tree,
but it does catch a few gems like:

scan.c:567: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘const char *’

passing a string to a %d :(

Signed-off-by: Eric Sandeen <sandeen at sandeen.net>
---

diff --git a/repair/err_protos.h b/repair/err_protos.h
index 6944950..2e3bf97 100644
--- a/repair/err_protos.h
+++ b/repair/err_protos.h
@@ -17,10 +17,12 @@
  */
 
 /* abort, internal error */
-void  __attribute__((noreturn)) do_abort(char const *, ...);
+void do_abort(char const *, ...)
+	__attribute__((format (printf, 1, 2))) __attribute__((noreturn));
 /* abort, system error */
-void  __attribute__((noreturn)) do_error(char const *, ...);
+void do_error(char const *, ...) __attribute__((noreturn));
+	__attribute__((format (printf, 1, 2))) __attribute__((noreturn));
 /* issue warning */
-void do_warn(char const *, ...);
+void do_warn(char const *, ...) __attribute__ ((format (printf, 1, 2)));
 /* issue log message */
-void do_log(char const *, ...);
+void do_log(char const *, ...) __attribute__ ((format (printf, 1, 2)));




More information about the xfs mailing list