[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ-ks9nkyicpbX4jv+Ry4iDVLUGTHr_mHQx0EMN-jt3iDbrw0g@mail.gmail.com>
Date: Sat, 6 Dec 2025 12:13:34 -0500
From: Tamir Duberstein <tamird@...nel.org>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Petr Mladek <pmladek@...e.com>, Steven Rostedt <rostedt@...dmis.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>, Sergey Senozhatsky <senozhatsky@...omium.org>,
Kees Cook <kees@...nel.org>, linux-kernel@...r.kernel.org,
oe-kbuild-all@...ts.linux.dev, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH] printf: add __printf attribute
On Sat, Dec 6, 2025 at 11:11 AM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Sat, Dec 06, 2025 at 08:19:09AM -0500, Tamir Duberstein wrote:
>
> > This produces better diagnostics when incorrect inputs are passed.
>
> ...
>
> > -static void
> > +static void __printf(2, 3)
>
> 3?!
>
> I think it should be (2, 0). Yes, the both users call it with "%p..." in format
> string, but the second parameter tells compiler to check the variadic
> arguments, which are absent here. Changing 'const void *p' to '...' will align
> it with the given __printf() attribute, but I don't know if this what we want.
The second parameter is the first-to-check, it is not specific to
variadic arguments. Using 0 means that no arguments are checkable, so
the compiler only validates the format string itself and won’t
diagnose mismatches with `p`. This works whether or not we later
change `const void *p` to `...`.
Cheers.
Tamir
Powered by blists - more mailing lists