qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Blue Swirl <blauwirbel@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] Suppress warning: zero-length gnu_printf format string
Date: Thu, 14 Oct 2010 17:59:15 +0000	[thread overview]
Message-ID: <AANLkTimRvyX74-tRYFrQB=JrJm+2yysrW_o6xn44tR4u@mail.gmail.com> (raw)
In-Reply-To: <4CB74350.80201@redhat.com>

On Thu, Oct 14, 2010 at 5:52 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 10/14/2010 06:38 PM, Blue Swirl wrote:
>>
>> On Thu, Oct 14, 2010 at 9:20 AM, Markus Armbruster<armbru@redhat.com>
>>  wrote:
>>>
>>> Blue Swirl<blauwirbel@gmail.com>  writes:
>>>
>>>> On Wed, Oct 13, 2010 at 7:19 AM, Markus Armbruster<armbru@redhat.com>
>>>>  wrote:
>>>>>
>>>>> Blue Swirl<blauwirbel@gmail.com>  writes:
>>>>>
>>>>>> On Mon, Oct 11, 2010 at 12:52 PM, Markus Armbruster<armbru@redhat.com>
>>>>>>  wrote:
>>>>>>>
>>>>>>> Warns about this line in check-qjson.c:
>>>>>>>    QObject *obj = qobject_from_json("");
>>>>>>>
>>>>>>> The obvious fix (add -Wno-format-zero-length to gcc_flags) doesn't
>>>>>>> work, because -Wall switches it on again.  Fix by putting configured
>>>>>>> flags last.
>>>>>>
>>>>>> This would disable the flag globally. I'd rather disable the flag only
>>>>>> for check-qjson.o
>>>>>
>>>>> Is this warning worth the hassle?  What's the problem with empty format
>>>>> strings?
>>>>
>>>> Your fix solves this specific case, but it also degrades the gcc
>>>> checks of the mainstream code (slightly). I think the test suite need
>>>> not follow the level of checking that should be applied to mainstream,
>>>> or at least the warnings there should not be fatal.
>>>
>>> "Degrade" implies we miss something that's "wrong" enough to be worth
>>> avoiding.  What's wrong with empty format strings?
>>
>> They generate useless calls to the formatting function, wasting
>> performance (slightly). Since there are no calls currently, this is of
>> course hypothetical.
>
> It is even more hypothetical when empty-format printfs are optimized away by
> GCC:
>
> $ gcc -x c - -O2 -S -o -
> #include <stdio.h>
> main() { printf (""); }
>
>        .file   ""
>        .text
>        .p2align 4,,15
> .globl main
>        .type   main, @function
> main:
> .LFB11:
>        .cfi_startproc
>        rep
>        ret
>        .cfi_endproc
>
> and other attribute-printf-marked functions are probably not noop when the
> format argument is empty.

How is that? Does the warning message from qobject_from_json("") mean
that GCC may optimize that call away?

  reply	other threads:[~2010-10-14 17:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-11 12:52 [Qemu-devel] [PATCH] Suppress warning: zero-length gnu_printf format string Markus Armbruster
2010-10-11 13:09 ` [Qemu-devel] " Paolo Bonzini
2010-10-12 17:35 ` Blue Swirl
2010-10-13  7:19   ` Markus Armbruster
2010-10-13 18:57     ` Blue Swirl
2010-10-14  9:19       ` [Qemu-devel] [PATCH] configure: Support disabling warnings in $gcc_flags Markus Armbruster
2010-10-20 20:55         ` [Qemu-devel] " Blue Swirl
2010-10-14  9:20       ` [Qemu-devel] Re: [PATCH] Suppress warning: zero-length gnu_printf format string Markus Armbruster
2010-10-14 16:38         ` Blue Swirl
2010-10-14 17:52           ` Paolo Bonzini
2010-10-14 17:59             ` Blue Swirl [this message]
2010-10-15  1:33               ` Paolo Bonzini
2010-10-15 17:41                 ` Blue Swirl
2010-10-16  0:37                   ` Paolo Bonzini
2010-10-16 16:28                     ` Blue Swirl
2010-10-16 17:42                       ` [Qemu-devel] [PATCH] Silence compiler warning in json test case Jan Kiszka
2010-10-18 14:14                         ` Luiz Capitulino

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='AANLkTimRvyX74-tRYFrQB=JrJm+2yysrW_o6xn44tR4u@mail.gmail.com' \
    --to=blauwirbel@gmail.com \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).