Skip to content

Commit

Permalink
genksyms: add printf format attribute to error_with_pos()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
fishilico authored and masahir0y committed Jun 5, 2017
1 parent 0833289 commit 3def034
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/genksyms/genksyms.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down

0 comments on commit 3def034

Please sign in to comment.