From 147337a3be96c8ea69fee38099762370ecac8d51 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 7 Jun 2017 15:26:34 -0400 Subject: [PATCH] Make bt_private_component_*_add_*_port() return a status code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- .../graph/private-component-filter.h | 11 +-- .../babeltrace/graph/private-component-sink.h | 6 +- .../graph/private-component-source.h | 6 +- lib/graph/filter.c | 42 +++++++++-- lib/graph/sink.c | 21 +++++- lib/graph/source.c | 21 +++++- plugins/ctf/fs-sink/writer.c | 10 +-- plugins/ctf/fs-src/fs.c | 8 +-- plugins/ctf/lttng-live/lttng-live.c | 26 ++++--- plugins/lttng-utils/plugin.c | 17 ++--- plugins/text/pretty/pretty.c | 10 +-- plugins/utils/dummy/dummy.c | 9 +-- plugins/utils/muxer/muxer.c | 43 +++++------ plugins/utils/trimmer/trimmer.c | 15 ++-- tests/lib/test_bt_notification_iterator.c | 17 ++--- tests/lib/test_graph_topo.c | 27 ++++--- tests/plugins/test-utils-muxer.c | 71 ++++++++----------- 17 files changed, 192 insertions(+), 168 deletions(-) diff --git a/include/babeltrace/graph/private-component-filter.h b/include/babeltrace/graph/private-component-filter.h index ec19534e..3ebc0e9c 100644 --- a/include/babeltrace/graph/private-component-filter.h +++ b/include/babeltrace/graph/private-component-filter.h @@ -25,6 +25,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -42,10 +43,11 @@ extern struct bt_private_port * bt_private_component_filter_get_output_private_port_by_index( struct bt_private_component *private_component, uint64_t index); -extern struct bt_private_port * +extern enum bt_component_status bt_private_component_filter_add_output_private_port( struct bt_private_component *private_component, - const char *name, void *user_data); + const char *name, void *user_data, + struct bt_private_port **private_port); extern struct bt_private_port * bt_private_component_filter_get_input_private_port_by_name( @@ -56,10 +58,11 @@ extern struct bt_private_port * bt_private_component_filter_get_input_private_port_by_index( struct bt_private_component *private_component, uint64_t index); -extern struct bt_private_port * +extern enum bt_component_status bt_private_component_filter_add_input_private_port( struct bt_private_component *private_component, - const char *name, void *user_data); + const char *name, void *user_data, + struct bt_private_port **private_port); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/private-component-sink.h b/include/babeltrace/graph/private-component-sink.h index bf2473be..b122b5b9 100644 --- a/include/babeltrace/graph/private-component-sink.h +++ b/include/babeltrace/graph/private-component-sink.h @@ -25,6 +25,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -42,10 +43,11 @@ extern struct bt_private_port * bt_private_component_sink_get_input_private_port_by_index( struct bt_private_component *private_component, uint64_t index); -extern struct bt_private_port * +extern enum bt_component_status bt_private_component_sink_add_input_private_port( struct bt_private_component *private_component, - const char *name, void *user_data); + const char *name, void *user_data, + struct bt_private_port **private_port); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/private-component-source.h b/include/babeltrace/graph/private-component-source.h index f4e9269e..702a539f 100644 --- a/include/babeltrace/graph/private-component-source.h +++ b/include/babeltrace/graph/private-component-source.h @@ -25,6 +25,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -43,10 +44,11 @@ bt_private_component_source_get_output_private_port_by_index( struct bt_private_component *private_component, uint64_t index); -extern struct bt_private_port * +extern enum bt_component_status bt_private_component_source_add_output_private_port( struct bt_private_component *private_component, - const char *name, void *user_data); + const char *name, void *user_data, + struct bt_private_port **private_port); #ifdef __cplusplus } diff --git a/lib/graph/filter.c b/lib/graph/filter.c index 94355cf8..4e6db19f 100644 --- a/lib/graph/filter.c +++ b/lib/graph/filter.c @@ -242,16 +242,19 @@ bt_private_component_filter_get_input_private_port_by_name( bt_component_from_private(private_component), name)); } -struct bt_private_port *bt_private_component_filter_add_input_private_port( +enum bt_component_status bt_private_component_filter_add_input_private_port( struct bt_private_component *private_component, - const char *name, void *user_data) + const char *name, void *user_data, + struct bt_private_port **user_priv_port) { + enum bt_component_status status = BT_COMPONENT_STATUS_OK; struct bt_port *port = NULL; struct bt_component *component = bt_component_from_private(private_component); if (!component) { BT_LOGW_STR("Invalid parameter: component is NULL."); + status = BT_COMPONENT_STATUS_INVALID; goto end; } @@ -260,14 +263,26 @@ struct bt_private_port *bt_private_component_filter_add_input_private_port( "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s", component, bt_component_get_name(component), bt_component_class_type_string(component->class->type)); + status = BT_COMPONENT_STATUS_INVALID; goto end; } /* bt_component_add_input_port() logs details/errors */ port = bt_component_add_input_port(component, name, user_data); + if (!port) { + status = BT_COMPONENT_STATUS_NOMEM; + goto end; + } + + if (user_priv_port) { + /* Move reference to user */ + *user_priv_port = bt_private_port_from_port(port); + port = NULL; + } end: - return bt_private_port_from_port(port); + bt_put(port); + return status; } struct bt_private_port * @@ -291,16 +306,19 @@ bt_private_component_filter_get_output_private_port_by_name( bt_component_from_private(private_component), name)); } -struct bt_private_port *bt_private_component_filter_add_output_private_port( +enum bt_component_status bt_private_component_filter_add_output_private_port( struct bt_private_component *private_component, - const char *name, void *user_data) + const char *name, void *user_data, + struct bt_private_port **user_priv_port) { + enum bt_component_status status = BT_COMPONENT_STATUS_OK; struct bt_port *port = NULL; struct bt_component *component = bt_component_from_private(private_component); if (!component) { BT_LOGW_STR("Invalid parameter: component is NULL."); + status = BT_COMPONENT_STATUS_INVALID; goto end; } @@ -309,12 +327,24 @@ struct bt_private_port *bt_private_component_filter_add_output_private_port( "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s", component, bt_component_get_name(component), bt_component_class_type_string(component->class->type)); + status = BT_COMPONENT_STATUS_INVALID; goto end; } /* bt_component_add_output_port() logs details/errors */ port = bt_component_add_output_port(component, name, user_data); + if (!port) { + status = BT_COMPONENT_STATUS_NOMEM; + goto end; + } + + if (user_priv_port) { + /* Move reference to user */ + *user_priv_port = bt_private_port_from_port(port); + port = NULL; + } end: - return bt_private_port_from_port(port); + bt_put(port); + return status; } diff --git a/lib/graph/sink.c b/lib/graph/sink.c index 78dc97f9..b2088139 100644 --- a/lib/graph/sink.c +++ b/lib/graph/sink.c @@ -196,16 +196,19 @@ bt_private_component_sink_get_input_private_port_by_name( bt_component_from_private(private_component), name)); } -struct bt_private_port *bt_private_component_sink_add_input_private_port( +enum bt_component_status bt_private_component_sink_add_input_private_port( struct bt_private_component *private_component, - const char *name, void *user_data) + const char *name, void *user_data, + struct bt_private_port **user_priv_port) { + enum bt_component_status status = BT_COMPONENT_STATUS_OK; struct bt_port *port = NULL; struct bt_component *component = bt_component_from_private(private_component); if (!component) { BT_LOGW_STR("Invalid parameter: component is NULL."); + status = BT_COMPONENT_STATUS_INVALID; goto end; } @@ -214,12 +217,24 @@ struct bt_private_port *bt_private_component_sink_add_input_private_port( "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s", component, bt_component_get_name(component), bt_component_class_type_string(component->class->type)); + status = BT_COMPONENT_STATUS_INVALID; goto end; } /* bt_component_add_input_port() logs details/errors */ port = bt_component_add_input_port(component, name, user_data); + if (!port) { + status = BT_COMPONENT_STATUS_NOMEM; + goto end; + } + + if (user_priv_port) { + /* Move reference to user */ + *user_priv_port = bt_private_port_from_port(port); + port = NULL; + } end: - return bt_private_port_from_port(port); + bt_put(port); + return status; } diff --git a/lib/graph/source.c b/lib/graph/source.c index 09af6972..57244c06 100644 --- a/lib/graph/source.c +++ b/lib/graph/source.c @@ -161,16 +161,19 @@ bt_private_component_source_get_output_private_port_by_index( bt_component_from_private(private_component), index)); } -struct bt_private_port *bt_private_component_source_add_output_private_port( +enum bt_component_status bt_private_component_source_add_output_private_port( struct bt_private_component *private_component, - const char *name, void *user_data) + const char *name, void *user_data, + struct bt_private_port **user_priv_port) { + enum bt_component_status status = BT_COMPONENT_STATUS_OK; struct bt_port *port = NULL; struct bt_component *component = bt_component_from_private(private_component); if (!component) { BT_LOGW_STR("Invalid parameter: component is NULL."); + status = BT_COMPONENT_STATUS_INVALID; goto end; } @@ -179,12 +182,24 @@ struct bt_private_port *bt_private_component_source_add_output_private_port( "comp-addr=%p, comp-name=\"%s\", comp-class-type=%s", component, bt_component_get_name(component), bt_component_class_type_string(component->class->type)); + status = BT_COMPONENT_STATUS_INVALID; goto end; } /* bt_component_add_output_port() logs details and errors */ port = bt_component_add_output_port(component, name, user_data); + if (!port) { + status = BT_COMPONENT_STATUS_NOMEM; + goto end; + } + + if (user_priv_port) { + /* Move reference to user */ + *user_priv_port = bt_private_port_from_port(port); + port = NULL; + } end: - return bt_private_port_from_port(port); + bt_put(port); + return status; } diff --git a/plugins/ctf/fs-sink/writer.c b/plugins/ctf/fs-sink/writer.c index a2141363..1bc5966d 100644 --- a/plugins/ctf/fs-sink/writer.c +++ b/plugins/ctf/fs-sink/writer.c @@ -290,22 +290,18 @@ enum bt_component_status writer_component_init( struct writer_component *writer_component = create_writer_component(); struct bt_value *value = NULL; const char *path; - void *priv_port; if (!writer_component) { ret = BT_COMPONENT_STATUS_NOMEM; goto end; } - priv_port = bt_private_component_sink_add_input_private_port(component, - "in", NULL); - if (!priv_port) { - ret = BT_COMPONENT_STATUS_NOMEM; + ret = bt_private_component_sink_add_input_private_port(component, + "in", NULL, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - bt_put(priv_port); - value = bt_value_map_get(params, "path"); if (!value || bt_value_is_null(value) || !bt_value_is_string(value)) { fprintf(writer_component->err, diff --git a/plugins/ctf/fs-src/fs.c b/plugins/ctf/fs-src/fs.c index bcb33026..55321b2f 100644 --- a/plugins/ctf/fs-src/fs.c +++ b/plugins/ctf/fs-src/fs.c @@ -271,7 +271,6 @@ int create_one_port_for_trace(struct ctf_fs_trace *ctf_fs_trace, struct ctf_fs_ds_file_group *ds_file_group) { int ret = 0; - struct bt_private_port *port = NULL; struct ctf_fs_port_data *port_data = NULL; GString *port_name = NULL; struct ctf_fs_component *ctf_fs = ctf_fs_trace->ctf_fs; @@ -300,9 +299,9 @@ int create_one_port_for_trace(struct ctf_fs_trace *ctf_fs_trace, } port_data->ds_file_group = ds_file_group; - port = bt_private_component_source_add_output_private_port( - ctf_fs->priv_comp, port_name->str, port_data); - if (!port) { + ret = bt_private_component_source_add_output_private_port( + ctf_fs->priv_comp, port_name->str, port_data, NULL); + if (ret) { goto error; } @@ -318,7 +317,6 @@ end: g_string_free(port_name, TRUE); } - bt_put(port); port_data_destroy(port_data); return ret; } diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c index 4954a3c9..4831c81a 100644 --- a/plugins/ctf/lttng-live/lttng-live.c +++ b/plugins/ctf/lttng-live/lttng-live.c @@ -94,9 +94,10 @@ int lttng_live_add_port(struct lttng_live_component *lttng_live, ret = sprintf(name, STREAM_NAME_PREFIX "%" PRIu64, stream_iter->viewer_stream_id); assert(ret > 0); strcpy(stream_iter->name, name); - private_port = bt_private_component_source_add_output_private_port( - lttng_live->private_component, name, stream_iter); - if (!private_port) { + ret = bt_private_component_source_add_output_private_port( + lttng_live->private_component, name, stream_iter, + &private_port); + if (ret) { return -1; } BT_LOGI("Added port %s", name); @@ -129,10 +130,10 @@ int lttng_live_remove_port(struct lttng_live_component *lttng_live, BT_PUT(component); if (nr_ports == 1) { assert(!lttng_live->no_stream_port); - lttng_live->no_stream_port = - bt_private_component_source_add_output_private_port(lttng_live->private_component, - "no-stream", lttng_live->no_stream_iter); - if (!lttng_live->no_stream_port) { + ret = bt_private_component_source_add_output_private_port(lttng_live->private_component, + "no-stream", lttng_live->no_stream_iter, + <tng_live->no_stream_port); + if (ret) { return -1; } lttng_live->no_stream_iter->port = lttng_live->no_stream_port; @@ -1069,11 +1070,14 @@ enum bt_component_status lttng_live_component_init( lttng_live->no_stream_iter = g_new0(struct lttng_live_no_stream_iterator, 1); lttng_live->no_stream_iter->p.type = LIVE_STREAM_TYPE_NO_STREAM; lttng_live->no_stream_iter->lttng_live = lttng_live; - - lttng_live->no_stream_port = - bt_private_component_source_add_output_private_port( + ret = bt_private_component_source_add_output_private_port( lttng_live->private_component, "no-stream", - lttng_live->no_stream_iter); + lttng_live->no_stream_iter, + <tng_live->no_stream_port); + if (ret != BT_COMPONENT_STATUS_OK) { + goto end; + } + lttng_live->no_stream_iter->port = lttng_live->no_stream_port; ret = bt_private_component_set_user_data(private_component, lttng_live); diff --git a/plugins/lttng-utils/plugin.c b/plugins/lttng-utils/plugin.c index d5575599..fb00dee3 100644 --- a/plugins/lttng-utils/plugin.c +++ b/plugins/lttng-utils/plugin.c @@ -440,7 +440,6 @@ enum bt_component_status debug_info_component_init( { enum bt_component_status ret; struct debug_info_component *debug_info = create_debug_info_component_data(); - struct bt_private_port *priv_port = NULL; if (!debug_info) { ret = BT_COMPONENT_STATUS_NOMEM; @@ -452,21 +451,17 @@ enum bt_component_status debug_info_component_init( goto error; } - priv_port = bt_private_component_filter_add_input_private_port( - component, "in", NULL); - if (!priv_port) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = bt_private_component_filter_add_input_private_port( + component, "in", NULL, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - BT_PUT(priv_port); - priv_port = bt_private_component_filter_add_output_private_port( - component, "out", NULL); - if (!priv_port) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = bt_private_component_filter_add_output_private_port( + component, "out", NULL, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - BT_PUT(priv_port); ret = init_from_params(debug_info, params); end: diff --git a/plugins/text/pretty/pretty.c b/plugins/text/pretty/pretty.c index 9c994095..3d470867 100644 --- a/plugins/text/pretty/pretty.c +++ b/plugins/text/pretty/pretty.c @@ -734,22 +734,18 @@ enum bt_component_status pretty_init( { enum bt_component_status ret; struct pretty_component *pretty = create_pretty(); - void *priv_port; if (!pretty) { ret = BT_COMPONENT_STATUS_NOMEM; goto end; } - priv_port = bt_private_component_sink_add_input_private_port(component, - "in", NULL); - if (!priv_port) { - ret = BT_COMPONENT_STATUS_NOMEM; + ret = bt_private_component_sink_add_input_private_port(component, + "in", NULL, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - bt_put(priv_port); - pretty->out = stdout; pretty->err = stderr; diff --git a/plugins/utils/dummy/dummy.c b/plugins/utils/dummy/dummy.c index 5f7c62d6..df2ddff9 100644 --- a/plugins/utils/dummy/dummy.c +++ b/plugins/utils/dummy/dummy.c @@ -59,21 +59,18 @@ enum bt_component_status dummy_init(struct bt_private_component *component, { enum bt_component_status ret; struct dummy *dummy = g_new0(struct dummy, 1); - void *priv_port; if (!dummy) { ret = BT_COMPONENT_STATUS_NOMEM; goto end; } - priv_port = bt_private_component_sink_add_input_private_port(component, - "in", NULL); - if (!priv_port) { - ret = BT_COMPONENT_STATUS_NOMEM; + ret = bt_private_component_sink_add_input_private_port(component, + "in", NULL, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - bt_put(priv_port); dummy->iterators = g_ptr_array_new_with_free_func( (GDestroyNotify) bt_put); if (!dummy->iterators) { diff --git a/plugins/utils/muxer/muxer.c b/plugins/utils/muxer/muxer.c index 04f8c535..30864edb 100644 --- a/plugins/utils/muxer/muxer.c +++ b/plugins/utils/muxer/muxer.c @@ -140,13 +140,13 @@ end: } static -int ensure_available_input_port(struct bt_private_component *priv_comp) +enum bt_component_status ensure_available_input_port( + struct bt_private_component *priv_comp) { struct muxer_comp *muxer_comp = bt_private_component_get_user_data(priv_comp); - int ret = 0; + enum bt_component_status status = BT_COMPONENT_STATUS_OK; GString *port_name = NULL; - void *priv_port = NULL; assert(muxer_comp); @@ -156,15 +156,14 @@ int ensure_available_input_port(struct bt_private_component *priv_comp) port_name = g_string_new("in"); if (!port_name) { - ret = -1; + status = BT_COMPONENT_STATUS_NOMEM; goto end; } g_string_append_printf(port_name, "%u", muxer_comp->next_port_num); - priv_port = bt_private_component_filter_add_input_private_port( - priv_comp, port_name->str, NULL); - if (!priv_port) { - ret = -1; + status = bt_private_component_filter_add_input_private_port( + priv_comp, port_name->str, NULL, NULL); + if (status != BT_COMPONENT_STATUS_OK) { goto end; } @@ -176,24 +175,15 @@ end: g_string_free(port_name, TRUE); } - bt_put(priv_port); - return ret; + return status; } static -int create_output_port(struct bt_private_component *priv_comp) +enum bt_component_status create_output_port( + struct bt_private_component *priv_comp) { - void *priv_port; - int ret = 0; - - priv_port = bt_private_component_filter_add_output_private_port( - priv_comp, "out", NULL); - if (!priv_port) { - ret = -1; - } - - bt_put(priv_port); - return ret; + return bt_private_component_filter_add_output_private_port( + priv_comp, "out", NULL, NULL); } static @@ -305,8 +295,8 @@ enum bt_component_status muxer_init( muxer_comp->priv_comp = priv_comp; ret = bt_private_component_set_user_data(priv_comp, muxer_comp); assert(ret == 0); - ret = ensure_available_input_port(priv_comp); - if (ret) { + status = ensure_available_input_port(priv_comp); + if (status != BT_COMPONENT_STATUS_OK) { goto error; } @@ -321,7 +311,10 @@ error: destroy_muxer_comp(muxer_comp); ret = bt_private_component_set_user_data(priv_comp, NULL); assert(ret == 0); - status = BT_COMPONENT_STATUS_ERROR; + + if (status == BT_COMPONENT_STATUS_OK) { + status = BT_COMPONENT_STATUS_ERROR; + } end: return status; diff --git a/plugins/utils/trimmer/trimmer.c b/plugins/utils/trimmer/trimmer.c index 58684d05..2a8bd5e0 100644 --- a/plugins/utils/trimmer/trimmer.c +++ b/plugins/utils/trimmer/trimmer.c @@ -359,7 +359,6 @@ enum bt_component_status trimmer_component_init( { enum bt_component_status ret; struct trimmer *trimmer = create_trimmer_data(); - struct bt_private_port *priv_port = NULL; if (!trimmer) { ret = BT_COMPONENT_STATUS_NOMEM; @@ -367,16 +366,15 @@ enum bt_component_status trimmer_component_init( } /* Create input and output ports */ - priv_port = bt_private_component_filter_add_input_private_port( - component, "in", NULL); - if (!priv_port) { + ret = bt_private_component_filter_add_input_private_port( + component, "in", NULL, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { goto error; } - bt_put(priv_port); - priv_port = bt_private_component_filter_add_output_private_port( - component, "out", NULL); - if (!priv_port) { + ret = bt_private_component_filter_add_output_private_port( + component, "out", NULL, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { goto error; } @@ -387,7 +385,6 @@ enum bt_component_status trimmer_component_init( ret = init_from_params(trimmer, params); end: - bt_put(priv_port); return ret; error: destroy_trimmer_data(trimmer); diff --git a/tests/lib/test_bt_notification_iterator.c b/tests/lib/test_bt_notification_iterator.c index cace4019..8dff7d0e 100644 --- a/tests/lib/test_bt_notification_iterator.c +++ b/tests/lib/test_bt_notification_iterator.c @@ -700,12 +700,11 @@ enum bt_component_status src_init( struct bt_private_component *private_component, struct bt_value *params, void *init_method_data) { - void *priv_port; + int ret; - priv_port = bt_private_component_source_add_output_private_port( - private_component, "out", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_source_add_output_private_port( + private_component, "out", NULL, NULL); + assert(ret == 0); return BT_COMPONENT_STATUS_OK; } @@ -842,16 +841,14 @@ enum bt_component_status sink_init( { struct sink_user_data *user_data = g_new0(struct sink_user_data, 1); int ret; - void *priv_port; assert(user_data); ret = bt_private_component_set_user_data(private_component, user_data); assert(ret == 0); - priv_port = bt_private_component_sink_add_input_private_port( - private_component, "in", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_sink_add_input_private_port( + private_component, "in", NULL, NULL); + assert(ret == 0); return BT_COMPONENT_STATUS_OK; } diff --git a/tests/lib/test_graph_topo.c b/tests/lib/test_graph_topo.c index 6b1976d1..058393a2 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -320,7 +320,7 @@ void src_port_connected(struct bt_private_component *private_component, struct bt_private_port *self_private_port, struct bt_port *other_port) { - struct bt_private_port *port; + int ret; struct event event = { .type = COMP_PORT_CONNECTED, @@ -337,10 +337,9 @@ void src_port_connected(struct bt_private_component *private_component, switch (current_test) { case TEST_SRC_ADDS_PORT_IN_PORT_CONNECTED: - port = bt_private_component_source_add_output_private_port( - private_component, "hello", NULL); - assert(port); - bt_put(port); + ret = bt_private_component_source_add_output_private_port( + private_component, "hello", NULL, NULL); + assert(ret == 0); break; default: break; @@ -377,12 +376,11 @@ static enum bt_component_status src_init(struct bt_private_component *priv_comp, struct bt_value *params, void *init_method_data) { - void *priv_port; + int ret; - priv_port = bt_private_component_source_add_output_private_port( - priv_comp, "out", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_source_add_output_private_port( + priv_comp, "out", NULL, NULL); + assert(ret == 0); return BT_COMPONENT_STATUS_OK; } @@ -450,12 +448,11 @@ static enum bt_component_status sink_init(struct bt_private_component *priv_comp, struct bt_value *params, void *init_method_data) { - void *priv_port; + int ret; - priv_port = bt_private_component_sink_add_input_private_port(priv_comp, - "in", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_sink_add_input_private_port(priv_comp, + "in", NULL, NULL); + assert(ret == 0); return BT_COMPONENT_STATUS_OK; } diff --git a/tests/plugins/test-utils-muxer.c b/tests/plugins/test-utils-muxer.c index e9d2dca0..0045b0bf 100644 --- a/tests/plugins/test-utils-muxer.c +++ b/tests/plugins/test-utils-muxer.c @@ -599,6 +599,7 @@ struct bt_notification_iterator_next_return src_iter_next( bt_private_notification_iterator_get_user_data(priv_iterator); struct bt_private_component *private_component = bt_private_notification_iterator_get_private_component(priv_iterator); + int ret; assert(user_data); assert(private_component); @@ -637,16 +638,12 @@ struct bt_notification_iterator_next_return src_iter_next( break; case TEST_SINGLE_END_THEN_MULTIPLE_FULL: if (user_data->iter_index == 0) { - struct bt_private_port *priv_port; - - priv_port = bt_private_component_source_add_output_private_port( - private_component, "out1", NULL); - assert(priv_port); - bt_put(priv_port); - priv_port = bt_private_component_source_add_output_private_port( - private_component, "out2", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_source_add_output_private_port( + private_component, "out1", NULL, NULL); + assert(ret == 0); + ret = bt_private_component_source_add_output_private_port( + private_component, "out2", NULL, NULL); + assert(ret == 0); next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_END; } else { next_return = src_iter_next_seq(user_data); @@ -658,16 +655,12 @@ struct bt_notification_iterator_next_return src_iter_next( next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN; user_data->at++; } else { - struct bt_private_port *priv_port; - - priv_port = bt_private_component_source_add_output_private_port( - private_component, "out1", NULL); - assert(priv_port); - bt_put(priv_port); - priv_port = bt_private_component_source_add_output_private_port( - private_component, "out2", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_source_add_output_private_port( + private_component, "out1", NULL, NULL); + assert(ret == 0); + ret = bt_private_component_source_add_output_private_port( + private_component, "out2", NULL, NULL); + assert(ret == 0); next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_END; } } else { @@ -687,7 +680,7 @@ enum bt_component_status src_init( struct bt_private_component *private_component, struct bt_value *params, void *init_method_data) { - struct bt_private_port *priv_port; + int ret; size_t nb_ports; switch (current_test) { @@ -704,31 +697,27 @@ enum bt_component_status src_init( } if (nb_ports >= 1) { - priv_port = bt_private_component_source_add_output_private_port( - private_component, "out0", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_source_add_output_private_port( + private_component, "out0", NULL, NULL); + assert(ret == 0); } if (nb_ports >= 2) { - priv_port = bt_private_component_source_add_output_private_port( - private_component, "out1", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_source_add_output_private_port( + private_component, "out1", NULL, NULL); + assert(ret == 0); } if (nb_ports >= 3) { - priv_port = bt_private_component_source_add_output_private_port( - private_component, "out2", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_source_add_output_private_port( + private_component, "out2", NULL, NULL); + assert(ret == 0); } if (nb_ports >= 4) { - priv_port = bt_private_component_source_add_output_private_port( - private_component, "out3", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_source_add_output_private_port( + private_component, "out3", NULL, NULL); + assert(ret == 0); } return BT_COMPONENT_STATUS_OK; @@ -899,16 +888,14 @@ enum bt_component_status sink_init( { struct sink_user_data *user_data = g_new0(struct sink_user_data, 1); int ret; - void *priv_port; assert(user_data); ret = bt_private_component_set_user_data(private_component, user_data); assert(ret == 0); - priv_port = bt_private_component_sink_add_input_private_port( - private_component, "in", NULL); - assert(priv_port); - bt_put(priv_port); + ret = bt_private_component_sink_add_input_private_port( + private_component, "in", NULL, NULL); + assert(ret == 0); return BT_COMPONENT_STATUS_OK; } -- 2.34.1