[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] VMXNET3: initialize rx_ridx to eliminate compil
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH] VMXNET3: initialize rx_ridx to eliminate compile warning |
Date: |
Tue, 26 Mar 2013 10:16:03 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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 <address@hidden>
> ---
> 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 <address@hidden>
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.