From 805e57b014d3763c86568a0b966f4d5093a53e03 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 17 May 2023 15:29:38 -0400 Subject: [PATCH] lib: de-duplicate "no error" assertion in add port functions Add BT_ASSERT_PRE_NO_ERROR_FROM_FUNC calls in bt_component_add_output_port and bt_component_add_input_port, and remove the equivalent calls in their callers. This moves the assertion check next to the other existing assertions. Change-Id: Ia251510ce2b6ba369cfc1f4afae50e8e46060957 Reviewed-on: https://review.lttng.org/c/babeltrace/+/10036 CI-Build: Simon Marchi Reviewed-by: Philippe Proulx Tested-by: jenkins --- src/lib/graph/component-filter.c | 4 ---- src/lib/graph/component-sink.c | 2 -- src/lib/graph/component-source.c | 2 -- src/lib/graph/component.c | 2 ++ 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/lib/graph/component-filter.c b/src/lib/graph/component-filter.c index ba940dea..79e57745 100644 --- a/src/lib/graph/component-filter.c +++ b/src/lib/graph/component-filter.c @@ -128,8 +128,6 @@ enum bt_self_component_add_port_status bt_self_component_filter_add_output_port( enum bt_self_component_add_port_status status; struct bt_port *port = NULL; - BT_ASSERT_PRE_NO_ERROR(); - /* * bt_component_add_output_port() logs details/errors and checks * preconditions. @@ -219,8 +217,6 @@ enum bt_self_component_add_port_status bt_self_component_filter_add_input_port( struct bt_port *port = NULL; struct bt_component *comp = (void *) self_comp; - BT_ASSERT_PRE_NO_ERROR(); - /* * bt_component_add_input_port() logs details/errors and checks * preconditions. diff --git a/src/lib/graph/component-sink.c b/src/lib/graph/component-sink.c index fb006f98..37eda35a 100644 --- a/src/lib/graph/component-sink.c +++ b/src/lib/graph/component-sink.c @@ -127,8 +127,6 @@ enum bt_self_component_add_port_status bt_self_component_sink_add_input_port( struct bt_port *port = NULL; struct bt_component *comp = (void *) self_comp; - BT_ASSERT_PRE_NO_ERROR(); - /* * bt_component_add_input_port() logs details/errors and checks * preconditions. diff --git a/src/lib/graph/component-source.c b/src/lib/graph/component-source.c index 1a8d7fce..83f1ef69 100644 --- a/src/lib/graph/component-source.c +++ b/src/lib/graph/component-source.c @@ -128,8 +128,6 @@ enum bt_self_component_add_port_status bt_self_component_source_add_output_port( enum bt_self_component_add_port_status status; struct bt_port *port = NULL; - BT_ASSERT_PRE_NO_ERROR(); - /* * bt_component_add_output_port() logs details/errors and checks * preconditions. diff --git a/src/lib/graph/component.c b/src/lib/graph/component.c index 85d6aae9..569a743e 100644 --- a/src/lib/graph/component.c +++ b/src/lib/graph/component.c @@ -475,6 +475,7 @@ enum bt_self_component_add_port_status bt_component_add_input_port( struct bt_component *component, const char *name, void *user_data, struct bt_port **port, const char *api_func) { + BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func); BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(api_func, component); BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name); BT_ASSERT_PRE_FROM_FUNC(api_func, "input-port-name-is-unique", @@ -492,6 +493,7 @@ enum bt_self_component_add_port_status bt_component_add_output_port( void *user_data, struct bt_port **port, const char *api_func) { + BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(api_func); BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(api_func, component); BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(api_func, name); BT_ASSERT_PRE_FROM_FUNC(api_func, "output-port-name-is-unique", -- 2.34.1