Re: [PATCH v2 4/6] vsnprintf: Mark binary printing functions with __printf() attribute
From: Andy Shevchenko
Date: Mon Mar 24 2025 - 15:34:18 EST
On Mon, Mar 24, 2025 at 03:20:12PM -0400, Steven Rostedt wrote:
> On Fri, 21 Mar 2025 16:40:50 +0200
> Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> 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.
Tell it to Linus :-) since it was him who enabled that default. And since it's
there and defconfigs are also part of the kernel I can't easy remove that, and
TBH I even won't dare doing that.
> 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.
You (actually me) fix them once, currently CI's typically run with W=1, but
with WERROR=n. Which means that the new code that is not fixed a priori, will
induce the CI red report.
> > Fix the compilation errors by adding __printf() attribute.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
--
With Best Regards,
Andy Shevchenko