[dpdk-dev] [PATCH] bond: changed rx and tx queue_id field type to prevent data loss.

Maciej Gajdzica maciejx.t.gajdzica at intel.com
Fri Feb 20 17:11:20 CET 2015


Previous type of rx and tx queue_id field was int, which caused possible
data loss when calling functions expecting uint16_t as an argument.
Issue found with static code analysis tool.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica at intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c     |    3 ++-
 lib/librte_pmd_bond/rte_eth_bond_private.h |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 7a17f53..a8df699 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -937,7 +937,8 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	struct bond_rx_queue *bd_rx_q;
 	struct bond_tx_queue *bd_tx_q;
 
-	int errval, q_id;
+	int errval;
+	uint16_t q_id;
 
 	/* Stop slave */
 	rte_eth_dev_stop(slave_eth_dev->data->port_id);
diff --git a/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h
index 3da5a9e..65697bd 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_private.h
+++ b/lib/librte_pmd_bond/rte_eth_bond_private.h
@@ -65,7 +65,7 @@ extern const char *driver_name;
 
 /** Port Queue Mapping Structure */
 struct bond_rx_queue {
-	int queue_id;
+	uint16_t queue_id;
 	/**< Queue Id */
 	struct bond_dev_private *dev_private;
 	/**< Reference to eth_dev private structure */
@@ -78,7 +78,7 @@ struct bond_rx_queue {
 };
 
 struct bond_tx_queue {
-	int queue_id;
+	uint16_t queue_id;
 	/**< Queue Id */
 	struct bond_dev_private *dev_private;
 	/**< Reference to dev private structure */
-- 
1.7.9.5



More information about the dev mailing list