]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
genksyms: add printf format attribute to error_with_pos()
authorNicolas Iooss <nicolas.iooss_linux@m4x.org>
Sat, 20 May 2017 11:27:00 +0000 (13:27 +0200)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 5 Jun 2017 16:22:48 +0000 (01:22 +0900)
When compiling with -Wsuggest-attribute=format in HOSTCFLAGS, gcc
complains that error_with_pos() may be declared with a printf format
attribute:

    scripts/genksyms/genksyms.c:726:3: warning: function might be
    possible candidate for ‘gnu_printf’ format attribute
    [-Wsuggest-attribute=format]
       vfprintf(stderr, fmt, args);
       ^~~~~~~~

This would allow catching printf-format errors at compile time in
callers to error_with_pos(). Add this attribute.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
scripts/genksyms/genksyms.h

index 3bffdcaaa274e82271a98c65fa0bc43cef53ffe2..b724a0290c75e45cbc89134f2b9ae03166ff27a5 100644 (file)
@@ -75,7 +75,7 @@ struct string_list *copy_list_range(struct string_list *start,
 int yylex(void);
 int yyparse(void);
 
-void error_with_pos(const char *, ...);
+void error_with_pos(const char *, ...) __attribute__ ((format(printf, 1, 2)));
 
 /*----------------------------------------------------------------------*/
 #define xmalloc(size) ({ void *__ptr = malloc(size);           \