Re: [PATCH v2 4/6] vsnprintf: Mark binary printing functions with __printf() attribute
From: Steven Rostedt <rostedt@goodmis.org>
Date: 2025-03-24 19:19:32
Also in:
linux-hardening, lkml
From: Steven Rostedt <rostedt@goodmis.org>
Date: 2025-03-24 19:19:32
Also in:
linux-hardening, lkml
On Fri, 21 Mar 2025 16:40:50 +0200 Andy Shevchenko [off-list ref] wrote:
Binary printf() functions are using printf() type of format, and compiler is not happy about them as is: lib/vsprintf.c:3130:47: error: function ‘vbin_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] lib/vsprintf.c:3298:33: error: function ‘bstr_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
BTW, I find it disturbing that the compiler is set to "error" on a warning that "might be a candidate". What happens if it is not? We have to play games to quiet it. Adding __printf() attributes to stubs seems to be a case of the compiler causing more problems than its worth :-/ I honestly hate this error on warning because it causes real pain when debugging. There's a lot of times I don't know if the value is long or long long, and when I get it wrong, my printk() causes the build to fail. It's especially annoying when both long and long long are the same size! Fixing theses stupid errors takes a non trivial amount of time away from actual debugging. -- Steve
Fix the compilation errors by adding __printf() attribute. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>