From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Matthew Wilcox <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
kernel test robot <lkp@intel.com>,
Maninder Singh <maninder1.s@samsung.com>,
kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Johannes Weiner <hannes@cmpxchg.org>,
Vaneet Narang <v.narang@samsung.com>,
Linux Memory Management List <linux-mm@kvack.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [hnaz-mm:master 272/379] lib/vsprintf.c:991:13: warning: variable 'modbuildid' set but not used
Date: Wed, 2 Mar 2022 12:52:54 +0100 [thread overview]
Message-ID: <Yh9alvkQhbbgppW0@alley> (raw)
In-Reply-To: <8735k0isum.fsf@jogness.linutronix.de>
On Wed 2022-03-02 10:58:49, John Ogness wrote:
> On 2022-03-01, Matthew Wilcox <willy@infradead.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
next prev parent reply other threads:[~2022-03-02 11:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 12:11 kernel test robot
2022-03-01 18:24 ` Andrew Morton
2022-03-01 19:22 ` Matthew Wilcox
2022-03-02 9:52 ` John Ogness
2022-03-02 11:52 ` Petr Mladek [this message]
2022-03-02 9:56 ` Petr Mladek
2022-03-02 12:07 ` Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yh9alvkQhbbgppW0@alley \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=john.ogness@linutronix.de \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=maninder1.s@samsung.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=v.narang@samsung.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox