[v3,8/8] pipeline: remove unnecessary checks for NULL pointer before free

Message ID 20220220182147.9750-9-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
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build fail github build: failed
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Stephen Hemminger Feb. 20, 2022, 6:21 p.m. UTC
  This library (mostly) uses convention that allows caller
to pass NULL.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/pipeline/rte_port_in_action.h | 6 ++++--
 lib/pipeline/rte_swx_ctl.c        | 3 +--
 lib/pipeline/rte_swx_ctl.h        | 1 +
 lib/pipeline/rte_swx_pipeline.c   | 6 ++----
 lib/pipeline/rte_swx_pipeline.h   | 1 +
 5 files changed, 9 insertions(+), 8 deletions(-)
  

Patch

diff --git a/lib/pipeline/rte_port_in_action.h b/lib/pipeline/rte_port_in_action.h
index d6b063cf58a7..9debb9269297 100644
--- a/lib/pipeline/rte_port_in_action.h
+++ b/lib/pipeline/rte_port_in_action.h
@@ -181,8 +181,9 @@  rte_port_in_action_profile_create(uint32_t socket_id);
  *
  * @param[in] profile
  *   Input port action profile handle (needs to be valid).
+ *   If NULL then, the function does nothing.
  * @return
- *   Zero on success, non-zero error code otherwise.
+ *   always zero.
  */
 __rte_experimental
 int
@@ -259,8 +260,9 @@  rte_port_in_action_create(struct rte_port_in_action_profile *profile,
  *
  * @param[in] action
  *   Handle to input port action object (needs to be valid).
+ *   If NULL then, the function does nothing.
  * @return
- *   Zero on success, non-zero error code otherwise.
+ *   Always zero.
  */
 __rte_experimental
 int
diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c
index f52ccffd75a4..710e89a46a26 100644
--- a/lib/pipeline/rte_swx_ctl.c
+++ b/lib/pipeline/rte_swx_ctl.c
@@ -1046,8 +1046,7 @@  table_state_free(struct rte_swx_ctl_pipeline *ctl)
 		struct rte_swx_table_state *ts = &ctl->ts_next[selector_base_index + i];
 
 		/* Table object. */
-		if (ts->obj)
-			rte_swx_table_selector_free(ts->obj);
+		rte_swx_table_selector_free(ts->obj);
 	}
 
 	/* For each learner table, free its table state. */
diff --git a/lib/pipeline/rte_swx_ctl.h b/lib/pipeline/rte_swx_ctl.h
index 82e62e70a7c3..501731d54724 100644
--- a/lib/pipeline/rte_swx_ctl.h
+++ b/lib/pipeline/rte_swx_ctl.h
@@ -1285,6 +1285,7 @@  rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p,
  *
  * @param[in] ctl
  *   Pipeline control handle.
+ *   If NULL then, the function does nothing.
  */
 __rte_experimental
 void
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index 868010303c73..0177a45c4486 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -8672,16 +8672,14 @@  table_state_build_free(struct rte_swx_pipeline *p)
 		struct rte_swx_table_state *ts = &p->table_state[p->n_tables + i];
 
 		/* ts->obj. */
-		if (ts->obj)
-			rte_swx_table_selector_free(ts->obj);
+		rte_swx_table_selector_free(ts->obj);
 	}
 
 	for (i = 0; i < p->n_learners; i++) {
 		struct rte_swx_table_state *ts = &p->table_state[p->n_tables + p->n_selectors + i];
 
 		/* ts->obj. */
-		if (ts->obj)
-			rte_swx_table_learner_free(ts->obj);
+		rte_swx_table_learner_free(ts->obj);
 
 		/* ts->default_action_data. */
 		free(ts->default_action_data);
diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h
index 77141bd3415b..51817159b154 100644
--- a/lib/pipeline/rte_swx_pipeline.h
+++ b/lib/pipeline/rte_swx_pipeline.h
@@ -912,6 +912,7 @@  rte_swx_pipeline_flush(struct rte_swx_pipeline *p);
  *
  * @param[in] p
  *   Pipeline handle.
+ *   If NULL then, the function does nothing.
  */
 __rte_experimental
 void