From: Maciej Gajdzica Date: Fri, 20 Feb 2015 16:12:22 +0000 (+0000) Subject: bond: fix type for port and queue id X-Git-Tag: spdx-start~9375 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=495f91870ea160fb6414a056b1d5173310af39b9;p=dpdk.git bond: fix type for port and queue id In some places port_id is declared as int or uint16_t, which causes data loss when using functions expecting port_id as uint8_t. 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. Issues found with static code analysis tool. Signed-off-by: Maciej Gajdzica --- diff --git a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c index f1cf81a63a..97a828e7e6 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c +++ b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c @@ -747,7 +747,7 @@ bond_mode_8023ad_periodic_cb(void *arg) struct ether_addr slave_addr; void *pkt = NULL; - uint16_t i, slave_id; + uint8_t i, slave_id; /* Update link status on each port */ @@ -1050,7 +1050,7 @@ int bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev) { struct bond_dev_private *internals = bond_dev->data->dev_private; - uint16_t i; + uint8_t i; for (i = 0; i < internals->active_slave_count; i++) bond_mode_8023ad_activate_slave(bond_dev, i); diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c index af8113e99c..c937e6b074 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c +++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c @@ -617,7 +617,7 @@ bandwidth_cmp(const void *a, const void *b) } static void -bandwidth_left(int port_id, uint64_t load, uint8_t update_idx, +bandwidth_left(uint8_t port_id, uint64_t load, uint8_t update_idx, struct bwg_slave *bwg_slave) { struct rte_eth_link link_status; @@ -1296,7 +1296,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); @@ -2045,7 +2046,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev) char *name = dev->data->name; struct bond_dev_private *internals = dev->data->dev_private; struct rte_kvargs *kvlist = internals->kvlist; - int arg_count, port_id = dev - rte_eth_devices; + int arg_count; + uint8_t port_id = dev - rte_eth_devices; /* * if no kvlist, it means that this bonded device has been created diff --git a/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h index bef1e8191f..45e5c657a1 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_private.h +++ b/lib/librte_pmd_bond/rte_eth_bond_private.h @@ -66,7 +66,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 */ @@ -79,7 +79,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 */