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>,
	Srikanth Yalavarthi <syalavarthi@marvell.com>
Subject: [PATCH 1/4] mldev: remove unnecessary null free checks
Date: Wed, 22 Mar 2023 18:04:25 -0700	[thread overview]
Message-ID: <20230323010428.64020-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20230323010428.64020-1-stephen@networkplumber.org>

These are places where mldev is doing unnecessary checks
for calling free() style functions.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-mldev/test_device_ops.c       |  6 ++----
 app/test-mldev/test_inference_common.c | 24 ++++++++----------------
 app/test-mldev/test_model_ops.c        |  6 ++----
 lib/mldev/rte_mldev.c                  |  3 +--
 4 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/app/test-mldev/test_device_ops.c b/app/test-mldev/test_device_ops.c
index be0c5f0780d9..81b3ca18f36b 100644
--- a/app/test-mldev/test_device_ops.c
+++ b/app/test-mldev/test_device_ops.c
@@ -70,8 +70,7 @@ test_device_setup(struct ml_test *test, struct ml_options *opt)
 	return 0;
 
 error:
-	if (test_device != NULL)
-		rte_free(test_device);
+	rte_free(test_device);
 
 	return ret;
 }
@@ -84,8 +83,7 @@ test_device_destroy(struct ml_test *test, struct ml_options *opt)
 	RTE_SET_USED(opt);
 
 	t = ml_test_priv(test);
-	if (t != NULL)
-		rte_free(t);
+	rte_free(t);
 }
 
 static int
diff --git a/app/test-mldev/test_inference_common.c b/app/test-mldev/test_inference_common.c
index eba37c50e96c..af831fc1bf4c 100644
--- a/app/test-mldev/test_inference_common.c
+++ b/app/test-mldev/test_inference_common.c
@@ -492,8 +492,7 @@ test_inference_setup(struct ml_test *test, struct ml_options *opt)
 	return 0;
 
 error:
-	if (test_inference != NULL)
-		rte_free(test_inference);
+	rte_free(test_inference);
 
 	return ret;
 }
@@ -506,8 +505,7 @@ test_inference_destroy(struct ml_test *test, struct ml_options *opt)
 	RTE_SET_USED(opt);
 
 	t = ml_test_priv(test);
-	if (t != NULL)
-		rte_free(t);
+	rte_free(t);
 }
 
 int
@@ -748,8 +746,7 @@ ml_inference_iomem_destroy(struct ml_test *test, struct ml_options *opt, uint16_
 	/* destroy io pool */
 	sprintf(mp_name, "ml_io_pool_%d", fid);
 	mp = rte_mempool_lookup(mp_name);
-	if (mp != NULL)
-		rte_mempool_free(mp);
+	rte_mempool_free(mp);
 }
 
 int
@@ -776,8 +773,7 @@ ml_inference_mem_destroy(struct ml_test *test, struct ml_options *opt)
 	RTE_SET_USED(opt);
 
 	/* release op pool */
-	if (t->op_pool != NULL)
-		rte_mempool_free(t->op_pool);
+	rte_mempool_free(t->op_pool);
 }
 
 static bool
@@ -1088,11 +1084,9 @@ ml_inference_stats_get(struct ml_test *test, struct ml_options *opt)
 	print_line(80);
 
 	/* release buffers */
-	if (t->xstats_map)
-		rte_free(t->xstats_map);
+	rte_free(t->xstats_map);
 
-	if (t->xstats_values)
-		rte_free(t->xstats_values);
+	rte_free(t->xstats_values);
 
 	/* print end-to-end stats */
 	freq = rte_get_tsc_hz();
@@ -1129,11 +1123,9 @@ ml_inference_stats_get(struct ml_test *test, struct ml_options *opt)
 	return 0;
 
 error:
-	if (t->xstats_map)
-		rte_free(t->xstats_map);
+	rte_free(t->xstats_map);
 
-	if (t->xstats_values)
-		rte_free(t->xstats_values);
+	rte_free(t->xstats_values);
 
 	return ret;
 }
diff --git a/app/test-mldev/test_model_ops.c b/app/test-mldev/test_model_ops.c
index 0202b31190f8..5bbbcb1a6c0b 100644
--- a/app/test-mldev/test_model_ops.c
+++ b/app/test-mldev/test_model_ops.c
@@ -93,8 +93,7 @@ test_model_ops_setup(struct ml_test *test, struct ml_options *opt)
 	return 0;
 
 error:
-	if (test_model_ops != NULL)
-		rte_free(test_model_ops);
+	rte_free(test_model_ops);
 
 	return ret;
 }
@@ -107,8 +106,7 @@ test_model_ops_destroy(struct ml_test *test, struct ml_options *opt)
 	RTE_SET_USED(opt);
 
 	t = ml_test_priv(test);
-	if (t != NULL)
-		rte_free(t);
+	rte_free(t);
 }
 
 static int
diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c
index 50ebeb1bfe8d..f5904a0d4a90 100644
--- a/lib/mldev/rte_mldev.c
+++ b/lib/mldev/rte_mldev.c
@@ -836,8 +836,7 @@ rte_ml_op_pool_create(const char *name, unsigned int nb_elts, unsigned int cache
 void
 rte_ml_op_pool_free(struct rte_mempool *mempool)
 {
-	if (mempool != NULL)
-		rte_mempool_free(mempool);
+	rte_mempool_free(mempool);
 }
 
 uint16_t
-- 
2.39.2


  reply	other threads:[~2023-03-23  1:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23  1:04 [PATCH 0/4] Remove " Stephen Hemminger
2023-03-23  1:04 ` Stephen Hemminger [this message]
2023-03-23  4:06   ` [EXT] [PATCH 1/4] mldev: remove " Srikanth Yalavarthi
2023-03-23  1:04 ` [PATCH 2/4] ml/cnkx: remove unnecessary null checks Stephen Hemminger
2023-03-23  4:14   ` [EXT] " Srikanth Yalavarthi
2023-03-23  1:04 ` [PATCH 3/4] graph: remove unnicessary " Stephen Hemminger
2023-03-23  1:04 ` [PATCH 4/4] examples/fips_validation: remove unneeded " Stephen Hemminger
2023-03-23  9:33 ` [PATCH 0/4] Remove unnecessary null free checks 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=20230323010428.64020-2-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=syalavarthi@marvell.com \
    /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).