From: Stefan Hajnoczi <stefanha@redhat.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: dmitry@daynix.com, yan@daynix.com,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] VMXNET3: initialize rx_ridx to eliminate compile warning
Date: Tue, 26 Mar 2013 10:16:03 +0100 [thread overview]
Message-ID: <20130326091603.GC17648@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1364264646-27542-1-git-send-email-xiawenc@linux.vnet.ibm.com>
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.
next prev parent reply other threads:[~2013-03-26 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-26 2:24 [Qemu-devel] [PATCH] VMXNET3: initialize rx_ridx to eliminate compile warning Wenchao Xia
2013-03-26 9:16 ` Stefan Hajnoczi [this message]
2013-03-26 9:16 ` Stefan Hajnoczi
2013-03-27 13:21 ` Dmitry Fleytman
2013-04-02 20:21 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130326091603.GC17648@stefanha-thinkpad.redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=dmitry@daynix.com \
--cc=qemu-devel@nongnu.org \
--cc=xiawenc@linux.vnet.ibm.com \
--cc=yan@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).