[v3,8/8] pipeline: remove unnecessary checks for NULL pointer before free
Checks
Commit Message
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(-)
@@ -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
@@ -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. */
@@ -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
@@ -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);
@@ -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