The following warning is produced by: make W=1 lib/vsprintf.o lib/vsprintf.c:1770:1: error: multiple storage classes in declaration specifiers static char *va_format(char *buf, char *end, struct va_format *va_fmt, ^~~~~~ lib/vsprintf.c:1770:14: warning: no previous prototype for ‘va_format’ [-Wmissing-prototypes] static char *va_format(char *buf, char *end, struct va_format *va_fmt, ^~~~~~~~~ More similar warnings are printed after fixing the 1st one: lib/vsprintf.c: In function ‘pointer’: lib/vsprintf.c:2522:3: warning: function ‘pointer’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] return va_format(buf, end, ptr, spec, fmt); ^~~~~~ lib/vsprintf.c: In function ‘vbin_printf’: lib/vsprintf.c:3213:12: warning: function ‘vbin_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] spec); ^~~~ lib/vsprintf.c: In function ‘bstr_printf’: lib/vsprintf.c:3398:5: warning: function ‘bstr_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] str = pointer(fmt, str, end, get_arg(void *), spec); ^~~ Add the proposed annotation. Signed-off-by: Petr Mladek <pmladek@xxxxxxxx> --- include/linux/string.h | 3 +++ lib/vsprintf.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index b6572aeca2f5..e37eaecb7906 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -196,8 +196,11 @@ int __sysfs_match_string(const char * const *array, size_t n, const char *s); #define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s) #ifdef CONFIG_BINARY_PRINTF +__printf(3, 0) int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); +__printf(3, 0) int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf); +__printf(3, 4) int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4); #endif diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 3b8129dd374c..981c71da5e3d 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1672,6 +1672,7 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, return buf; } +__printf(5, 0) static char *va_format(char *buf, char *end, struct va_format *va_fmt, struct printf_spec spec, const char *fmt) { @@ -2498,6 +2499,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, * @precision: precision of a number * @qualifier: qualifier of a number (long, size_t, ...) */ +__printf(1, 0) static noinline_for_stack int format_decode(const char *fmt, struct printf_spec *spec) { -- 2.26.2