* [dpdk-dev] [PATCH 00/11] misc cleanup patches
@ 2015-07-24 17:06 Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count Stephen Hemminger
` (10 more replies)
0 siblings, 11 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
These are all low risk, low reward changes found by reviewing
while doing other work. Ok to defer them to 2.2 if necessary.
Stephen Hemminger (11):
eth: move queue check for rx_queue_count
eth: do simple return
kni: remove useless semicolon
eth: remove unnecessary return value
kni: eliminate unnecessary return variables
pipeline: remove useless cast
lpm: remove useless casts
hash: remove useless casts
kni: remove useless cast
i40e: remove useless cast
bond: remove useless cast
drivers/net/bonding/rte_eth_bond_pmd.c | 12 +++++------
drivers/net/e1000/em_rxtx.c | 5 -----
drivers/net/e1000/igb_rxtx.c | 5 -----
drivers/net/i40e/i40e_ethdev.c | 3 +--
drivers/net/i40e/i40e_rxtx.c | 5 -----
drivers/net/ixgbe/ixgbe_rxtx.c | 5 -----
.../linuxapp/kni/ethtool/igb/e1000_82575.c | 16 +++++---------
lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c | 9 ++++----
.../linuxapp/kni/ethtool/ixgbe/ixgbe_common.c | 4 ++--
lib/librte_ether/rte_ethdev.c | 25 +++++++++++++---------
lib/librte_hash/rte_cuckoo_hash.c | 4 ++--
lib/librte_hash/rte_fbk_hash.c | 3 +--
lib/librte_kni/rte_kni.c | 7 ++----
lib/librte_lpm/rte_lpm.c | 4 ++--
lib/librte_lpm/rte_lpm6.c | 8 +++----
lib/librte_pipeline/rte_pipeline.c | 4 ++--
16 files changed, 46 insertions(+), 73 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-07-26 13:47 ` Thomas Monjalon
2015-08-03 17:00 ` Zhang, Helin
2015-07-24 17:06 ` [dpdk-dev] [PATCH 02/11] eth: do simple return Stephen Hemminger
` (9 subsequent siblings)
10 siblings, 2 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
All implemenations of rx_queue_count need to check for queue_id
being valid, therefore move the test to common code.
Also, add missing queue validation for rx_descriptor_done
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/e1000/em_rxtx.c | 5 -----
drivers/net/e1000/igb_rxtx.c | 5 -----
drivers/net/i40e/i40e_rxtx.c | 5 -----
drivers/net/ixgbe/ixgbe_rxtx.c | 5 -----
lib/librte_ether/rte_ethdev.c | 11 +++++++++++
5 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 3b8776d..88ad7d7 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -1454,11 +1454,6 @@ eth_em_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
struct em_rx_queue *rxq;
uint32_t desc = 0;
- if (rx_queue_id >= dev->data->nb_rx_queues) {
- PMD_RX_LOG(DEBUG, "Invalid RX queue_id=%d", rx_queue_id);
- return 0;
- }
-
rxq = dev->data->rx_queues[rx_queue_id];
rxdp = &(rxq->rx_ring[rxq->rx_tail]);
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 3a31b21..2a3c41f 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -1543,11 +1543,6 @@ eth_igb_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
struct igb_rx_queue *rxq;
uint32_t desc = 0;
- if (rx_queue_id >= dev->data->nb_rx_queues) {
- PMD_RX_LOG(ERR, "Invalid RX queue id=%d", rx_queue_id);
- return 0;
- }
-
rxq = dev->data->rx_queues[rx_queue_id];
rxdp = &(rxq->rx_ring[rxq->rx_tail]);
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 891a221..5503ed9 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2547,11 +2547,6 @@ i40e_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
struct i40e_rx_queue *rxq;
uint16_t desc = 0;
- if (unlikely(rx_queue_id >= dev->data->nb_rx_queues)) {
- PMD_DRV_LOG(ERR, "Invalid RX queue id %u", rx_queue_id);
- return 0;
- }
-
rxq = dev->data->rx_queues[rx_queue_id];
rxdp = &(rxq->rx_ring[rxq->rx_tail]);
while ((desc < rxq->nb_rx_desc) &&
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index af7e222..9a14d72 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2598,11 +2598,6 @@ ixgbe_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
struct ixgbe_rx_queue *rxq;
uint32_t desc = 0;
- if (rx_queue_id >= dev->data->nb_rx_queues) {
- PMD_RX_LOG(ERR, "Invalid RX queue id=%d", rx_queue_id);
- return 0;
- }
-
rxq = dev->data->rx_queues[rx_queue_id];
rxdp = &(rxq->rx_ring[rxq->rx_tail]);
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 8751801..f46426e 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -122,6 +122,7 @@
} \
} while (0)
+
static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
static struct rte_eth_dev_data *rte_eth_dev_data;
@@ -2910,6 +2911,11 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
VALID_PORTID_OR_ERR_RET(port_id, 0);
+ if (queue_id >= dev->data->nb_rx_queues) {
+ PMD_RX_LOG(ERR, "Invalid RX queue id=%d", queue_id);
+ return 0;
+ }
+
dev = &rte_eth_devices[port_id];
FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
@@ -2922,6 +2928,11 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+ if (queue_id >= dev->data->nb_rx_queues) {
+ PMD_RX_LOG(ERR, "Invalid RX queue id=%d", queue_id);
+ return 0;
+ }
+
dev = &rte_eth_devices[port_id];
FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
return (*dev->dev_ops->rx_descriptor_done)(dev->data->rx_queues[queue_id],
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 02/11] eth: do simple return
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 03/11] kni: remove useless semicolon Stephen Hemminger
` (8 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
Found by coccinelle simple_return.cocci
This function can just use direct return.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_ether/rte_ethdev.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f46426e..a96cd4f 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -269,17 +269,12 @@ static int
rte_eth_dev_create_unique_device_name(char *name, size_t size,
struct rte_pci_device *pci_dev)
{
- int ret;
-
if ((name == NULL) || (pci_dev == NULL))
return -EINVAL;
- ret = snprintf(name, size, "%d:%d.%d",
+ return snprintf(name, size, "%d:%d.%d",
pci_dev->addr.bus, pci_dev->addr.devid,
pci_dev->addr.function);
- if (ret < 0)
- return ret;
- return 0;
}
int
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 03/11] kni: remove useless semicolon
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 02/11] eth: do simple return Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 04/11] eth: remove unnecessary return value Stephen Hemminger
` (7 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
Found by coccinelle semicolon.cocci script
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c
index 93659ca..1b78902 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c
@@ -1534,7 +1534,7 @@ static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw)
udelay(5);
ixgbe_standby_eeprom(hw);
- };
+ }
/*
* On some parts, SPI write time could vary from 0-20mSec on 3.3V
@@ -1616,7 +1616,7 @@ static void ixgbe_shift_out_eeprom_bits(struct ixgbe_hw *hw, u16 data,
* EEPROM
*/
mask = mask >> 1;
- };
+ }
/* We leave the "DI" bit set to "0" when we leave this routine. */
eec &= ~IXGBE_EEC_DI;
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 04/11] eth: remove unnecessary return value
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
` (2 preceding siblings ...)
2015-07-24 17:06 ` [dpdk-dev] [PATCH 03/11] kni: remove useless semicolon Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 05/11] kni: eliminate unnecessary return variables Stephen Hemminger
` (6 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
Eliminate unnecessary variable for return value
Found with returnvar.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_ether/rte_ethdev.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a96cd4f..d72fa8e 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1892,7 +1892,6 @@ int
rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
{
struct rte_eth_dev *dev;
- int ret = 0;
int mask = 0;
int cur, org = 0;
@@ -1921,14 +1920,14 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
mask |= ETH_VLAN_EXTEND_MASK;
}
- /*no change*/
+ /* no change */
if (mask == 0)
- return ret;
+ return 0;
FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
(*dev->dev_ops->vlan_offload_set)(dev, mask);
- return ret;
+ return 0;
}
int
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 05/11] kni: eliminate unnecessary return variables
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
` (3 preceding siblings ...)
2015-07-24 17:06 ` [dpdk-dev] [PATCH 04/11] eth: remove unnecessary return value Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 06/11] pipeline: remove useless cast Stephen Hemminger
` (5 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
If function just sets a variable (and never changes it) and then
returns that value, just move the constant to return.
Found with returnvar.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_eal/linuxapp/kni/ethtool/igb/e1000_82575.c | 16 +++++-----------
lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c | 9 ++++-----
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/e1000_82575.c b/lib/librte_eal/linuxapp/kni/ethtool/igb/e1000_82575.c
index b8c9a13..e3a874b 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/e1000_82575.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/e1000_82575.c
@@ -876,7 +876,6 @@ out:
static s32 e1000_set_d0_lplu_state_82580(struct e1000_hw *hw, bool active)
{
struct e1000_phy_info *phy = &hw->phy;
- s32 ret_val = E1000_SUCCESS;
u32 data;
DEBUGFUNC("e1000_set_d0_lplu_state_82580");
@@ -904,7 +903,7 @@ static s32 e1000_set_d0_lplu_state_82580(struct e1000_hw *hw, bool active)
}
E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, data);
- return ret_val;
+ return E1000_SUCCESS;
}
/**
@@ -924,7 +923,6 @@ static s32 e1000_set_d0_lplu_state_82580(struct e1000_hw *hw, bool active)
s32 e1000_set_d3_lplu_state_82580(struct e1000_hw *hw, bool active)
{
struct e1000_phy_info *phy = &hw->phy;
- s32 ret_val = E1000_SUCCESS;
u32 data;
DEBUGFUNC("e1000_set_d3_lplu_state_82580");
@@ -952,7 +950,7 @@ s32 e1000_set_d3_lplu_state_82580(struct e1000_hw *hw, bool active)
}
E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, data);
- return ret_val;
+ return E1000_SUCCESS;
}
/**
@@ -1112,7 +1110,6 @@ static void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
static s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
{
s32 timeout = PHY_CFG_TIMEOUT;
- s32 ret_val = E1000_SUCCESS;
u32 mask = E1000_NVM_CFG_DONE_PORT_0;
DEBUGFUNC("e1000_get_cfg_done_82575");
@@ -1137,7 +1134,7 @@ static s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
(hw->phy.type == e1000_phy_igp_3))
e1000_phy_init_script_igp3(hw);
- return ret_val;
+ return E1000_SUCCESS;
}
/**
@@ -2786,7 +2783,6 @@ s32 e1000_read_emi_reg(struct e1000_hw *hw, u16 addr, u16 *data)
**/
s32 e1000_set_eee_i350(struct e1000_hw *hw)
{
- s32 ret_val = E1000_SUCCESS;
u32 ipcnfg, eeer;
DEBUGFUNC("e1000_set_eee_i350");
@@ -2818,8 +2814,7 @@ s32 e1000_set_eee_i350(struct e1000_hw *hw)
E1000_READ_REG(hw, E1000_IPCNFG);
E1000_READ_REG(hw, E1000_EEER);
out:
-
- return ret_val;
+ return E1000_SUCCESS;
}
/**
@@ -2986,7 +2981,6 @@ void e1000_write_vfta_i350(struct e1000_hw *hw, u32 offset, u32 value)
**/
s32 e1000_set_i2c_bb(struct e1000_hw *hw)
{
- s32 ret_val = E1000_SUCCESS;
u32 ctrl_ext, i2cparams;
DEBUGFUNC("e1000_set_i2c_bb");
@@ -3003,7 +2997,7 @@ s32 e1000_set_i2c_bb(struct e1000_hw *hw)
E1000_WRITE_REG(hw, E1000_I2CPARAMS, i2cparams);
E1000_WRITE_FLUSH(hw);
- return ret_val;
+ return E1000_SUCCESS;
}
/**
diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
index eed8df6..0c04787 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
@@ -1859,7 +1859,6 @@ static s32 igb_enable_mas(struct igb_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
u32 connsw;
- s32 ret_val = E1000_SUCCESS;
connsw = E1000_READ_REG(hw, E1000_CONNSW);
if (hw->phy.media_type == e1000_media_type_copper) {
@@ -1871,7 +1870,7 @@ static s32 igb_enable_mas(struct igb_adapter *adapter)
E1000_WRITE_FLUSH(hw);
} else if (connsw & E1000_CONNSW_SERDESD) {
/* already SerDes, no need to enable anything */
- return ret_val;
+ return E1000_SUCCESS;
} else {
dev_info(pci_dev_to_dev(adapter->pdev),
"%s:MAS: Unable to configure feature, disabling..\n",
@@ -1879,7 +1878,7 @@ static s32 igb_enable_mas(struct igb_adapter *adapter)
adapter->flags &= ~IGB_FLAG_MAS_ENABLE;
}
}
- return ret_val;
+ return E1000_SUCCESS;
}
void igb_reset(struct igb_adapter *adapter)
@@ -2424,14 +2423,14 @@ int igb_init_vmdq_netdevs(struct igb_adapter *adapter)
int igb_remove_vmdq_netdevs(struct igb_adapter *adapter)
{
- int pool, err = 0;
+ int pool;
for (pool = 1; pool < adapter->vmdq_pools; pool++) {
unregister_netdev(adapter->vmdq_netdev[pool-1]);
free_netdev(adapter->vmdq_netdev[pool-1]);
adapter->vmdq_netdev[pool-1] = NULL;
}
- return err;
+ return 0;
}
#endif /* CONFIG_IGB_VMDQ_NETDEV */
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 06/11] pipeline: remove useless cast
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
` (4 preceding siblings ...)
2015-07-24 17:06 ` [dpdk-dev] [PATCH 05/11] kni: eliminate unnecessary return variables Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 07/11] lpm: remove useless casts Stephen Hemminger
` (4 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
Found by modified version of acll_cast.cocci
lib/librte_pipeline/rte_pipeline.c:358:18-49: WARNING: casting value returned by memory allocation function to (struct rte_pipeline_table_entry *) is useless.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_pipeline/rte_pipeline.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/librte_pipeline/rte_pipeline.c b/lib/librte_pipeline/rte_pipeline.c
index bd700d2..d56cfa7 100644
--- a/lib/librte_pipeline/rte_pipeline.c
+++ b/lib/librte_pipeline/rte_pipeline.c
@@ -355,8 +355,8 @@ rte_pipeline_table_create(struct rte_pipeline *p,
/* Allocate space for the default table entry */
entry_size = sizeof(struct rte_pipeline_table_entry) +
params->action_data_size;
- default_entry = (struct rte_pipeline_table_entry *) rte_zmalloc_socket(
- "PIPELINE", entry_size, RTE_CACHE_LINE_SIZE, p->socket_id);
+ default_entry = rte_zmalloc_socket("PIPELINE", entry_size,
+ RTE_CACHE_LINE_SIZE, p->socket_id);
if (default_entry == NULL) {
RTE_LOG(ERR, PIPELINE,
"%s: Failed to allocate default entry\n", __func__);
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 07/11] lpm: remove useless casts
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
` (5 preceding siblings ...)
2015-07-24 17:06 ` [dpdk-dev] [PATCH 06/11] pipeline: remove useless cast Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 08/11] hash: " Stephen Hemminger
` (3 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
Found by modified coccinelle script.
lib/librte_lpm/rte_lpm6.c:196:8-23: WARNING: casting value returned by memory allocation function to (struct rte_lpm6 *) is useless.
lib/librte_lpm/rte_lpm6.c:205:19-39: WARNING: casting value returned by memory allocation function to (struct rte_lpm6_rule *) is useless.
lib/librte_lpm/rte_lpm.c:195:8-22: WARNING: casting value returned by memory allocation function to (struct rte_lpm *) is useless.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_lpm/rte_lpm.c | 4 ++--
lib/librte_lpm/rte_lpm6.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index de05307..e71bd15 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -192,8 +192,8 @@ rte_lpm_create(const char *name, int socket_id, int max_rules,
}
/* Allocate memory to store the LPM data structures. */
- lpm = (struct rte_lpm *)rte_zmalloc_socket(mem_name, mem_size,
- RTE_CACHE_LINE_SIZE, socket_id);
+ lpm = rte_zmalloc_socket(mem_name, mem_size,
+ RTE_CACHE_LINE_SIZE, socket_id);
if (lpm == NULL) {
RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
rte_free(te);
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index 6c2b293..ec2d482 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -193,8 +193,8 @@ rte_lpm6_create(const char *name, int socket_id,
}
/* Allocate memory to store the LPM data structures. */
- lpm = (struct rte_lpm6 *)rte_zmalloc_socket(mem_name, (size_t)mem_size,
- RTE_CACHE_LINE_SIZE, socket_id);
+ lpm = rte_zmalloc_socket(mem_name, (size_t)mem_size,
+ RTE_CACHE_LINE_SIZE, socket_id);
if (lpm == NULL) {
RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
@@ -202,8 +202,8 @@ rte_lpm6_create(const char *name, int socket_id,
goto exit;
}
- lpm->rules_tbl = (struct rte_lpm6_rule *)rte_zmalloc_socket(NULL,
- (size_t)rules_size, RTE_CACHE_LINE_SIZE, socket_id);
+ lpm->rules_tbl = rte_zmalloc_socket(NULL, (size_t)rules_size,
+ RTE_CACHE_LINE_SIZE, socket_id);
if (lpm->rules_tbl == NULL) {
RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 08/11] hash: remove useless casts
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
` (6 preceding siblings ...)
2015-07-24 17:06 ` [dpdk-dev] [PATCH 07/11] lpm: remove useless casts Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 09/11] kni: remove useless cast Stephen Hemminger
` (2 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
Found by coccinelle.
lib/librte_hash/rte_fbk_hash.c:153:7-32: WARNING: casting value returned by memory allocation function to (struct rte_fbk_hash_table *) is useless.
lib/librte_hash/rte_cuckoo_hash.c:218:6-21: WARNING: casting value returned by memory allocation function to (struct rte_hash *) is useless.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_hash/rte_cuckoo_hash.c | 4 ++--
lib/librte_hash/rte_fbk_hash.c | 3 +--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 5cf4af6..3a4f5e9 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -215,8 +215,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
goto err;
}
- h = (struct rte_hash *)rte_zmalloc_socket(hash_name, sizeof(struct rte_hash),
- RTE_CACHE_LINE_SIZE, params->socket_id);
+ h = rte_zmalloc_socket(hash_name, sizeof(struct rte_hash),
+ RTE_CACHE_LINE_SIZE, params->socket_id);
if (h == NULL) {
RTE_LOG(ERR, HASH, "memory allocation failed\n");
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 8752a47..4c27756 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -150,8 +150,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
}
/* Allocate memory for table. */
- ht = (struct rte_fbk_hash_table *)rte_zmalloc_socket(hash_name, mem_size,
- 0, params->socket_id);
+ ht = rte_zmalloc_socket(hash_name, mem_size, 0, params->socket_id);
if (ht == NULL) {
RTE_LOG(ERR, HASH, "Failed to allocate fbk hash table\n");
rte_free(te);
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 09/11] kni: remove useless cast
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
` (7 preceding siblings ...)
2015-07-24 17:06 ` [dpdk-dev] [PATCH 08/11] hash: " Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 10/11] i40e: " Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 11/11] bond: " Stephen Hemminger
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
lib/librte_kni/rte_kni.c:224:27-54: WARNING: casting value returned by memory allocation function to (struct rte_kni_memzone_slot *) is useless.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_kni/rte_kni.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 08155db..fd70448 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -221,11 +221,8 @@ rte_kni_init(unsigned int max_kni_ifaces)
}
/* Allocate slot objects */
- kni_memzone_pool.slots = (struct rte_kni_memzone_slot *)
- rte_malloc(NULL,
- sizeof(struct rte_kni_memzone_slot) *
- max_kni_ifaces,
- 0);
+ kni_memzone_pool.slots = rte_calloc(NULL, max_kni_ifaces,
+ sizeof(struct rte_kni_memzone_slot), 0);
KNI_MEM_CHECK(kni_memzone_pool.slots == NULL);
/* Initialize general pool variables */
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 10/11] i40e: remove useless cast
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
` (8 preceding siblings ...)
2015-07-24 17:06 ` [dpdk-dev] [PATCH 09/11] kni: remove useless cast Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
2015-08-03 16:56 ` Zhang, Helin
2015-07-24 17:06 ` [dpdk-dev] [PATCH 11/11] bond: " Stephen Hemminger
10 siblings, 1 reply; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
drivers/net/i40e/i40e_ethdev.c:2360:18-56: WARNING: casting value returned by memory allocation function to (struct i40e_aqc_get_switch_config_resp *) is useless.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/i40e/i40e_ethdev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 40b0526..0e19f2e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2357,8 +2357,7 @@ i40e_pf_get_switch_config(struct i40e_pf *pf)
uint16_t start_seid = 0, num_reported;
int ret;
- switch_config = (struct i40e_aqc_get_switch_config_resp *)\
- rte_zmalloc("i40e", I40E_AQ_LARGE_BUF, 0);
+ switch_config = rte_zmalloc("i40e", I40E_AQ_LARGE_BUF, 0);
if (!switch_config) {
PMD_DRV_LOG(ERR, "Failed to allocated memory");
return -ENOMEM;
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 11/11] bond: remove useless cast
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
` (9 preceding siblings ...)
2015-07-24 17:06 ` [dpdk-dev] [PATCH 10/11] i40e: " Stephen Hemminger
@ 2015-07-24 17:06 ` Stephen Hemminger
10 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2015-07-24 17:06 UTC (permalink / raw)
To: dev
Found by coccinelle script.
drivers/net/bonding/rte_eth_bond_pmd.c:1587:34-54: WARNING: casting value returned by memory allocation function to (struct bond_rx_queue *) is useless.
drivers/net/bonding/rte_eth_bond_pmd.c:1611:35-55: WARNING: casting value returned by memory allocation function to (struct bond_tx_queue *) is useless.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/bonding/rte_eth_bond_pmd.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 9cafe65..5e8c447 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1584,9 +1584,9 @@ bond_ethdev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id __rte_unused,
const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mb_pool)
{
- struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)
- rte_zmalloc_socket(NULL, sizeof(struct bond_rx_queue),
- 0, dev->pci_dev->numa_node);
+ struct bond_rx_queue *bd_rx_q
+ = rte_zmalloc_socket(NULL, sizeof(struct bond_rx_queue),
+ 0, dev->pci_dev->numa_node);
if (bd_rx_q == NULL)
return -1;
@@ -1608,9 +1608,9 @@ bond_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
uint16_t nb_tx_desc, unsigned int socket_id __rte_unused,
const struct rte_eth_txconf *tx_conf)
{
- struct bond_tx_queue *bd_tx_q = (struct bond_tx_queue *)
- rte_zmalloc_socket(NULL, sizeof(struct bond_tx_queue),
- 0, dev->pci_dev->numa_node);
+ struct bond_tx_queue *bd_tx_q
+ = rte_zmalloc_socket(NULL, sizeof(struct bond_tx_queue),
+ 0, dev->pci_dev->numa_node);
if (bd_tx_q == NULL)
return -1;
--
2.1.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count
2015-07-24 17:06 ` [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count Stephen Hemminger
@ 2015-07-26 13:47 ` Thomas Monjalon
2015-08-03 17:00 ` Zhang, Helin
1 sibling, 0 replies; 15+ messages in thread
From: Thomas Monjalon @ 2015-07-26 13:47 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
2015-07-24 10:06, Stephen Hemminger:
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -122,6 +122,7 @@
> } \
> } while (0)
>
> +
checkpatch would warn about this whitespace change
> static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
> struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
> static struct rte_eth_dev_data *rte_eth_dev_data;
> @@ -2910,6 +2911,11 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
>
> VALID_PORTID_OR_ERR_RET(port_id, 0);
>
> + if (queue_id >= dev->data->nb_rx_queues) {
> + PMD_RX_LOG(ERR, "Invalid RX queue id=%d", queue_id);
> + return 0;
> + }
PMD_RX_LOG is not defined in ethdev.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 10/11] i40e: remove useless cast
2015-07-24 17:06 ` [dpdk-dev] [PATCH 10/11] i40e: " Stephen Hemminger
@ 2015-08-03 16:56 ` Zhang, Helin
0 siblings, 0 replies; 15+ messages in thread
From: Zhang, Helin @ 2015-08-03 16:56 UTC (permalink / raw)
To: Stephen Hemminger, dev
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger
> Sent: Friday, July 24, 2015 10:06 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 10/11] i40e: remove useless cast
>
> drivers/net/i40e/i40e_ethdev.c:2360:18-56: WARNING: casting value returned by
> memory allocation function to (struct i40e_aqc_get_switch_config_resp *) is
> useless.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Helin Zhang <helin.zhang@intel.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count
2015-07-24 17:06 ` [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count Stephen Hemminger
2015-07-26 13:47 ` Thomas Monjalon
@ 2015-08-03 17:00 ` Zhang, Helin
1 sibling, 0 replies; 15+ messages in thread
From: Zhang, Helin @ 2015-08-03 17:00 UTC (permalink / raw)
To: Stephen Hemminger, dev
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger
> Sent: Friday, July 24, 2015 10:06 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count
>
> All implemenations of rx_queue_count need to check for queue_id being valid,
> therefore move the test to common code.
> Also, add missing queue validation for rx_descriptor_done
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Helin Zhang <helin.zhang@intel.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2015-08-03 17:01 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-24 17:06 [dpdk-dev] [PATCH 00/11] misc cleanup patches Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count Stephen Hemminger
2015-07-26 13:47 ` Thomas Monjalon
2015-08-03 17:00 ` Zhang, Helin
2015-07-24 17:06 ` [dpdk-dev] [PATCH 02/11] eth: do simple return Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 03/11] kni: remove useless semicolon Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 04/11] eth: remove unnecessary return value Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 05/11] kni: eliminate unnecessary return variables Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 06/11] pipeline: remove useless cast Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 07/11] lpm: remove useless casts Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 08/11] hash: " Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 09/11] kni: remove useless cast Stephen Hemminger
2015-07-24 17:06 ` [dpdk-dev] [PATCH 10/11] i40e: " Stephen Hemminger
2015-08-03 16:56 ` Zhang, Helin
2015-07-24 17:06 ` [dpdk-dev] [PATCH 11/11] bond: " Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).