From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=34449 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PaxFS-0007Nx-3V for qemu-devel@nongnu.org; Thu, 06 Jan 2011 16:19:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PaxFQ-0002JR-Ow for qemu-devel@nongnu.org; Thu, 06 Jan 2011 16:19:53 -0500 Received: from mail-pw0-f45.google.com ([209.85.160.45]:58881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PaxFQ-0002JD-F2 for qemu-devel@nongnu.org; Thu, 06 Jan 2011 16:19:52 -0500 Received: by pwj6 with SMTP id 6so2879328pwj.4 for ; Thu, 06 Jan 2011 13:19:51 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20110106211327.GF21099@hall.aurel32.net> References: <20110106211327.GF21099@hall.aurel32.net> From: Blue Swirl Date: Thu, 6 Jan 2011 21:19:29 +0000 Message-ID: Subject: Re: [Qemu-devel] cirrus_vga: uninitialized variable warnings Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno Cc: qemu-devel On Thu, Jan 6, 2011 at 9:13 PM, Aurelien Jarno wrote= : > On Thu, Jan 06, 2011 at 07:45:01PM +0000, Blue Swirl wrote: >> There are a few variables which appear uninitialized to GCC 4.6.0: > > It's due to my commit 92d675d1c1f23f3617e24b63c825074a1d1da44b > >> =C2=A0 CC =C2=A0 =C2=A0i386-softmmu/cirrus_vga.o >> /src/qemu/hw/cirrus_vga.c: In function 'cirrus_bitblt_start': >> /src/qemu/hw/cirrus_vga.c:678: warning: 'depth' may be used >> uninitialized in this function >> /src/qemu/hw/cirrus_vga.c:678: note: 'depth' was declared here >> /src/qemu/hw/cirrus_vga.c:677: warning: 'dx' may be used uninitialized >> in this function >> /src/qemu/hw/cirrus_vga.c:677: note: 'dx' was declared here >> /src/qemu/hw/cirrus_vga.c:676: warning: 'sx' may be used uninitialized >> in this function >> /src/qemu/hw/cirrus_vga.c:676: note: 'sx' was declared here >> /src/qemu/hw/cirrus_vga.c:676: warning: 'sy' may be used uninitialized >> in this function >> /src/qemu/hw/cirrus_vga.c:676: note: 'sy' was declared here >> /src/qemu/hw/cirrus_vga.c:677: warning: 'dy' may be used uninitialized >> in this function >> /src/qemu/hw/cirrus_vga.c:677: note: 'dy' was declared here >> >> I don't think they are, since the variable use is conditional to >> notify variable: >> =C2=A0 =C2=A0 =C2=A0if (notify) >> =C2=A0 =C2=A0 =C2=A0 qemu_console_copy(s->vga.ds, >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 sx, sy, dx, dy, >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 s->cirrus_blt_width / depth, >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 s->cirrus_blt_height); > > Strangely neither GCC 4.4 nor GCC 4.5 trigger such a warning, though > they are usually catching cases like that. Could it be a regression in > GCC 4.6, or do you think it's just that it wasn't detected in previous > versions? It also happens with GCC 4.2.1 but not with 4.3.2. > >> Perhaps the code could be rearranged to avoid the warnings? Otherwise >> we could add zero initializers. >> > > Rearranging the code doesn't seems easy, so we should probably go to > zero initializers, as in the patch below. > > From: Aurelien Jarno > > cirrus: delete GCC 4.6 warnings > > Commit 92d675d1c1f23f3617e24b63c825074a1d1da44b triggered uninitialized > variables warning with GCC 4.6. Fix them by adding zero initializers. > > Signed-off-by: Aurelien Jarno Acked-by: Blue Swirl > --- > =C2=A0hw/cirrus_vga.c | =C2=A0 =C2=A06 +++--- > =C2=A01 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c > index 833a2eb..75d1cc6 100644 > --- a/hw/cirrus_vga.c > +++ b/hw/cirrus_vga.c > @@ -673,9 +673,9 @@ static int cirrus_bitblt_videotovideo_patterncopy(Cir= rusVGAState * s) > > =C2=A0static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int= w, int h) > =C2=A0{ > - =C2=A0 =C2=A0int sx, sy; > - =C2=A0 =C2=A0int dx, dy; > - =C2=A0 =C2=A0int depth; > + =C2=A0 =C2=A0int sx =3D 0, sy =3D 0; > + =C2=A0 =C2=A0int dx =3D 0, dy =3D 0; > + =C2=A0 =C2=A0int depth =3D 0; > =C2=A0 =C2=A0 int notify =3D 0; > > =C2=A0 =C2=A0 /* make sure to only copy if it's a plain copy ROP */ > > -- > Aurelien Jarno =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0GPG: 1024D/F1BCDB73 > aurelien@aurel32.net =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 http://www.aurel32.net >