[v2,51/83] net/i40e: remove unnecessary NULL checks

Message ID 20220124174719.14417-52-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series remove unnecessary null checks |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Jan. 24, 2022, 5:46 p.m. UTC
  Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/i40e/i40e_ethdev.c | 27 +++++++++------------------
 drivers/net/i40e/i40e_rxtx.c   |  3 +--
 2 files changed, 10 insertions(+), 20 deletions(-)
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 1d417dbf8ad7..ecfa3c94db44 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1781,10 +1781,8 @@  i40e_rm_ethtype_filter_list(struct i40e_pf *pf)
 
 	ethertype_rule = &pf->ethertype;
 	/* Remove all ethertype filter rules and hash */
-	if (ethertype_rule->hash_map)
-		rte_free(ethertype_rule->hash_map);
-	if (ethertype_rule->hash_table)
-		rte_hash_free(ethertype_rule->hash_table);
+	rte_free(ethertype_rule->hash_map);
+	rte_hash_free(ethertype_rule->hash_table);
 
 	while ((p_ethertype = TAILQ_FIRST(&ethertype_rule->ethertype_list))) {
 		TAILQ_REMOVE(&ethertype_rule->ethertype_list,
@@ -1801,10 +1799,8 @@  i40e_rm_tunnel_filter_list(struct i40e_pf *pf)
 
 	tunnel_rule = &pf->tunnel;
 	/* Remove all tunnel director rules and hash */
-	if (tunnel_rule->hash_map)
-		rte_free(tunnel_rule->hash_map);
-	if (tunnel_rule->hash_table)
-		rte_hash_free(tunnel_rule->hash_table);
+	rte_free(tunnel_rule->hash_map);
+	rte_hash_free(tunnel_rule->hash_table);
 
 	while ((p_tunnel = TAILQ_FIRST(&tunnel_rule->tunnel_list))) {
 		TAILQ_REMOVE(&tunnel_rule->tunnel_list, p_tunnel, rules);
@@ -1833,16 +1829,11 @@  i40e_fdir_memory_cleanup(struct i40e_pf *pf)
 	fdir_info = &pf->fdir;
 
 	/* flow director memory cleanup */
-	if (fdir_info->hash_map)
-		rte_free(fdir_info->hash_map);
-	if (fdir_info->hash_table)
-		rte_hash_free(fdir_info->hash_table);
-	if (fdir_info->fdir_flow_pool.bitmap)
-		rte_free(fdir_info->fdir_flow_pool.bitmap);
-	if (fdir_info->fdir_flow_pool.pool)
-		rte_free(fdir_info->fdir_flow_pool.pool);
-	if (fdir_info->fdir_filter_array)
-		rte_free(fdir_info->fdir_filter_array);
+	rte_free(fdir_info->hash_map);
+	rte_hash_free(fdir_info->hash_table);
+	rte_free(fdir_info->fdir_flow_pool.bitmap);
+	rte_free(fdir_info->fdir_flow_pool.pool);
+	rte_free(fdir_info->fdir_filter_array);
 }
 
 void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 9a00a9b71e2c..25a28ecea22c 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2573,8 +2573,7 @@  i40e_reset_rx_queue(struct i40e_rx_queue *rxq)
 	rxq->rx_tail = 0;
 	rxq->nb_rx_hold = 0;
 
-	if (rxq->pkt_first_seg != NULL)
-		rte_pktmbuf_free(rxq->pkt_first_seg);
+	rte_pktmbuf_free(rxq->pkt_first_seg);
 
 	rxq->pkt_first_seg = NULL;
 	rxq->pkt_last_seg = NULL;