From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 07983B76D for ; Fri, 20 Feb 2015 17:12:56 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 20 Feb 2015 08:07:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,615,1418112000"; d="scan'208";a="654874531" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 20 Feb 2015 08:12:54 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t1KGCrOx021006; Fri, 20 Feb 2015 16:12:53 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t1KGCq5W005921; Fri, 20 Feb 2015 16:12:52 GMT Received: (from mtgajdzx@localhost) by sivswdev01.ir.intel.com with id t1KGCqvl005917; Fri, 20 Feb 2015 16:12:52 GMT From: Maciej Gajdzica To: dev@dpdk.org Date: Fri, 20 Feb 2015 16:12:39 +0000 Message-Id: <1424448759-5802-1-git-send-email-maciejx.t.gajdzica@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] virtio: Changed variable types to prevent possible data loss in virtio_ethdev.c, virtio_ethdev.h and virtio_rxtx.c X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 16:12:57 -0000 Changed vtpci_queue_idx type in function virtio_dev_queue_setup from uint8_t to uint16_t to prevent possible data loss. Also changed type of head variable in function virtio_send_command from uint32_t to uint16_t. Issues found with static code analysis tool. Signed-off-by: Maciej Gajdzica --- lib/librte_pmd_virtio/virtio_ethdev.c | 4 ++-- lib/librte_pmd_virtio/virtio_ethdev.h | 2 +- lib/librte_pmd_virtio/virtio_rxtx.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c b/lib/librte_pmd_virtio/virtio_ethdev.c index b3b5bb6..6624916 100644 --- a/lib/librte_pmd_virtio/virtio_ethdev.c +++ b/lib/librte_pmd_virtio/virtio_ethdev.c @@ -106,7 +106,7 @@ static int virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl, int *dlen, int pkt_num) { - uint32_t head = vq->vq_desc_head_idx, i; + uint16_t head = vq->vq_desc_head_idx, i; int k, sum = 0; virtio_net_ctrl_ack status = ~0; struct virtio_pmd_ctrl result; @@ -233,7 +233,7 @@ virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues) int virtio_dev_queue_setup(struct rte_eth_dev *dev, int queue_type, uint16_t queue_idx, - uint8_t vtpci_queue_idx, + uint16_t vtpci_queue_idx, uint16_t nb_desc, unsigned int socket_id, struct virtqueue **pvq) diff --git a/lib/librte_pmd_virtio/virtio_ethdev.h b/lib/librte_pmd_virtio/virtio_ethdev.h index 1da3c62..1c463b1 100644 --- a/lib/librte_pmd_virtio/virtio_ethdev.h +++ b/lib/librte_pmd_virtio/virtio_ethdev.h @@ -87,7 +87,7 @@ void virtio_dev_rxtx_start(struct rte_eth_dev *dev); int virtio_dev_queue_setup(struct rte_eth_dev *dev, int queue_type, uint16_t queue_idx, - uint8_t vtpci_queue_idx, + uint16_t vtpci_queue_idx, uint16_t nb_desc, unsigned int socket_id, struct virtqueue **pvq); diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c b/lib/librte_pmd_virtio/virtio_rxtx.c index c013f97..468e978 100644 --- a/lib/librte_pmd_virtio/virtio_rxtx.c +++ b/lib/librte_pmd_virtio/virtio_rxtx.c @@ -369,7 +369,7 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, __rte_unused const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp) { - uint8_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX; + uint16_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX; struct virtqueue *vq; int ret; @@ -402,7 +402,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, const struct rte_eth_txconf *tx_conf) { - uint8_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX; + uint16_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX; struct virtqueue *vq; int ret; -- 1.7.9.5