qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH] Suppress warning: zero-length gnu_printf format


From: Blue Swirl
Subject: [Qemu-devel] Re: [PATCH] Suppress warning: zero-length gnu_printf format string
Date: Thu, 14 Oct 2010 17:59:15 +0000

On Thu, Oct 14, 2010 at 5:52 PM, Paolo Bonzini <address@hidden> wrote:
> On 10/14/2010 06:38 PM, Blue Swirl wrote:
>>
>> On Thu, Oct 14, 2010 at 9:20 AM, Markus Armbruster<address@hidden>
>>  wrote:
>>>
>>> Blue Swirl<address@hidden>  writes:
>>>
>>>> On Wed, Oct 13, 2010 at 7:19 AM, Markus Armbruster<address@hidden>
>>>>  wrote:
>>>>>
>>>>> Blue Swirl<address@hidden>  writes:
>>>>>
>>>>>> On Mon, Oct 11, 2010 at 12:52 PM, Markus Armbruster<address@hidden>
>>>>>>  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 via email to

[Prev in Thread] Current Thread [Next in Thread]