X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fgraph%2Fgraph.c;h=22c4f92f8ec33314cd7f74cec71a5adb0781e3b8;hb=17f3083a0b4d318d3303c8a5bfa63db6a874ec73;hp=ed66ba89ef5c2c13d1629c6421aa16ef5db80fa5;hpb=9669d69306665dc42352cf22b65d76cbf517ee11;p=babeltrace.git diff --git a/src/lib/graph/graph.c b/src/lib/graph/graph.c index ed66ba89..22c4f92f 100644 --- a/src/lib/graph/graph.c +++ b/src/lib/graph/graph.c @@ -40,6 +40,7 @@ #include #include "lib/value.h" #include +#include #include #include "component-class-sink-simple.h" @@ -267,6 +268,7 @@ struct bt_graph *bt_graph_create(uint64_t mip_version) struct bt_graph *graph; int ret; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE(mip_version <= bt_get_maximal_mip_version(), "Unknown MIP version: mip-version=%" PRIu64 ", " "max-mip-version=%" PRIu64, @@ -431,6 +433,7 @@ enum bt_graph_connect_ports_status bt_graph_connect_ports( enum bt_component_class_port_connected_method_status port_connected_status; bool init_can_consume; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(upstream_port, "Upstream port"); BT_ASSERT_PRE_NON_NULL(downstream_port, "Downstream port port"); @@ -587,6 +590,7 @@ int consume_graph_sink(struct bt_component_sink *comp) consume_status == BT_FUNC_STATUS_MEMORY_ERROR, "Invalid component status returned by consuming method: " "status=%s", bt_common_func_status_string(consume_status)); + BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(consume_status); if (consume_status) { if (consume_status < 0) { BT_LIB_LOGW_APPEND_CAUSE( @@ -702,6 +706,7 @@ enum bt_graph_run_once_status bt_graph_run_once(struct bt_graph *graph) { enum bt_graph_run_once_status status; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_DEV(graph->can_consume, "Cannot consume graph in its current state: %!+g", graph); @@ -726,6 +731,7 @@ enum bt_graph_run_status bt_graph_run(struct bt_graph *graph) { enum bt_graph_run_status status; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE(graph->can_consume, "Cannot consume graph in its current state: %!+g", graph); @@ -807,6 +813,7 @@ bt_graph_add_source_component_output_port_added_listener( }; bt_listener_id listener_id; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener"); @@ -842,6 +849,7 @@ bt_graph_add_filter_component_output_port_added_listener( }; bt_listener_id listener_id; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener"); @@ -877,6 +885,7 @@ bt_graph_add_filter_component_input_port_added_listener( }; bt_listener_id listener_id; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener"); @@ -912,6 +921,7 @@ bt_graph_add_sink_component_input_port_added_listener( }; bt_listener_id listener_id; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener"); @@ -947,6 +957,7 @@ bt_graph_add_source_filter_component_ports_connected_listener( }; bt_listener_id listener_id; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener"); @@ -983,6 +994,7 @@ bt_graph_add_source_sink_component_ports_connected_listener( }; bt_listener_id listener_id; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener"); @@ -1019,6 +1031,7 @@ bt_graph_add_filter_filter_component_ports_connected_listener( }; bt_listener_id listener_id; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener"); @@ -1055,6 +1068,7 @@ bt_graph_add_filter_sink_component_ports_connected_listener( }; bt_listener_id listener_id; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener"); @@ -1099,7 +1113,7 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added( listeners = graph->listeners.source_output_port_added; break; default: - abort(); + bt_common_abort(); } break; @@ -1114,7 +1128,7 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added( listeners = graph->listeners.filter_output_port_added; break; default: - abort(); + bt_common_abort(); } break; @@ -1126,13 +1140,13 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added( listeners = graph->listeners.sink_input_port_added; break; default: - abort(); + bt_common_abort(); } break; } default: - abort(); + bt_common_abort(); } for (i = 0; i < listeners->len; i++) { @@ -1143,6 +1157,7 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added( BT_ASSERT(listener->func); status = listener->func(comp, port, listener->base.data); + BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status); if (status != BT_FUNC_STATUS_OK) { goto end; } @@ -1187,7 +1202,7 @@ enum bt_graph_listener_func_status bt_graph_notify_ports_connected( graph->listeners.source_sink_ports_connected; break; default: - abort(); + bt_common_abort(); } break; @@ -1204,13 +1219,13 @@ enum bt_graph_listener_func_status bt_graph_notify_ports_connected( graph->listeners.filter_sink_ports_connected; break; default: - abort(); + bt_common_abort(); } break; } default: - abort(); + bt_common_abort(); } for (i = 0; i < listeners->len; i++) { @@ -1221,6 +1236,7 @@ enum bt_graph_listener_func_status bt_graph_notify_ports_connected( BT_ASSERT(listener->func); status = listener->func(upstream_comp, downstream_comp, upstream_port, downstream_port, listener->base.data); + BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(status); if (status != BT_FUNC_STATUS_OK) { goto end; } @@ -1337,6 +1353,7 @@ int add_component_with_init_method_data( init_status = init_method(component, NULL, params, init_method_data); BT_LOGD("User method returned: status=%s", bt_common_func_status_string(init_status)); + BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(init_status); if (init_status != BT_FUNC_STATUS_OK) { if (init_status < 0) { BT_LIB_LOGW_APPEND_CAUSE( @@ -1408,6 +1425,7 @@ bt_graph_add_source_component_with_initialize_method_data( void *init_method_data, bt_logging_level log_level, const struct bt_component_source **component) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); return add_component_with_init_method_data(graph, (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init, @@ -1421,6 +1439,7 @@ enum bt_graph_add_component_status bt_graph_add_source_component( enum bt_logging_level log_level, const struct bt_component_source **component) { + BT_ASSERT_PRE_NO_ERROR(); return bt_graph_add_source_component_with_initialize_method_data( graph, comp_cls, name, params, NULL, log_level, component); } @@ -1433,6 +1452,7 @@ bt_graph_add_filter_component_with_initialize_method_data( void *init_method_data, enum bt_logging_level log_level, const struct bt_component_filter **component) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); return add_component_with_init_method_data(graph, (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init, @@ -1446,6 +1466,7 @@ enum bt_graph_add_component_status bt_graph_add_filter_component( enum bt_logging_level log_level, const struct bt_component_filter **component) { + BT_ASSERT_PRE_NO_ERROR(); return bt_graph_add_filter_component_with_initialize_method_data( graph, comp_cls, name, params, NULL, log_level, component); } @@ -1458,6 +1479,7 @@ bt_graph_add_sink_component_with_initialize_method_data( void *init_method_data, enum bt_logging_level log_level, const struct bt_component_sink **component) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); return add_component_with_init_method_data(graph, (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init, @@ -1471,6 +1493,7 @@ enum bt_graph_add_component_status bt_graph_add_sink_component( enum bt_logging_level log_level, const struct bt_component_sink **component) { + BT_ASSERT_PRE_NO_ERROR(); return bt_graph_add_sink_component_with_initialize_method_data( graph, comp_cls, name, params, NULL, log_level, component); } @@ -1491,6 +1514,8 @@ bt_graph_add_simple_sink_component(struct bt_graph *graph, const char *name, .user_data = user_data, }; + BT_ASSERT_PRE_NO_ERROR(); + /* * Other preconditions are checked by * bt_graph_add_sink_component_with_init_method_data(). @@ -1541,6 +1566,7 @@ bool bt_graph_is_interrupted(const struct bt_graph *graph) enum bt_graph_add_interrupter_status bt_graph_add_interrupter( struct bt_graph *graph, const struct bt_interrupter *intr) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(intr, "Interrupter"); g_ptr_array_add(graph->interrupters, (void *) intr);