DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jerin Jacob <jerin.jacob@caviumnetworks.com>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com, thomas@monjalon.net,
	cristian.dumitrescu@intel.com, yuanhan.liu@linux.intel.com,
	maxime.coquelin@redhat.com,
	Jerin Jacob <jerin.jacob@caviumnetworks.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH 4/4] examples/vhost: fix uninitialized desc indexes
Date: Fri,  2 Jun 2017 16:50:31 +0530	[thread overview]
Message-ID: <20170602112031.9112-4-jerin.jacob@caviumnetworks.com> (raw)
In-Reply-To: <20170602112031.9112-1-jerin.jacob@caviumnetworks.com>

Fixing the below error by returning from the function early
when count == 0.

Issue flagged by GCC 7.1.1

examples/vhost/virtio_net.c:370:38: error: ‘desc_indexes[0]’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
  rte_prefetch0(&vr->desc[desc_indexes[0]]);

Fixes: ca059fa5e290 ("examples/vhost: demonstrate the new generic APIs")

Cc: stable@dpdk.org
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 examples/vhost/virtio_net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/examples/vhost/virtio_net.c b/examples/vhost/virtio_net.c
index cc2c3d882..5e1ed44a5 100644
--- a/examples/vhost/virtio_net.c
+++ b/examples/vhost/virtio_net.c
@@ -350,6 +350,9 @@ vs_dequeue_pkts(struct vhost_dev *dev, uint16_t queue_id,
 	count = RTE_MIN(count, MAX_PKT_BURST);
 	count = RTE_MIN(count, free_entries);
 
+	if (unlikely(count == 0))
+		return 0;
+
 	/*
 	 * Retrieve all of the head indexes first and pre-update used entries
 	 * to avoid caching issues.
@@ -385,8 +388,6 @@ vs_dequeue_pkts(struct vhost_dev *dev, uint16_t queue_id,
 		}
 
 	}
-	if (!i)
-		return 0;
 
 	queue->last_avail_idx += i;
 	queue->last_used_idx += i;
-- 
2.13.0

  parent reply	other threads:[~2017-06-02 11:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 11:20 [dpdk-dev] [PATCH 1/4] examples/l3fwd: add switch fall-through comments Jerin Jacob
2017-06-02 11:20 ` [dpdk-dev] [PATCH 2/4] examples/performance-thread: add " Jerin Jacob
2017-06-02 11:20 ` [dpdk-dev] [PATCH 3/4] examples/qos_sched: suppress GCC 7.1.1 warnings Jerin Jacob
2017-06-02 18:18   ` Dumitrescu, Cristian
2017-06-02 11:20 ` Jerin Jacob [this message]
2017-06-03  6:59   ` [dpdk-dev] [PATCH 4/4] examples/vhost: fix uninitialized desc indexes Maxime Coquelin
2017-06-05 12:57 ` [dpdk-dev] [PATCH 1/4] examples/l3fwd: add switch fall-through comments Thomas Monjalon

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=20170602112031.9112-4-jerin.jacob@caviumnetworks.com \
    --to=jerin.jacob@caviumnetworks.com \
    --cc=bruce.richardson@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=yuanhan.liu@linux.intel.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).