* [Qemu-devel] cirrus_vga: uninitialized variable warnings
@ 2011-01-06 19:45 Blue Swirl
2011-01-06 21:13 ` Aurelien Jarno
0 siblings, 1 reply; 3+ messages in thread
From: Blue Swirl @ 2011-01-06 19:45 UTC (permalink / raw)
To: qemu-devel
There are a few variables which appear uninitialized to GCC 4.6.0:
CC i386-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:
if (notify)
qemu_console_copy(s->vga.ds,
sx, sy, dx, dy,
s->cirrus_blt_width / depth,
s->cirrus_blt_height);
Perhaps the code could be rearranged to avoid the warnings? Otherwise
we could add zero initializers.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] cirrus_vga: uninitialized variable warnings
2011-01-06 19:45 [Qemu-devel] cirrus_vga: uninitialized variable warnings Blue Swirl
@ 2011-01-06 21:13 ` Aurelien Jarno
2011-01-06 21:19 ` Blue Swirl
0 siblings, 1 reply; 3+ messages in thread
From: Aurelien Jarno @ 2011-01-06 21:13 UTC (permalink / raw)
To: Blue Swirl; +Cc: qemu-devel
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
> CC i386-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:
> if (notify)
> qemu_console_copy(s->vga.ds,
> sx, sy, dx, dy,
> s->cirrus_blt_width / depth,
> 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?
> 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 <aurelien@aurel32.net>
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 <aurelien@aurel32.net>
---
hw/cirrus_vga.c | 6 +++---
1 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(CirrusVGAState * s)
static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
{
- int sx, sy;
- int dx, dy;
- int depth;
+ int sx = 0, sy = 0;
+ int dx = 0, dy = 0;
+ int depth = 0;
int notify = 0;
/* make sure to only copy if it's a plain copy ROP */
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] cirrus_vga: uninitialized variable warnings
2011-01-06 21:13 ` Aurelien Jarno
@ 2011-01-06 21:19 ` Blue Swirl
0 siblings, 0 replies; 3+ messages in thread
From: Blue Swirl @ 2011-01-06 21:19 UTC (permalink / raw)
To: Aurelien Jarno; +Cc: qemu-devel
On Thu, Jan 6, 2011 at 9:13 PM, Aurelien Jarno <aurelien@aurel32.net> 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
>
>> CC i386-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:
>> if (notify)
>> qemu_console_copy(s->vga.ds,
>> sx, sy, dx, dy,
>> s->cirrus_blt_width / depth,
>> 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 <aurelien@aurel32.net>
>
> 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 <aurelien@aurel32.net>
Acked-by: Blue Swirl <blauwirbel@gmail.com>
> ---
> hw/cirrus_vga.c | 6 +++---
> 1 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(CirrusVGAState * s)
>
> static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
> {
> - int sx, sy;
> - int dx, dy;
> - int depth;
> + int sx = 0, sy = 0;
> + int dx = 0, dy = 0;
> + int depth = 0;
> int notify = 0;
>
> /* make sure to only copy if it's a plain copy ROP */
>
> --
> Aurelien Jarno GPG: 1024D/F1BCDB73
> aurelien@aurel32.net http://www.aurel32.net
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-06 21:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-06 19:45 [Qemu-devel] cirrus_vga: uninitialized variable warnings Blue Swirl
2011-01-06 21:13 ` Aurelien Jarno
2011-01-06 21:19 ` Blue Swirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).