[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yh9alvkQhbbgppW0@alley>
Date: Wed, 2 Mar 2022 12:52:54 +0100
From: Petr Mladek <pmladek@...e.com>
To: John Ogness <john.ogness@...utronix.de>
Cc: Matthew Wilcox <willy@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
kernel test robot <lkp@...el.com>,
Maninder Singh <maninder1.s@...sung.com>,
kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
Johannes Weiner <hannes@...xchg.org>,
Vaneet Narang <v.narang@...sung.com>,
Linux Memory Management List <linux-mm@...ck.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [hnaz-mm:master 272/379] lib/vsprintf.c:991:13: warning:
variable 'modbuildid' set but not used
On Wed 2022-03-02 10:58:49, John Ogness wrote:
> On 2022-03-01, Matthew Wilcox <willy@...radead.org> wrote:
> >> > lib/vsprintf.c: In function 'va_format':
> >> > lib/vsprintf.c:1759:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> >> > 1759 | buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va);
> >> > | ^~~
> >>
> >> I wonder what this means.
> >
> > It means the compiler thinks we might want to add:
> >
> > __attribute__((format(gnu_printf, x, y))) to the function declaration so it
> > can type-check the arguments.
> >
> > 'format (ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)'
> > The 'format' attribute specifies that a function takes 'printf',
> > 'scanf', 'strftime' or 'strfmon' style arguments that should be
> > type-checked against a format string. For example, the
> > declaration:
> >
> > extern int
> > my_printf (void *my_object, const char *my_format, ...)
> > __attribute__ ((format (printf, 2, 3)));
> >
> > causes the compiler to check the arguments in calls to 'my_printf'
> > for consistency with the 'printf' style format string argument
> > 'my_format'.
> >
> >
> > I haven't looked into this at all and have no idea if we should.
>
> AFAICT it is not possible to use the gnu_printf format attribute for
> this because the va_list to check is a field within the passed in struct
> pointer @va_fmt.
My understanding is that it can be handled by passing '0' as the
FIRST-TO-CHECK parameter:
<paste>
format (archetype, string-index, first-to-check)
The format attribute specifies that a function takes printf, scanf,
strftime or strfmon style arguments that should be type-checked
against a format string. For example, the declaration:
[...]
"For functions where the arguments are not available to be checked
(such as vprintf), specify the third parameter as zero."
<paste>
, cut&pasted from
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
Well, this particular function va_format() is never used with
open-coded @arg parameter. It always just passes @arg from
the caller. So that the check is not important.
Best Regards,
Petr
Powered by blists - more mailing lists