From: Stephen Hemminger Date: Fri, 28 Aug 2015 16:23:38 +0000 (-0700) Subject: virtio: fix Coverity unsigned warnings X-Git-Tag: spdx-start~8373 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1e7bd2380f661d7b4024708371f8340a6e55fd8d;p=dpdk.git virtio: fix Coverity unsigned warnings There are some places in virtio driver where uint16_t or int are used where it would be safer to use unsigned. Signed-off-by: Stephen Hemminger --- diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 44952186aa..02f698a2e1 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -262,21 +262,20 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev, { char vq_name[VIRTQUEUE_MAX_NAME_SZ]; const struct rte_memzone *mz; - uint16_t vq_size; - int size; + unsigned int vq_size, size; struct virtio_hw *hw = dev->data->dev_private; struct virtqueue *vq = NULL; /* Write the virtqueue index to the Queue Select Field */ VIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, vtpci_queue_idx); - PMD_INIT_LOG(DEBUG, "selecting queue: %d", vtpci_queue_idx); + PMD_INIT_LOG(DEBUG, "selecting queue: %u", vtpci_queue_idx); /* * Read the virtqueue size from the Queue Size field * Always power of 2 and if 0 virtqueue does not exist */ vq_size = VIRTIO_READ_REG_2(hw, VIRTIO_PCI_QUEUE_NUM); - PMD_INIT_LOG(DEBUG, "vq_size: %d nb_desc:%d", vq_size, nb_desc); + PMD_INIT_LOG(DEBUG, "vq_size: %u nb_desc:%u", vq_size, nb_desc); if (vq_size == 0) { PMD_INIT_LOG(ERR, "%s: virtqueue does not exist", __func__); return -EINVAL; diff --git a/drivers/net/virtio/virtio_ring.h b/drivers/net/virtio/virtio_ring.h index a16c4991c1..447760a8e5 100644 --- a/drivers/net/virtio/virtio_ring.h +++ b/drivers/net/virtio/virtio_ring.h @@ -123,10 +123,10 @@ struct vring { #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) #define vring_avail_event(vr) (*(uint16_t *)&(vr)->used->ring[(vr)->num]) -static inline int +static inline size_t vring_size(unsigned int num, unsigned long align) { - int size; + size_t size; size = num * sizeof(struct vring_desc); size += sizeof(struct vring_avail) + (num * sizeof(uint16_t)); diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index c5b53bb165..d35c5f94ac 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -206,7 +206,7 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie) uint16_t seg_num = cookie->nb_segs; uint16_t needed = 1 + seg_num; uint16_t head_idx, idx; - uint16_t head_size = txvq->hw->vtnet_hdr_size; + size_t head_size = txvq->hw->vtnet_hdr_size; if (unlikely(txvq->vq_free_cnt == 0)) return -ENOSPC; @@ -224,7 +224,7 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie) start_dp = txvq->vq_ring.desc; start_dp[idx].addr = txvq->virtio_net_hdr_mem + idx * head_size; - start_dp[idx].len = (uint32_t)head_size; + start_dp[idx].len = head_size; start_dp[idx].flags = VRING_DESC_F_NEXT; for (; ((seg_num > 0) && (cookie != NULL)); seg_num--) {