From: Pedro Alves <palves@redhat.com>
To: paul@mad-scientist.net
Cc: Jack Howarth <howarth.mailing.lists@gmail.com>,
pinskia@gmail.com, Simon Marchi <simon.marchi@polymtl.ca>,
"Paul_Koning@dell.com" <Paul_Koning@dell.com>,
"gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: format string is not a string literal
Date: Thu, 26 Feb 2015 19:41:00 -0000 [thread overview]
Message-ID: <54EF5D65.8050605@redhat.com> (raw)
In-Reply-To: <1424972642.824.33.camel@homebase>
On 02/26/2015 05:44 PM, Paul Smith wrote:
> On Thu, 2015-02-26 at 09:52 +0000, Pedro Alves wrote:
>> + /* Use FMT from here on instead of complaint->fmt, to avoid "format
>> + string is not a string literal" warnings. */
>> + gdb_assert (complaint->fmt == fmt);
>> +
>> if (complaint->file != NULL)
>> - internal_vwarning (complaint->file, complaint->line,
>> - complaint->fmt, args);
>> + internal_vwarning (complaint->file, complaint->line, fmt, args);
>
> Can someone quickly explain how using fmt instead of complaint->fmt here
> removes the warning? fmt is not a "string literal" either...?
>
> Just curious what the trick is...
Simon explained it, actually:
> If the function is vprintf-style, it's similar but the last argument
> should be 0. It will push the argument check a level higher, where
> eventually they are explicitely defined printf-style. The doc is
> somewhere here [2] in the middle.
That code is in this function:
> static void ATTRIBUTE_PRINTF (4, 0)
vcomplaint (struct complaints **c, const char *file,
int line, const char *fmt,
va_list args)
{
So here the compiler will check FMT in the caller.
Thanks,
Pedro Alves
prev parent reply other threads:[~2015-02-26 17:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 17:16 Jack Howarth
2015-02-24 18:18 ` Andrew Pinski
2015-02-24 18:04 ` Andrew Pinski
2015-02-25 7:58 ` Paul_Koning
2015-02-26 0:06 ` Jack Howarth
2015-02-26 0:12 ` Paul_Koning
[not found] ` <CAFXXi0=56gNf2GoSKkrx=bRArhjk+AhSbiu0crpdR3=df7B2BQ@mail.gmail.com>
2015-02-26 0:46 ` pinskia
2015-02-26 2:31 ` Jack Howarth
2015-02-26 2:35 ` pinskia
2015-02-26 2:38 ` Simon Marchi
2015-02-26 8:39 ` Andrew Pinski
2015-02-26 8:46 ` Andrew Pinski
2015-02-26 9:52 ` Jack Howarth
2015-02-26 10:18 ` Andrew Pinski
2015-02-26 16:26 ` Pedro Alves
2015-02-26 17:44 ` Jack Howarth
2015-02-26 19:55 ` Pedro Alves
2015-02-26 18:34 ` Paul Smith
2015-02-26 19:41 ` Pedro Alves [this message]
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=54EF5D65.8050605@redhat.com \
--to=palves@redhat.com \
--cc=Paul_Koning@dell.com \
--cc=gdb@sourceware.org \
--cc=howarth.mailing.lists@gmail.com \
--cc=paul@mad-scientist.net \
--cc=pinskia@gmail.com \
--cc=simon.marchi@polymtl.ca \
/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