提交 ef476062 编写于 作者: B Blue Swirl

eepro100: initialize a variable in all cases

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: NBlue Swirl <blauwirbel@gmail.com>
上级 8c78881f
...@@ -1290,7 +1290,7 @@ static void eepro100_write_port(EEPRO100State * s, uint32_t val) ...@@ -1290,7 +1290,7 @@ static void eepro100_write_port(EEPRO100State * s, uint32_t val)
static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr) static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr)
{ {
uint8_t val; uint8_t val = 0;
if (addr <= sizeof(s->mem) - sizeof(val)) { if (addr <= sizeof(s->mem) - sizeof(val)) {
memcpy(&val, &s->mem[addr], sizeof(val)); memcpy(&val, &s->mem[addr], sizeof(val));
} }
...@@ -1333,7 +1333,7 @@ static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr) ...@@ -1333,7 +1333,7 @@ static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr)
static uint16_t eepro100_read2(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)) { if (addr <= sizeof(s->mem) - sizeof(val)) {
memcpy(&val, &s->mem[addr], sizeof(val)); memcpy(&val, &s->mem[addr], sizeof(val));
} }
...@@ -1356,7 +1356,7 @@ static uint16_t eepro100_read2(EEPRO100State * s, uint32_t addr) ...@@ -1356,7 +1356,7 @@ static uint16_t eepro100_read2(EEPRO100State * s, uint32_t addr)
static uint32_t eepro100_read4(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)) { if (addr <= sizeof(s->mem) - sizeof(val)) {
memcpy(&val, &s->mem[addr], sizeof(val)); memcpy(&val, &s->mem[addr], sizeof(val));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册