2005-03-14 01:19:19

by Marcelo Tosatti

[permalink] [raw]
Subject: [PATCH] Enable gcc warnings for vsprintf/vsnprintf with "format" attribute


Applied to v2.4 - v2.6 wants the same change.

Against v2.6-BK.

From: Solar Designer <[email protected]>

Enables gcc warnings for the case when arguments to vsprintf/vsnprintf
function don't match the format string. This helps catch programming
errors.

--- a/include/linux/kernel.h.orig 2005-03-13 14:42:52.069920616 -0300
+++ b/include/linux/kernel.h 2005-03-13 14:45:15.192162728 -0300
@@ -91,10 +91,12 @@
extern long long simple_strtoll(const char *,char **,unsigned int);
extern int sprintf(char * buf, const char * fmt, ...)
__attribute__ ((format (printf, 2, 3)));
-extern int vsprintf(char *buf, const char *, va_list);
+extern int vsprintf(char *buf, const char *, va_list)
+ __attribute__ ((format (printf, 2, 0)));
extern int snprintf(char * buf, size_t size, const char * fmt, ...)
__attribute__ ((format (printf, 3, 4)));
-extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
+extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
+ __attribute__ ((format (printf, 3, 0)));
extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
__attribute__ ((format (printf, 3, 4)));
extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);