Received: from [140.186.70.92] (port=58479 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oq8OY-0007fE-CW for qemu-devel@nongnu.org; Mon, 30 Aug 2010 13:43:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oq8OX-0001Li-8X for qemu-devel@nongnu.org; Mon, 30 Aug 2010 13:43:46 -0400 Received: from fe02x03-cgp.akado.ru ([77.232.31.165]:58127 helo=akado.ru) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oq8OX-0001LW-26 for qemu-devel@nongnu.org; Mon, 30 Aug 2010 13:43:45 -0400 Date: Mon, 30 Aug 2010 21:43:31 +0400 (MSD) From: malc Subject: Re: [Qemu-devel] Re: [PATCH 04/14] Zero initialize timespec struct explicitly In-Reply-To: <4C7BEC96.6040506@redhat.com> Message-ID: References: <1283182547-26116-1-git-send-email-Jes.Sorensen@redhat.com> <1283182547-26116-5-git-send-email-Jes.Sorensen@redhat.com> <4C7BD19E.1050604@codemonkey.ws> <4C7BEC96.6040506@redhat.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Mon, 30 Aug 2010, Jes Sorensen wrote: > On 08/30/10 18:56, malc wrote: > > On Mon, 30 Aug 2010, Anthony Liguori wrote: > > > >> On 08/30/2010 10:35 AM, Jes.Sorensen@redhat.com wrote: > >>> From: Jes Sorensen > >>> diff --git a/linux-aio.c b/linux-aio.c > >>> index 68f4b3d..3240996 100644 > >>> --- a/linux-aio.c > >>> +++ b/linux-aio.c > >>> @@ -118,7 +118,7 @@ static void qemu_laio_completion_cb(void *opaque) > >>> struct io_event events[MAX_EVENTS]; > >>> uint64_t val; > >>> ssize_t ret; > >>> - struct timespec ts = { 0 }; > >>> + struct timespec ts = { 0, 0 }; > >>> > >> > >> I don't like these. What's wrong with { } or { 0 }? Implicit zeroing of > >> members is a critical feature of structure initialization so if there is > >> something wrong with this, it's important to know why because otherwise we've > >> got a massive amount of broken code. > >> > > > > Apart from gcc complaining about fields not being initialized explicitly > > there's nothing wrong with it. > > Sure it compiles, it works, but it's not pretty. What does it mean if > you write = { 1 } in the above case? It means exactly what standard says it should mean, i.e. set tv_sec to 1 and tv_nsec to 0. > > Anyway the whole point of my patch is this, if we fix things like these, > we are much more likely to be able to catch real bugs using some of > gcc's checking. The patch I submitted is harmless code wise, but it > makes it that bit easier to catch other bugs in the code. In my book > that adds a lot of value. FWIW I wasn't arguing against the patch. -- mailto:av1474@comtv.ru