qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Re: [PATCH 10/14] Zero json struct with memset() instea


From: Richard Henderson
Subject: Re: [Qemu-devel] Re: [PATCH 10/14] Zero json struct with memset() instea of = {} to keep compiler happy.
Date: Mon, 30 Aug 2010 12:32:51 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Thunderbird/3.1.2

On 08/30/2010 08:48 AM, Anthony Liguori wrote:
> 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.

GCC only warns for this if you explicitly ask for it.
I.e. -Wmissing-field-initializers.

That flag is included in -Wextra, which Jes used.

Traditionally this flag is used when you are initializing structures
like the above, but you make a change to the structure involved, so
you may need to update all initializers to take the new field into
account.  Some projects have found this idiom useful.

That said, today I'd not bother with this flag and use designated
initializers now.


r~



reply via email to

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