From 708e8c9dea489b8c6113adc3ea03d16c993b1f0c Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 9 Apr 2020 13:55:05 -0400 Subject: [PATCH] Fix: sink.text.details: goto error when failing to add input port If bt_self_component_sink_add_input_port fails, the current code does not goto error. This patch fixes it. It also changes the switch, used to convert from `add_port_status` to `status`, to a cast, as is the practice throughout the project. Change-Id: I82b2719316ad00ffd9d9c14b86b8890b98130669 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/3383 Reviewed-by: Philippe Proulx (cherry picked from commit c7f21c12d5cec35f3e48630cf603207748409847) Reviewed-on: https://review.lttng.org/c/babeltrace/+/3362 CI-Build: Philippe Proulx Tested-by: jenkins --- src/plugins/text/details/details.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/plugins/text/details/details.c b/src/plugins/text/details/details.c index 4f304f73..95aabe1f 100644 --- a/src/plugins/text/details/details.c +++ b/src/plugins/text/details/details.c @@ -373,18 +373,9 @@ bt_component_class_initialize_method_status details_init( add_port_status = bt_self_component_sink_add_input_port(comp, IN_PORT_NAME, NULL, NULL); - switch (add_port_status) { - case BT_SELF_COMPONENT_ADD_PORT_STATUS_OK: - status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK; - break; - case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: - status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR; - break; - case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: - status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; - break; - default: - bt_common_abort(); + if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { + status = (int) add_port_status; + goto error; } details_comp = create_details_comp(comp); -- 2.34.1