DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	David Hunt <david.hunt@intel.com>,
	Brian Dooley <brian.dooley@intel.com>
Subject: [PATCH 4/4] examples: remove unnecessary null checks
Date: Wed,  9 Nov 2022 15:46:49 -0800	[thread overview]
Message-ID: <20221109234649.331942-5-stephen@networkplumber.org> (raw)
In-Reply-To: <20221109234649.331942-1-stephen@networkplumber.org>

The function rte_free() already handles NULL argument;
therefore the checks in this code are unnecessary.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/distributor/main.c     |  3 +--
 examples/fips_validation/main.c | 15 +++++----------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index e767973ed8de..21304d661873 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -1017,8 +1017,7 @@ main(int argc, char *argv[])
 
 	print_stats();
 
-	if (pd)
-		rte_free(pd);
+	rte_free(pd);
 	rte_free(pr);
 
 	/* clean up the EAL */
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 40a5b70e073b..73caaffb7e7a 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -962,8 +962,7 @@ prepare_rsa_op(void)
 		asym->rsa.message.data = msg.val;
 		asym->rsa.message.length = msg.len;
 
-		if (vec.rsa.signature.val)
-			rte_free(vec.rsa.signature.val);
+		rte_free(vec.rsa.signature.val);
 
 		vec.rsa.signature.val = rte_zmalloc(NULL, vec.rsa.n.len, 0);
 		vec.rsa.signature.len = vec.rsa.n.len;
@@ -1011,11 +1010,9 @@ prepare_ecdsa_op(void)
 		asym->ecdsa.k.data = vec.ecdsa.k.val;
 		asym->ecdsa.k.length = vec.ecdsa.k.len;
 
-		if (vec.ecdsa.r.val)
-			rte_free(vec.ecdsa.r.val);
+		rte_free(vec.ecdsa.r.val);
 
-		if (vec.ecdsa.s.val)
-			rte_free(vec.ecdsa.s.val);
+		rte_free(vec.ecdsa.s.val);
 
 		vec.ecdsa.r.len = info.interim_info.ecdsa_data.curve_len;
 		vec.ecdsa.r.val = rte_zmalloc(NULL, vec.ecdsa.r.len, 0);
@@ -1060,11 +1057,9 @@ prepare_ecfpm_op(void)
 	asym->ecpm.scalar.data = vec.ecdsa.pkey.val;
 	asym->ecpm.scalar.length = vec.ecdsa.pkey.len;
 
-	if (vec.ecdsa.qx.val)
-		rte_free(vec.ecdsa.qx.val);
+	rte_free(vec.ecdsa.qx.val);
 
-	if (vec.ecdsa.qy.val)
-		rte_free(vec.ecdsa.qy.val);
+	rte_free(vec.ecdsa.qy.val);
 
 	vec.ecdsa.qx.len = info.interim_info.ecdsa_data.curve_len;
 	vec.ecdsa.qx.val = rte_zmalloc(NULL, vec.ecdsa.qx.len, 0);
-- 
2.35.1


  parent reply	other threads:[~2022-11-09 23:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 23:46 [PATCH 0/4] " Stephen Hemminger
2022-11-09 23:46 ` [PATCH 1/4] gve: " Stephen Hemminger
2022-11-09 23:46 ` [PATCH 2/4] mlx5: " Stephen Hemminger
2022-11-09 23:46 ` [PATCH 3/4] idpf: remvoee " Stephen Hemminger
2022-11-09 23:46 ` Stephen Hemminger [this message]
2022-11-14 15:43   ` [PATCH 4/4] examples: remove " Dooley, Brian
2022-11-15 14:03 ` [PATCH 0/4] " Thomas Monjalon
2022-11-15 16:46   ` Stephen Hemminger
2022-11-15 17:23     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221109234649.331942-5-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=brian.dooley@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).