remove unnecessary null check before free/rte_free
Checks
Commit Message
This is the latest round of places that are checking for NULL
pointer before calling free or rte_free. It is result of applying
the nullfree.cocci script.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_cryptodev_asym.c | 3 +--
app/test/test_reassembly_perf.c | 3 +--
drivers/net/bnxt/bnxt_ethdev.c | 3 +--
drivers/net/bnxt/bnxt_vnic.c | 3 +--
drivers/net/cpfl/cpfl_fxp_rule.c | 3 +--
drivers/net/nfp/nfp_ipsec.c | 3 +--
drivers/net/qede/base/bcm_osal.c | 3 +--
7 files changed, 7 insertions(+), 14 deletions(-)
Comments
25/10/2023 00:58, Stephen Hemminger:
> This is the latest round of places that are checking for NULL
> pointer before calling free or rte_free. It is result of applying
> the nullfree.cocci script.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Applied and re-run with more fixes in new ml/cnxk code, thanks.
@@ -565,8 +565,7 @@ ut_teardown_asym(void)
if (self->sess != NULL)
rte_cryptodev_asym_session_free(dev_id, self->sess);
- if (self->op != NULL)
- rte_crypto_op_free(self->op);
+ rte_crypto_op_free(self->op);
self->sess = NULL;
self->op = NULL;
self->result_op = NULL;
@@ -81,8 +81,7 @@ reassembly_test_teardown(void)
if (frag_tbl != NULL)
rte_ip_frag_table_destroy(frag_tbl);
- if (pkt_pool != NULL)
- rte_mempool_free(pkt_pool);
+ rte_mempool_free(pkt_pool);
}
static void
@@ -6004,8 +6004,7 @@ static void bnxt_free_ctx_mem_buf(struct bnxt_ctx_mem_buf_info *ctx)
if (!ctx)
return;
- if (ctx->va)
- rte_free(ctx->va);
+ rte_free(ctx->va);
ctx->va = NULL;
ctx->dma = RTE_BAD_IOVA;
@@ -847,8 +847,7 @@ bnxt_vnic_rss_hash_algo_update(struct bnxt *bp,
int32_t bnxt_vnic_queue_db_deinit(struct bnxt *bp)
{
- if (bp->vnic_queue_db.rss_q_db != NULL)
- rte_hash_free(bp->vnic_queue_db.rss_q_db);
+ rte_hash_free(bp->vnic_queue_db.rss_q_db);
return 0;
}
@@ -55,8 +55,7 @@ cpfl_send_ctlq_msg(struct idpf_hw *hw, struct idpf_ctlq_info *cq, u16 num_q_msg,
}
send_err:
- if (msg_ptr_list)
- free(msg_ptr_list);
+ free(msg_ptr_list);
err:
return ret;
}
@@ -1415,8 +1415,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
static void
nfp_ipsec_ctx_destroy(struct rte_eth_dev *dev)
{
- if (dev->security_ctx != NULL)
- rte_free(dev->security_ctx);
+ rte_free(dev->security_ctx);
}
void
@@ -69,8 +69,7 @@ int ecore_mz_mapping_alloc(void)
void ecore_mz_mapping_free(void)
{
if (__atomic_fetch_sub(&ref_cnt, 1, __ATOMIC_RELAXED) - 1 == 0) {
- if (ecore_mz_mapping)
- rte_free(ecore_mz_mapping);
+ rte_free(ecore_mz_mapping);
ecore_mz_mapping = NULL;
}
}