Message ID | 1364264646-27542-1-git-send-email-xiawenc@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
On Tue, Mar 26, 2013 at 10:24:06AM +0800, Wenchao Xia wrote: > Gcc report "hw/vmxnet3.c:972: error: ‘rx_ridx’ may be used > uninitialized in this function", so fix it. > > Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> > --- > hw/vmxnet3.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/hw/vmxnet3.c b/hw/vmxnet3.c > index 925be80..bdd256e 100644 > --- a/hw/vmxnet3.c > +++ b/hw/vmxnet3.c > @@ -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; Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> 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 bool vmxnet3_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. From now on rx_ridx is 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.
On Tue, Mar 26, 2013 at 10:24:06AM +0800, Wenchao Xia wrote: > Gcc report "hw/vmxnet3.c:972: error: ‘rx_ridx’ may be used > uninitialized in this function", so fix it. > > Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> > --- > 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. On Tue, Mar 26, 2013 at 4:24 AM, Wenchao Xia <xiawenc@linux.vnet.ibm.com>wrote: > Gcc report "hw/vmxnet3.c:972: error: ‘rx_ridx’ may be used > uninitialized in this function", so fix it. > > Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> > --- > hw/vmxnet3.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/hw/vmxnet3.c b/hw/vmxnet3.c > index 925be80..bdd256e 100644 > --- a/hw/vmxnet3.c > +++ b/hw/vmxnet3.c > @@ -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 > > >
Applied. Thanks. Regards, Anthony Liguori
diff --git a/hw/vmxnet3.c b/hw/vmxnet3.c index 925be80..bdd256e 100644 --- a/hw/vmxnet3.c +++ b/hw/vmxnet3.c @@ -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;
Gcc report "hw/vmxnet3.c:972: error: ‘rx_ridx’ may be used uninitialized in this function", so fix it. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> --- hw/vmxnet3.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)