From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=41888 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P6S4w-0007Lz-FP for qemu-devel@nongnu.org; Thu, 14 Oct 2010 13:58:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P6S4v-0008U9-DM for qemu-devel@nongnu.org; Thu, 14 Oct 2010 13:58:58 -0400 Received: from mail-qy0-f173.google.com ([209.85.216.173]:43141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P6S4v-0008U5-AU for qemu-devel@nongnu.org; Thu, 14 Oct 2010 13:58:57 -0400 Received: by qyk36 with SMTP id 36so271616qyk.4 for ; Thu, 14 Oct 2010 10:58:56 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4CB74350.80201@redhat.com> Date: Thu, 14 Oct 2010 19:52:16 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] Suppress warning: zero-length gnu_printf format string List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Markus Armbruster , qemu-devel@nongnu.org On 10/14/2010 06:38 PM, Blue Swirl wrote: > On Thu, Oct 14, 2010 at 9:20 AM, Markus Armbruster wrote: >> Blue Swirl writes: >> >>> On Wed, Oct 13, 2010 at 7:19 AM, Markus Armbruster wrote: >>>> Blue Swirl writes: >>>> >>>>> On Mon, Oct 11, 2010 at 12:52 PM, Markus Armbruster 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 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. Paolo