[v3,3/8] lpm: remove unnecessary NULL checks

Message ID 20220220182147.9750-4-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series yet more unnecessary NULL checks |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Feb. 20, 2022, 6:21 p.m. UTC
  The functions rte_lpm_free() and rte_lpm6_free() already
handle NULL pointer case.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_func_reentrancy.c | 3 +--
 lib/lpm/rte_lpm.h               | 1 +
 lib/lpm/rte_lpm6.h              | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)
  

Comments

Ruifeng Wang Feb. 21, 2022, 2:47 a.m. UTC | #1
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, February 21, 2022 2:22 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Bruce
> Richardson <bruce.richardson@intel.com>; Vladimir Medvedkin
> <vladimir.medvedkin@intel.com>; Yipeng Wang <yipeng1.wang@intel.com>;
> Sameh Gobriel <sameh.gobriel@intel.com>; Anatoly Burakov
> <anatoly.burakov@intel.com>; Olivier Matz <olivier.matz@6wind.com>;
> Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>; Honnappa
> Nagarahalli <Honnappa.Nagarahalli@arm.com>; Konstantin Ananyev
> <konstantin.ananyev@intel.com>
> Subject: [PATCH v3 3/8] lpm: remove unnecessary NULL checks
> 
> The functions rte_lpm_free() and rte_lpm6_free() already handle NULL
> pointer case.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  app/test/test_func_reentrancy.c | 3 +--
>  lib/lpm/rte_lpm.h               | 1 +
>  lib/lpm/rte_lpm6.h              | 1 +
>  3 files changed, 3 insertions(+), 2 deletions(-)
> 
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
  
Vladimir Medvedkin Feb. 21, 2022, 3:51 p.m. UTC | #2
On 20/02/2022 18:21, Stephen Hemminger wrote:
> The functions rte_lpm_free() and rte_lpm6_free() already
> handle NULL pointer case.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   app/test/test_func_reentrancy.c | 3 +--
>   lib/lpm/rte_lpm.h               | 1 +
>   lib/lpm/rte_lpm6.h              | 1 +
>   3 files changed, 3 insertions(+), 2 deletions(-)
> 

Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
  

Patch

diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c
index da00694daafd..67e69ad53588 100644
--- a/app/test/test_func_reentrancy.c
+++ b/app/test/test_func_reentrancy.c
@@ -348,8 +348,7 @@  lpm_clean(unsigned int lcore_id)
 	int i;
 
 	lpm = rte_lpm_find_existing("fr_test_once");
-	if (lpm != NULL)
-		rte_lpm_free(lpm);
+	rte_lpm_free(lpm);
 
 	for (i = 0; i < MAX_LPM_ITER_TIMES; i++) {
 		snprintf(lpm_name, sizeof(lpm_name), "fr_test_%d_%d",  lcore_id, i);
diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h
index 5eb14c1748e5..a50bf3339fee 100644
--- a/lib/lpm/rte_lpm.h
+++ b/lib/lpm/rte_lpm.h
@@ -183,6 +183,7 @@  rte_lpm_find_existing(const char *name);
  *
  * @param lpm
  *   LPM object handle
+ *   If NULL then, the function does nothing.
  * @return
  *   None
  */
diff --git a/lib/lpm/rte_lpm6.h b/lib/lpm/rte_lpm6.h
index f96f3372e593..145fd4495a94 100644
--- a/lib/lpm/rte_lpm6.h
+++ b/lib/lpm/rte_lpm6.h
@@ -73,6 +73,7 @@  rte_lpm6_find_existing(const char *name);
  *
  * @param lpm
  *   LPM object handle
+ *   If NULL then, the function does nothing.
  * @return
  *   None
  */