From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKPzH-0007Jh-Jh for qemu-devel@nongnu.org; Tue, 26 Mar 2013 05:16:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKPzE-0004zt-MT for qemu-devel@nongnu.org; Tue, 26 Mar 2013 05:16:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50775) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKPzE-0004zm-EM for qemu-devel@nongnu.org; Tue, 26 Mar 2013 05:16:08 -0400 Date: Tue, 26 Mar 2013 10:16:03 +0100 From: Stefan Hajnoczi Message-ID: <20130326091603.GC17648@stefanha-thinkpad.redhat.com> References: <1364264646-27542-1-git-send-email-xiawenc@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1364264646-27542-1-git-send-email-xiawenc@linux.vnet.ibm.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] VMXNET3: initialize rx_ridx to eliminate compile warning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: dmitry@daynix.com, yan@daynix.com, Anthony Liguori , qemu-devel@nongnu.org On Tue, Mar 26, 2013 at 10:24:06AM +0800, Wenchao Xia wrote: > Gcc report "hw/vmxnet3.c:972: error: =E2=80=98rx_ridx=E2=80=99 may be= used > uninitialized in this function", so fix it. >=20 > Signed-off-by: Wenchao Xia > --- > hw/vmxnet3.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) >=20 > 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 =3D true; > uint32_t rxd_idx; > - uint32_t rx_ridx; > + uint32_t rx_ridx =3D 0; Reviewed-by: Stefan Hajnoczi 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 =3D 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_ri= dx)) { break; } rx_ridx is assigned by vmxnet3_get_next_rx_descr() unless it returns false. >>From now on rx_ridx is initialized. [...] rxcd.rqID =3D 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 %l= u " "sop %d csum_correct %lu", (unsigned long) rx_ridx, Used here, fine since we initialized it above. [...] } Not used outside the while loop.