From: Stephen Hemminger stephen@networkplumber.org
Functions like free, rte_free, and rte_mempool_free already handle NULL pointer so the checks here are not necessary.
Remove redundant NULL pointer checks before free functions found by nullfree.cocci
Note: This patch only captures some hns3 modification from the following patch: Fixes: 06c047b68061 ("remove unnecessary null checks")
Signed-off-by: Stephen Hemminger stephen@networkplumber.org --- drivers/net/hns3/hns3_rxtx.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 8ad40a49c7..29caaeafbd 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -86,8 +86,7 @@ hns3_rx_queue_release(void *queue) hns3_rx_queue_release_mbufs(rxq); if (rxq->mz) rte_memzone_free(rxq->mz); - if (rxq->sw_ring) - rte_free(rxq->sw_ring); + rte_free(rxq->sw_ring); rte_free(rxq); } } @@ -100,10 +99,8 @@ hns3_tx_queue_release(void *queue) hns3_tx_queue_release_mbufs(txq); if (txq->mz) rte_memzone_free(txq->mz); - if (txq->sw_ring) - rte_free(txq->sw_ring); - if (txq->free) - rte_free(txq->free); + rte_free(txq->sw_ring); + rte_free(txq->free); rte_free(txq); } }