|
From: | Anthony Liguori |
Subject: | [Qemu-devel] Re: [PATCH 10/14] Zero json struct with memset() instea of = {} to keep compiler happy. |
Date: | Mon, 30 Aug 2010 10:48:55 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100713 Lightning/1.0b1 Thunderbird/3.0.6 |
On 08/30/2010 10:43 AM, Jes Sorensen wrote:
On 08/30/10 17:39, Anthony Liguori wrote:On 08/30/2010 10:35 AM, address@hidden wrote:From: Jes Sorensen<address@hidden> This keeps the compiler happy when building with -Wextra while effectively generating the same code. Signed-off-by: Jes Sorensen<address@hidden>What's GCC's compliant?cc1: warnings being treated as errors qjson.c: In function 'qobject_from_jsonv': qjson.c:39: error: missing initializer qjson.c:39: error: (near initialization for 'state.parser') make: *** [qjson.o] Error 1 We have a lot of these where we try to init a struct element {}. Yes it's technically legal. However it's painful when you try to apply more aggressive warning flags looking for real bugs.
No, this is GCC being stupid.
I would suggest we modify the coding style to ask people to not init a struct like this.
How else do you terminate a list? IOW: MyDeviceInfo device_infos[] = { {"foo", 0, 2}, {"bar", 0, 1}, {} /* or { 0 } */ };This is such a pervasive idiom that there's simply no way that GCC can possibly try to warn against this. Plus, it's entirely reasonable.
I think this is just a false positive in GCC. Otherwise, there's a ton of code that it should be throwing warnings against.
Regards, Anthony Liguori
Cheers, Jes
[Prev in Thread] | Current Thread | [Next in Thread] |