Fix: lib: expose bt_lib_log_level symbol
[babeltrace.git] / cli / babeltrace.c
index 791c6c8eba18190c6a670e634e2c735866fa25f9..913a74216c2d600d15a916e2ad3ae16d6059844d 100644 (file)
@@ -1452,8 +1452,11 @@ int cmd_print_ctf_metadata(struct bt_config *cfg)
        if (ret < 0) {
                BT_LOGE("Cannot write whole metadata text to output stream: "
                        "ret=%d", ret);
+               goto end;
        }
 
+       ret = 0;
+
        goto end;
 
 failed:
@@ -1998,11 +2001,13 @@ end:
 }
 
 static
-void graph_output_port_added_listener(struct cmd_run_ctx *ctx,
+bt_graph_listener_status
+graph_output_port_added_listener(struct cmd_run_ctx *ctx,
                const bt_port_output *out_port)
 {
        const bt_component *comp;
        const bt_port *port = bt_port_output_as_port_const(out_port);
+       bt_graph_listener_status ret = BT_GRAPH_LISTENER_STATUS_OK;
 
        comp = bt_port_borrow_component_const(port);
        BT_LOGI("Port added to a graph's component: comp-addr=%p, "
@@ -2027,27 +2032,28 @@ void graph_output_port_added_listener(struct cmd_run_ctx *ctx,
        if (cmd_run_ctx_connect_upstream_port(ctx, out_port)) {
                BT_LOGF_STR("Cannot connect upstream port.");
                fprintf(stderr, "Added port could not be connected: aborting\n");
-               abort();
+               ret = BT_GRAPH_LISTENER_STATUS_ERROR;
+               goto end;
        }
 
 end:
-       return;
+       return ret;
 }
 
 static
-void graph_source_output_port_added_listener(
+bt_graph_listener_status graph_source_output_port_added_listener(
                const bt_component_source *component,
                const bt_port_output *port, void *data)
 {
-       graph_output_port_added_listener(data, port);
+       return graph_output_port_added_listener(data, port);
 }
 
 static
-void graph_filter_output_port_added_listener(
+bt_graph_listener_status graph_filter_output_port_added_listener(
                const bt_component_filter *component,
                const bt_port_output *port, void *data)
 {
-       graph_output_port_added_listener(data, port);
+       return graph_output_port_added_listener(data, port);
 }
 
 static
@@ -2163,8 +2169,6 @@ int set_stream_intersections(struct cmd_run_ctx *ctx,
        const bt_value *intersection_range = NULL;
        const bt_value *intersection_begin = NULL;
        const bt_value *intersection_end = NULL;
-       const bt_value *stream_path_value = NULL;
-       const bt_value *stream_paths = NULL;
        const bt_value *stream_infos = NULL;
        const bt_value *stream_info = NULL;
        struct port_id *port_id = NULL;
@@ -2263,20 +2267,8 @@ int set_stream_intersections(struct cmd_run_ctx *ctx,
                        goto error;
                }
 
-               /*
-                * FIXME
-                *
-                * The first path of a stream's "paths" is currently used to
-                * associate streams/ports to a given trace intersection.
-                *
-                * This is a fragile hack as it relies on the port names
-                * being set to the various streams path.
-                *
-                * A stream name should be introduced as part of the trace-info
-                * query result.
-                */
                for (stream_idx = 0; stream_idx < stream_count; stream_idx++) {
-                       const char *stream_path;
+                       const bt_value *port_name;
 
                        port_id = g_new0(struct port_id, 1);
                        if (!port_id) {
@@ -2308,26 +2300,14 @@ int set_stream_intersections(struct cmd_run_ctx *ctx,
                                goto error;
                        }
 
-                       stream_paths = bt_value_map_borrow_entry_value_const(stream_info,
-                                                                            "paths");
-                       if (!stream_paths || !bt_value_is_array(stream_paths)) {
-                               ret = -1;
-                               BT_LOGD_STR("Cannot retrieve stream paths from trace in query result.");
-                               goto error;
-                       }
-
-                       stream_path_value =
-                               bt_value_array_borrow_element_by_index_const(
-                                       stream_paths, 0);
-                       if (!stream_path_value ||
-                               !bt_value_is_string(stream_path_value)) {
+                       port_name = bt_value_map_borrow_entry_value_const(stream_info, "port-name");
+                       if (!port_name || !bt_value_is_string(port_name)) {
                                ret = -1;
-                               BT_LOGD_STR("Cannot retrieve stream path value from trace in query result.");
+                               BT_LOGD_STR("Cannot retrieve port name in query result.");
                                goto error;
                        }
 
-                       stream_path = bt_value_string_get(stream_path_value);
-                       port_id->port_name = strdup(stream_path);
+                       port_id->port_name = g_strdup(bt_value_string_get(port_name));
                        if (!port_id->port_name) {
                                ret = -1;
                                BT_LOGE_STR("Cannot allocate memory for port_id port_name.");
This page took 0.024997 seconds and 4 git commands to generate.