Make bt_private_component_*_add_*_port() return a status code
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 7 Jun 2017 19:26:34 +0000 (15:26 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 21:03:27 +0000 (17:03 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
17 files changed:
include/babeltrace/graph/private-component-filter.h
include/babeltrace/graph/private-component-sink.h
include/babeltrace/graph/private-component-source.h
lib/graph/filter.c
lib/graph/sink.c
lib/graph/source.c
plugins/ctf/fs-sink/writer.c
plugins/ctf/fs-src/fs.c
plugins/ctf/lttng-live/lttng-live.c
plugins/lttng-utils/plugin.c
plugins/text/pretty/pretty.c
plugins/utils/dummy/dummy.c
plugins/utils/muxer/muxer.c
plugins/utils/trimmer/trimmer.c
tests/lib/test_bt_notification_iterator.c
tests/lib/test_graph_topo.c
tests/plugins/test-utils-muxer.c

index ec19534e3718810a23444430d9f18fcc97a32912..3ebc0e9c671adbf19cb189d8d3aedd4abfc2add6 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <stdint.h>
 #include <babeltrace/graph/component.h>
+#include <babeltrace/graph/component-status.h>
 
 #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
 }
index bf2473beac5e80f9724b704076854a08ea66828b..b122b5b931ac869a056880cabaaa30861ee5efbf 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <stdint.h>
 #include <babeltrace/graph/component.h>
+#include <babeltrace/graph/component-status.h>
 
 #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
 }
index f4e9269e78a485008b425b95fa50a89a3fab2e18..702a539fc17b26d903c81d57263bed2b2c205059 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <stdint.h>
 #include <babeltrace/graph/component.h>
+#include <babeltrace/graph/component-status.h>
 
 #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
 }
index 94355cf81fcf4b9a680e16f9256bf3a736cf97fb..4e6db19fd5d59508f9182443a10b7cfe01b2affe 100644 (file)
@@ -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;
 }
index 78dc97f93fc542f778b6c5111ab7037612a00d02..b2088139f080bfe7bccb89ea43666bcd8dedac5c 100644 (file)
@@ -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;
 }
index 09af697232cb0d0ee3803175f835e578618e595b..57244c062584e14d978c40640ae79a015e23300a 100644 (file)
@@ -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;
 }
index a21413635de990c7ebe9e2fc4ef63da7309639e1..1bc5966deac4e4fbca37cea34d926a0078553f80 100644 (file)
@@ -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,
index bcb3302657c71c3206652e35d5840a502d84ed3f..55321b2fd4785d8b94f0617ad0a4e577c090c412 100644 (file)
@@ -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;
 }
index 4954a3c93033528825157c84a8def4929de515a5..4831c81af77d142b9b78cfc01b577bd5f3d8a048 100644 (file)
@@ -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,
+                               &lttng_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,
+                               &lttng_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);
index d55755992222d15bdd24364033af9f831f795443..fb00dee315b64ee4c650fa6357a7233fd3cb2c11 100644 (file)
@@ -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:
index 9c994095871e556d149edf0fef49bdbe50482b00..3d4708672049e2d833a8066a6b9182ce7da00771 100644 (file)
@@ -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;
 
index 5f7c62d64b56dbe4b145fab37b88ec6ca6dfee52..df2ddff9345408df2aca16fb676b8ef9d942a41f 100644 (file)
@@ -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) {
index 04f8c535645066e25d07ffeb28cba8f8dc71c57f..30864edb4ceffbb3aba1dc4dc2ad7d927d6de326 100644 (file)
@@ -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;
index 58684d05617750fd30a5b445c81756ae90eec7b7..2a8bd5e0b83c5fb4ae8d21977134a4cd432c536e 100644 (file)
@@ -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);
index cace4019c035d9e21bfd00847081bf3cedd3e910..8dff7d0edbf9212313191002395a017b42404fd9 100644 (file)
@@ -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;
 }
 
index 6b1976d16e2e2ca6a33ec6469e71128e1b97e74d..058393a2b091503afc8fac29826b26dc46d8a105 100644 (file)
@@ -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;
 }
 
index e9d2dca0a27a1caeff627fb6994a06653665be5e..0045b0bf3d3998c329ec1e8f98f2607b3a7be7f2 100644 (file)
@@ -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;
 }
 
This page took 0.038747 seconds and 4 git commands to generate.