diff mbox series

[04/82] examples/fips_validation: remove unnecessary NULL checks

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Jan. 24, 2022, 12:04 a.m. UTC
Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/fips_validation/fips_dev_self_test.c | 18 ++++------
 examples/fips_validation/fips_validation.c    |  3 +-
 examples/fips_validation/main.c               | 36 +++++++------------
 3 files changed, 19 insertions(+), 38 deletions(-)
diff mbox series

Patch

diff --git a/examples/fips_validation/fips_dev_self_test.c b/examples/fips_validation/fips_dev_self_test.c
index b4eab05a9851..076e9de099c0 100644
--- a/examples/fips_validation/fips_dev_self_test.c
+++ b/examples/fips_validation/fips_dev_self_test.c
@@ -1396,8 +1396,7 @@  check_aead_result(struct rte_crypto_op *op,
 	if (!mbuf)
 		return -1;
 
-	if (op->sym->aead.aad.data)
-		rte_free(op->sym->aead.aad.data);
+	rte_free(op->sym->aead.aad.data);
 
 	if (dir == self_test_dir_enc_auth_gen) {
 		src = vec->output.data;
@@ -1523,18 +1522,13 @@  static void
 fips_dev_auto_test_uninit(uint8_t dev_id,
 		struct fips_dev_auto_test_env *env)
 {
-	if (env->mbuf)
-		rte_pktmbuf_free(env->mbuf);
+	rte_pktmbuf_free(env->mbuf);
 	if (env->op)
 		rte_crypto_op_free(env->op);
-	if (env->mpool)
-		rte_mempool_free(env->mpool);
-	if (env->op_pool)
-		rte_mempool_free(env->op_pool);
-	if (env->sess_pool)
-		rte_mempool_free(env->sess_pool);
-	if (env->sess_priv_pool)
-		rte_mempool_free(env->sess_priv_pool);
+	rte_mempool_free(env->mpool);
+	rte_mempool_free(env->op_pool);
+	rte_mempool_free(env->sess_pool);
+	rte_mempool_free(env->sess_priv_pool);
 
 	rte_cryptodev_stop(dev_id);
 }
diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index 52a7bf952d46..94253eaee8bf 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -344,8 +344,7 @@  fips_test_clear(void)
 		fclose(info.fp_rd);
 	if (info.fp_wr)
 		fclose(info.fp_wr);
-	if (info.one_line_text)
-		free(info.one_line_text);
+	free(info.one_line_text);
 	if (info.nb_vec_lines) {
 		uint32_t i;
 
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index dc40bffe7d97..e06ae37567fd 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -143,12 +143,9 @@  cryptodev_fips_validate_app_int(void)
 error_exit:
 
 	rte_mempool_free(env.mpool);
-	if (env.sess_mpool)
-		rte_mempool_free(env.sess_mpool);
-	if (env.sess_priv_mpool)
-		rte_mempool_free(env.sess_priv_mpool);
-	if (env.op_pool)
-		rte_mempool_free(env.op_pool);
+	rte_mempool_free(env.sess_mpool);
+	rte_mempool_free(env.sess_priv_mpool);
+	rte_mempool_free(env.op_pool);
 
 	return ret;
 }
@@ -523,8 +520,7 @@  prepare_data_mbufs(struct fips_val *val)
 	uint16_t nb_seg;
 	int ret = 0;
 
-	if (env.mbuf)
-		rte_pktmbuf_free(env.mbuf);
+	rte_pktmbuf_free(env.mbuf);
 
 	if (total_len > RTE_MBUF_MAX_NB_SEGS) {
 		RTE_LOG(ERR, USER1, "Data len %u too big\n", total_len);
@@ -598,8 +594,7 @@  prepare_data_mbufs(struct fips_val *val)
 	return 0;
 
 error_exit:
-	if (head)
-		rte_pktmbuf_free(head);
+	rte_pktmbuf_free(head);
 	return ret;
 }
 
@@ -656,8 +651,7 @@  prepare_auth_op(void)
 	if (ret < 0)
 		return ret;
 
-	if (env.digest)
-		rte_free(env.digest);
+	rte_free(env.digest);
 
 	env.digest = rte_zmalloc(NULL, vec.cipher_auth.digest.len,
 			RTE_CACHE_LINE_SIZE);
@@ -705,8 +699,7 @@  prepare_aead_op(void)
 		if (ret < 0)
 			return ret;
 
-		if (env.digest)
-			rte_free(env.digest);
+		rte_free(env.digest);
 		env.digest = rte_zmalloc(NULL, vec.aead.digest.len,
 				RTE_CACHE_LINE_SIZE);
 		if (!env.digest) {
@@ -1430,8 +1423,7 @@  fips_mct_tdes_test(void)
 		}
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1510,8 +1502,7 @@  fips_mct_aes_ecb_test(void)
 		}
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1619,8 +1610,7 @@  fips_mct_aes_test(void)
 			memcpy(vec.iv.val, val.val, AES_BLOCK_SIZE);
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1706,8 +1696,7 @@  fips_mct_sha_test(void)
 
 	rte_free(vec.pt.val);
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1851,8 +1840,7 @@  fips_test_one_file(void)
 		rte_free(env.digest);
 		env.digest = NULL;
 	}
-	if (env.mbuf)
-		rte_pktmbuf_free(env.mbuf);
+	rte_pktmbuf_free(env.mbuf);
 
 	return ret;
 }