VMXNET3: initialize rx_ridx to eliminate compile warning
PATCH 1/1 VMXNET3: initialize rx_ridx to eliminate compile warning
Gcc report "hw/vmxnet3.c:972: error: ‘rx_ridx’ may be used
uninitialized in this function", so fix it.
--- hw/vmxnet3.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/vmxnet3.c +1 -1
@@ -969,7 +969,7 @@ vmxnet3_indicate_packet(VMXNET3State *s)struct Vmxnet3_RxDesc rxd;bool is_head = true;uint32_t rxd_idx; -uint32_t rx_ridx; +uint32_t rx_ridx =0 ;struct Vmxnet3_RxCompDesc rxcd;uint32_t new_rxcd_gen =VMXNET3_INIT_GEN ;
Signature · 1 line
1.7.1
Quoted 13 lines · Wenchao Xia
Gcc report "
hw/vmxnet3.c:972: error: ‘rx_ridx’ may be used
uninitialized in this function", so fix it.Signed-off-by Wenchao Xia <[email protected]>--- hw/vmxnet3.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)hw/vmxnet3.c +0
-0
hw/vmxnet3.c vmxnet3_indicate_packet(VMXNET3State *s) · line 972
Quoted 5 lines
hw/vmxnet3.c +1
-1@@ -969,7 +969,7 @@ vmxnet3_indicate_packet(VMXNET3State *s)struct Vmxnet3_RxDesc rxd;bool is_head = true;uint32_t rxd_idx; -uint32_t rx_ridx; +uint32_t rx_ridx =0 ;
This seems to be a gcc weakness in some versions.
No warnings here with gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8).
I manually checked the code and there is no path which can use uninitialized rx_ridx:
static boolvmxnet3_indicate_packet(VMXNET3State *s)
{
struct Vmxnet3_RxDesc rxd;
bool is_head = true;
uint32_t rxd_idx;
uint32_t rx_ridx;
[...]
while (bytes_left > 0) {
[...]
if (!vmxnet3_get_next_rx_descr(s, is_head, &rxd, &rxd_idx, &rx_ridx)) {
break;
}rx_ridx is assigned by vmxnet3_get_next_rx_descr() unless it returns false.
Quoted 1 line
From now on
rx_ridxis initialized.
[...]
rxcd.rqID = RXQ_IDX + rx_ridx * s->rxq_num;
Used here, fine since we initialized it above.
[...]
VMW_RIPRN("RX Completion descriptor: rxRing: %lu rxIdx %lu len %lu "
"sop %d csum_correct %lu",
(unsigned long) rx_ridx,
Used here, fine since we initialized it above.
[...]
}
Not used outside the while loop.
Quoted 7 lines · Wenchao Xia
Gcc report "
hw/vmxnet3.c:972: error: ‘rx_ridx’ may be used
uninitialized in this function", so fix it.Signed-off-by Wenchao Xia <[email protected]>--- hw/vmxnet3.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Anthony: Please apply this fix directly. I think there's no need to go through the net tree.
Stefan
Hi, Wenchao
Thanks for fixing this!
Dmitry.
Quoted 26 lines · Wenchao Xia
Gcc report "
hw/vmxnet3.c:972: error: ‘rx_ridx’ may be used
uninitialized in this function", so fix it.Signed-off-by Wenchao Xia <[email protected]>--- hw/vmxnet3.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)hw/vmxnet3.c +1
-2@@ -969,7 +969,7 @@ vmxnet3_indicate_packet(VMXNET3State *s)struct Vmxnet3_RxDesc rxd;bool is_head = true;uint32_t rxd_idx; -uint32_t rx_ridx; +uint32_t rx_ridx =0 ;struct Vmxnet3_RxCompDesc rxcd;uint32_t new_rxcd_gen =VMXNET3_INIT_GEN ; --1.7.1
Anthony Liguori
AppliedApplied. Thanks.
Regards,
Anthony Liguori