[dpdk-dev] virtio: Changed variable types to prevent possible data loss in virtio_ethdev.c, virtio_ethdev.h and virtio_rxtx.c
Commit Message
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 <maciejx.t.gajdzica@intel.com>
---
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(-)
Comments
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Maciej Gajdzica
> Sent: Saturday, February 21, 2015 12:13 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] virtio: Changed variable types to prevent
> possible data loss in virtio_ethdev.c, virtio_ethdev.h and virtio_rxtx.c
>
> 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 <maciejx.t.gajdzica@intel.com>
> ---
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
@@ -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)
@@ -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);
@@ -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;