diff --git a/SConstruct b/SConstruct index c2873bc..27031a9 100644 --- a/SConstruct +++ b/SConstruct @@ -59,7 +59,8 @@ env.Append(CFLAGS = [ "-Wshadow", "-Wno-typedef-redefinition" ]) #env.Append(CXXFLAGS = [ "-Wno-non-template-friend", "-Woverloaded-virtual", # "-Wcast-qual", "-Wcast-align", "-Wconversion", # "-Weffc++", "-std=c++0x", "-Werror" ]) -env.Append(CPPFLAGS = [ "-fno-builtin", "-fno-stack-protector" ]) +env.Append(CPPFLAGS = [ "-fno-builtin", "-fno-stack-protector", + "-Wformat=2", "-Wmissing-format-attribute" ]) if env["WITH_GPROF"] == "1": env.Append(CPPFLAGS = [ "-pg" ]) diff --git a/include/stdio.h b/include/stdio.h index 061639e..3c24d35 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -3,6 +3,7 @@ #define __STDIO_H__ #include +#include typedef struct FILE { int in_use; @@ -40,7 +41,7 @@ int puts(const char *str); int printf(const char *fmt, ...); int fprintf(FILE *stream, const char *fmt, ...); int sprintf(char *str, const char *fmt, ...); -int snprintf(char *str, size_t size, const char *fmt, ...); +int snprintf(char *str, size_t size, const char *fmt, ...) __printflike(3, 4);; #endif /* __STDIO_H__ */ diff --git a/sys/include/cdefs.h b/sys/include/cdefs.h index 85ec7ed..5445f23 100644 --- a/sys/include/cdefs.h +++ b/sys/include/cdefs.h @@ -16,5 +16,7 @@ #define __hidden __attribute__((__visibility__("hidden"))) +#define __printflike(_fmt, _var) __attribute__((__format__(__printf__, _fmt, _var))) + #endif /* __CDEFS_H__ */