From 742d8aaa81378e422aba63c1592978386a6db983 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 9 Nov 2022 15:46:46 -0800 Subject: [PATCH] drivers/net: remove unnecessary null checks The function rte_free() already handles NULL argument; therefore the checks in this code are unnecessary. Signed-off-by: Stephen Hemminger --- drivers/net/gve/gve_ethdev.c | 6 ++---- drivers/net/idpf/idpf_rxtx.c | 3 +-- drivers/net/mlx5/hws/mlx5dr_pool.c | 3 +-- drivers/net/mlx5/mlx5_flow_hw.c | 6 ++---- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c index 274a183250..97781f0ed3 100644 --- a/drivers/net/gve/gve_ethdev.c +++ b/drivers/net/gve/gve_ethdev.c @@ -81,12 +81,10 @@ gve_free_qpls(struct gve_priv *priv) for (i = 0; i < nb_txqs + nb_rxqs; i++) { if (priv->qpl[i].mz != NULL) rte_memzone_free(priv->qpl[i].mz); - if (priv->qpl[i].page_buses != NULL) - rte_free(priv->qpl[i].page_buses); + rte_free(priv->qpl[i].page_buses); } - if (priv->qpl != NULL) - rte_free(priv->qpl); + rte_free(priv->qpl); } static int diff --git a/drivers/net/idpf/idpf_rxtx.c b/drivers/net/idpf/idpf_rxtx.c index ef2fdb317d..b4a396c3f5 100644 --- a/drivers/net/idpf/idpf_rxtx.c +++ b/drivers/net/idpf/idpf_rxtx.c @@ -255,8 +255,7 @@ reset_single_rx_queue(struct idpf_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; diff --git a/drivers/net/mlx5/hws/mlx5dr_pool.c b/drivers/net/mlx5/hws/mlx5dr_pool.c index 2bfda5b4a5..fdbd3d438d 100644 --- a/drivers/net/mlx5/hws/mlx5dr_pool.c +++ b/drivers/net/mlx5/hws/mlx5dr_pool.c @@ -537,8 +537,7 @@ static void mlx5dr_onesize_element_db_uninit(struct mlx5dr_pool *pool) for (i = 0; i < MLX5DR_POOL_RESOURCE_ARR_SZ; i++) { elem = pool->db.element_manager->elements[i]; if (elem) { - if (elem->bitmap) - rte_free(elem->bitmap); + rte_free(elem->bitmap); simple_free(elem); pool->db.element_manager->elements[i] = NULL; } diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 537bcf141d..f4493ad556 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -7039,10 +7039,8 @@ flow_hw_configure(struct rte_eth_dev *dev, if (dr_ctx) claim_zero(mlx5dr_context_close(dr_ctx)); for (i = 0; i < nb_q_updated; i++) { - if (priv->hw_q[i].indir_iq) - rte_ring_free(priv->hw_q[i].indir_iq); - if (priv->hw_q[i].indir_cq) - rte_ring_free(priv->hw_q[i].indir_cq); + rte_ring_free(priv->hw_q[i].indir_iq); + rte_ring_free(priv->hw_q[i].indir_cq); } mlx5_free(priv->hw_q); priv->hw_q = NULL;