Skip to contentSkip to conversation

Enable gcc warnings for vsprintf/vsnprintf with "format" attribute

PATCH New Marcelo Tosatti 1 participant 1 message Mar 14, 2005

lore
Share & tools
lore

Marcelo Tosatti

author Applied
#0 lore raw

PATCH 1/1 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.

include/linux/kernel.h renamed from include/linux/kernel.h.orig +4 -2
@@ -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);