qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 03/12] eepro100: initialize a variable in all cases
@ 2010-10-08 21:23 Blue Swirl
  2010-10-11 14:53 ` Markus Armbruster
  0 siblings, 1 reply; 4+ messages in thread
From: Blue Swirl @ 2010-10-08 21:23 UTC (permalink / raw)
  To: qemu-devel

Compiling with GCC 4.6.0 20100925 produced warnings:
/src/qemu/hw/eepro100.c: In function 'eepro100_read4':
/src/qemu/hw/eepro100.c:1351:14: error: 'val' may be used
uninitialized in this function [-Werror=uninitialized]
/src/qemu/hw/eepro100.c: In function 'eepro100_read2':
/src/qemu/hw/eepro100.c:1328:14: error: 'val' may be used
uninitialized in this function [-Werror=uninitialized]
/src/qemu/hw/eepro100.c: In function 'eepro100_read1':
/src/qemu/hw/eepro100.c:1285:13: error: 'val' may be used
uninitialized in this function [-Werror=uninitialized]

Fix by initializing 'val' at start.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/eepro100.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 2b75c8f..adc579f 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1282,7 +1282,7 @@ static void eepro100_write_port(EEPRO100State *
s, uint32_t val)

 static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr)
 {
-    uint8_t val;
+    uint8_t val = 0;
     if (addr <= sizeof(s->mem) - sizeof(val)) {
         memcpy(&val, &s->mem[addr], sizeof(val));
     }
@@ -1325,7 +1325,7 @@ static uint8_t eepro100_read1(EEPRO100State * s,
uint32_t addr)

 static uint16_t eepro100_read2(EEPRO100State * s, uint32_t addr)
 {
-    uint16_t val;
+    uint16_t val = 0;
     if (addr <= sizeof(s->mem) - sizeof(val)) {
         memcpy(&val, &s->mem[addr], sizeof(val));
     }
@@ -1348,7 +1348,7 @@ static uint16_t eepro100_read2(EEPRO100State *
s, uint32_t addr)

 static uint32_t eepro100_read4(EEPRO100State * s, uint32_t addr)
 {
-    uint32_t val;
+    uint32_t val = 0;
     if (addr <= sizeof(s->mem) - sizeof(val)) {
         memcpy(&val, &s->mem[addr], sizeof(val));
     }
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-10-11 17:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-08 21:23 [Qemu-devel] [PATCH 03/12] eepro100: initialize a variable in all cases Blue Swirl
2010-10-11 14:53 ` Markus Armbruster
2010-10-11 16:07   ` Stefan Weil
2010-10-11 17:00     ` Markus Armbruster

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).