From: Jerin Jacob Date: Fri, 2 Jun 2017 11:20:31 +0000 (+0530) Subject: examples/vhost: fix uninitialized descriptor indexes X-Git-Tag: spdx-start~3195 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=62a0e941b5000fec02dc3bd3efed092b809ce570;p=dpdk.git examples/vhost: fix uninitialized descriptor indexes 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 Reviewed-by: Maxime Coquelin --- diff --git a/examples/vhost/virtio_net.c b/examples/vhost/virtio_net.c index cc2c3d8827..5e1ed44a5d 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;