From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40420 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oq7xE-0003Wf-PV for qemu-devel@nongnu.org; Mon, 30 Aug 2010 13:15:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oq7xD-00057k-P6 for qemu-devel@nongnu.org; Mon, 30 Aug 2010 13:15:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60806) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oq7xD-0004fV-AR for qemu-devel@nongnu.org; Mon, 30 Aug 2010 13:15:31 -0400 Message-ID: <4C7BE668.8050507@redhat.com> Date: Mon, 30 Aug 2010 20:12:08 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 10/14] Zero json struct with memset() instea of = {} to keep compiler happy. References: <1283182547-26116-1-git-send-email-Jes.Sorensen@redhat.com> <1283182547-26116-11-git-send-email-Jes.Sorensen@redhat.com> <4C7BD0CE.6020505@codemonkey.ws> <4C7BD19C.9080308@redhat.com> <4C7BD2E7.2010201@codemonkey.ws> <4C7BD405.4090506@redhat.com> In-Reply-To: <4C7BD405.4090506@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes Sorensen Cc: kwolf@redhat.com, qemu-devel@nongnu.org On 08/30/2010 06:53 PM, Jes Sorensen wrote: > On 08/30/10 17:48, Anthony Liguori wrote: >> On 08/30/2010 10:43 AM, Jes Sorensen wrote: >>> 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 > I believe the comma after the last case takes care of terminating the list. It only makes patches that add items prettier. > I agree that it would be nice to get gcc to not moan about this specific > case, however I will argue that my change is worth it to be able to use > the error flags, even if it is gcc being stupid. If the flags make gcc stupid, why use them? -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.