diff --git a/src/lib/assert-pre.h b/src/lib/assert-pre.h index 03d86de36..138977558 100644 --- a/src/lib/assert-pre.h +++ b/src/lib/assert-pre.h @@ -116,6 +116,20 @@ "Index is out of bounds: index=%" PRIu64 ", " \ "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length)) +/* + * Asserts that the current thread has no error set. + */ +#define BT_ASSERT_PRE_NO_ERROR() \ + do { \ + const struct bt_error *err = bt_current_thread_take_error(); \ + if (err) { \ + bt_current_thread_move_error(err); \ + } \ + BT_ASSERT_PRE(!err, \ + "API function called while current thread has an " \ + "error: function=%s", __func__); \ + } while (0) + #ifdef BT_DEV_MODE /* Developer mode version of BT_ASSERT_PRE_MSG(). */ # define BT_ASSERT_PRE_DEV_MSG(_fmt, ...) \ @@ -146,6 +160,10 @@ # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ BT_ASSERT_PRE_VALID_INDEX((_index), (_length)) +/* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */ +# define BT_ASSERT_PRE_DEV_NO_ERROR() \ + BT_ASSERT_PRE_NO_ERROR() + /* * Marks a function as being only used within a BT_ASSERT_PRE_DEV() * context. @@ -160,6 +178,7 @@ ((void) sizeof((void) (_obj), (void) (_obj_name), 0)) # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ ((void) sizeof((void) (_index), (void) (_length), 0)) +# define BT_ASSERT_PRE_DEV_NO_ERROR() # define BT_ASSERT_PRE_DEV_FUNC __attribute__((unused)) #endif /* BT_DEV_MODE */ diff --git a/src/lib/graph/component-class-sink-simple.c b/src/lib/graph/component-class-sink-simple.c index b347280f7..21fb0b799 100644 --- a/src/lib/graph/component-class-sink-simple.c +++ b/src/lib/graph/component-class-sink-simple.c @@ -192,6 +192,8 @@ struct bt_component_class_sink *bt_component_class_sink_simple_borrow(void) { enum bt_component_class_set_method_status set_method_status; + BT_ASSERT_PRE_NO_ERROR(); + if (simple_comp_cls) { goto end; } diff --git a/src/lib/graph/component-class.c b/src/lib/graph/component-class.c index 9bbf4172e..5f01158a2 100644 --- a/src/lib/graph/component-class.c +++ b/src/lib/graph/component-class.c @@ -152,6 +152,7 @@ struct bt_component_class_source *bt_component_class_source_create( struct bt_component_class_source *source_class = NULL; int ret; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method"); BT_LOGI("Creating source component class: " @@ -191,6 +192,7 @@ struct bt_component_class_filter *bt_component_class_filter_create( struct bt_component_class_filter *filter_class = NULL; int ret; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method"); BT_LOGI("Creating filter component class: " @@ -229,6 +231,7 @@ struct bt_component_class_sink *bt_component_class_sink_create( struct bt_component_class_sink *sink_class = NULL; int ret; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_NON_NULL(method, "Consume next method"); BT_LOGI("Creating sink component class: " @@ -266,6 +269,7 @@ bt_component_class_source_set_get_supported_mip_versions_method( struct bt_component_class_source *comp_cls, bt_component_class_source_get_supported_mip_versions_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -280,6 +284,7 @@ bt_component_class_filter_set_get_supported_mip_versions_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_get_supported_mip_versions_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -294,6 +299,7 @@ bt_component_class_sink_set_get_supported_mip_versions_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_get_supported_mip_versions_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -308,6 +314,7 @@ bt_component_class_source_set_initialize_method( struct bt_component_class_source *comp_cls, bt_component_class_source_initialize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -322,6 +329,7 @@ bt_component_class_filter_set_initialize_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_initialize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -336,6 +344,7 @@ bt_component_class_sink_set_initialize_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_initialize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -350,6 +359,7 @@ bt_component_class_source_set_finalize_method( struct bt_component_class_source *comp_cls, bt_component_class_source_finalize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -364,6 +374,7 @@ bt_component_class_filter_set_finalize_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_finalize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -378,6 +389,7 @@ bt_component_class_sink_set_finalize_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_finalize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -392,6 +404,7 @@ bt_component_class_source_set_query_method( struct bt_component_class_source *comp_cls, bt_component_class_source_query_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -406,6 +419,7 @@ bt_component_class_filter_set_query_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_query_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -420,6 +434,7 @@ bt_component_class_sink_set_query_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_query_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -434,6 +449,7 @@ bt_component_class_filter_set_input_port_connected_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_input_port_connected_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -448,6 +464,7 @@ bt_component_class_sink_set_input_port_connected_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_input_port_connected_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -462,6 +479,7 @@ bt_component_class_source_set_output_port_connected_method( struct bt_component_class_source *comp_cls, bt_component_class_source_output_port_connected_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -476,6 +494,7 @@ bt_component_class_filter_set_output_port_connected_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_output_port_connected_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -490,6 +509,7 @@ bt_component_class_sink_set_graph_is_configured_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_graph_is_configured_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -504,6 +524,7 @@ bt_component_class_source_set_message_iterator_initialize_method( struct bt_component_class_source *comp_cls, bt_component_class_source_message_iterator_initialize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -518,6 +539,7 @@ bt_component_class_filter_set_message_iterator_initialize_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_message_iterator_initialize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -532,6 +554,7 @@ bt_component_class_source_set_message_iterator_finalize_method( struct bt_component_class_source *comp_cls, bt_component_class_source_message_iterator_finalize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -546,6 +569,7 @@ bt_component_class_filter_set_message_iterator_finalize_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_message_iterator_finalize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -561,6 +585,7 @@ bt_component_class_filter_set_message_iterator_seek_ns_from_origin_methods( bt_component_class_filter_message_iterator_seek_ns_from_origin_method seek_method, bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method can_seek_method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -577,6 +602,7 @@ bt_component_class_source_set_message_iterator_seek_ns_from_origin_methods( bt_component_class_source_message_iterator_seek_ns_from_origin_method seek_method, bt_component_class_source_message_iterator_can_seek_ns_from_origin_method can_seek_method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -593,6 +619,7 @@ bt_component_class_filter_set_message_iterator_seek_beginning_methods( bt_component_class_filter_message_iterator_seek_beginning_method seek_method, bt_component_class_filter_message_iterator_can_seek_beginning_method can_seek_method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -609,6 +636,7 @@ bt_component_class_source_set_message_iterator_seek_beginning_methods( bt_component_class_source_message_iterator_seek_beginning_method seek_method, bt_component_class_source_message_iterator_can_seek_beginning_method can_seek_method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -624,6 +652,7 @@ bt_component_class_set_description( struct bt_component_class *comp_cls, const char *description) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(description, "Description"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); @@ -640,6 +669,7 @@ enum bt_component_class_set_help_status bt_component_class_set_help( struct bt_component_class *comp_cls, const char *help) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(help, "Help"); BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); diff --git a/src/lib/graph/component-descriptor-set.c b/src/lib/graph/component-descriptor-set.c index 9dcbabf5a..e6b0894d0 100644 --- a/src/lib/graph/component-descriptor-set.c +++ b/src/lib/graph/component-descriptor-set.c @@ -86,6 +86,8 @@ struct bt_component_descriptor_set *bt_component_descriptor_set_create(void) { struct bt_component_descriptor_set *comp_descr_set; + BT_ASSERT_PRE_NO_ERROR(); + BT_LOGI_STR("Creating component descriptor set object."); comp_descr_set = g_new0(struct bt_component_descriptor_set, 1); if (!comp_descr_set) { @@ -140,6 +142,7 @@ bt_component_descriptor_set_add_descriptor_with_initialize_method_data( struct bt_component_descriptor_set_entry *entry = NULL; GPtrArray *comp_descr_array = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_descr_set, "Component descriptor set"); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE(!params || bt_value_is_map(params), @@ -214,6 +217,8 @@ bt_component_descriptor_set_add_descriptor( const struct bt_component_class *comp_cls, const struct bt_value *params) { + BT_ASSERT_PRE_NO_ERROR(); + return bt_component_descriptor_set_add_descriptor_with_initialize_method_data( comp_descr_set, comp_cls, params, NULL); } diff --git a/src/lib/graph/component-filter.c b/src/lib/graph/component-filter.c index 010e8fe85..9950a5029 100644 --- a/src/lib/graph/component-filter.c +++ b/src/lib/graph/component-filter.c @@ -48,6 +48,8 @@ struct bt_component *bt_component_filter_create( { struct bt_component_filter *filter = NULL; + BT_ASSERT_PRE_NO_ERROR(); + filter = g_new0(struct bt_component_filter, 1); if (!filter) { BT_LIB_LOGE_APPEND_CAUSE( @@ -122,6 +124,8 @@ enum bt_self_component_add_port_status bt_self_component_filter_add_output_port( enum bt_self_component_add_port_status status; struct bt_port *port = NULL; + BT_ASSERT_PRE_NO_ERROR(); + /* bt_component_add_output_port() logs details and errors */ status = bt_component_add_output_port(comp, name, user_data, &port); if (status != BT_FUNC_STATUS_OK) { @@ -190,6 +194,8 @@ enum bt_self_component_add_port_status bt_self_component_filter_add_input_port( struct bt_port *port = NULL; struct bt_component *comp = (void *) self_comp; + BT_ASSERT_PRE_NO_ERROR(); + /* bt_component_add_input_port() logs details/errors */ status = bt_component_add_input_port(comp, name, user_data, &port); if (status != BT_FUNC_STATUS_OK) { diff --git a/src/lib/graph/component-sink.c b/src/lib/graph/component-sink.c index b848a019a..577239acf 100644 --- a/src/lib/graph/component-sink.c +++ b/src/lib/graph/component-sink.c @@ -49,6 +49,8 @@ struct bt_component *bt_component_sink_create( { struct bt_component_sink *sink = NULL; + BT_ASSERT_PRE_NO_ERROR(); + sink = g_new0(struct bt_component_sink, 1); if (!sink) { BT_LIB_LOGE_APPEND_CAUSE( @@ -126,6 +128,8 @@ enum bt_self_component_add_port_status bt_self_component_sink_add_input_port( struct bt_port *port = NULL; struct bt_component *comp = (void *) self_comp; + BT_ASSERT_PRE_NO_ERROR(); + /* bt_component_add_input_port() logs details/errors */ status = bt_component_add_input_port(comp, name, user_data, &port); if (status != BT_FUNC_STATUS_OK) { diff --git a/src/lib/graph/component-source.c b/src/lib/graph/component-source.c index aed5dafd6..d793c1920 100644 --- a/src/lib/graph/component-source.c +++ b/src/lib/graph/component-source.c @@ -48,6 +48,8 @@ struct bt_component *bt_component_source_create( { struct bt_component_source *source = NULL; + BT_ASSERT_PRE_NO_ERROR(); + source = g_new0(struct bt_component_source, 1); if (!source) { BT_LIB_LOGE_APPEND_CAUSE( @@ -120,6 +122,8 @@ enum bt_self_component_add_port_status bt_self_component_source_add_output_port( enum bt_self_component_add_port_status status; struct bt_port *port = NULL; + BT_ASSERT_PRE_NO_ERROR(); + /* bt_component_add_output_port() logs details and errors */ status = bt_component_add_output_port(comp, name, user_data, &port); if (status != BT_FUNC_STATUS_OK) { diff --git a/src/lib/graph/graph.c b/src/lib/graph/graph.c index 0f30ec46a..22c4f92f8 100644 --- a/src/lib/graph/graph.c +++ b/src/lib/graph/graph.c @@ -268,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, @@ -432,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"); @@ -704,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); @@ -728,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); @@ -809,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"); @@ -844,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"); @@ -879,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"); @@ -914,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"); @@ -949,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"); @@ -985,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"); @@ -1021,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"); @@ -1057,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"); @@ -1413,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, @@ -1426,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); } @@ -1438,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, @@ -1451,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); } @@ -1463,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, @@ -1476,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); } @@ -1496,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(). @@ -1546,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); diff --git a/src/lib/graph/interrupter.c b/src/lib/graph/interrupter.c index 2a066ddd9..5e48e5e69 100644 --- a/src/lib/graph/interrupter.c +++ b/src/lib/graph/interrupter.c @@ -40,6 +40,8 @@ extern struct bt_interrupter *bt_interrupter_create(void) { struct bt_interrupter *intr = g_new0(struct bt_interrupter, 1); + BT_ASSERT_PRE_NO_ERROR(); + if (!intr) { BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one interrupter."); goto error; diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index 6dc3ba982..49381a3ca 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -527,6 +527,7 @@ bt_self_component_port_input_message_iterator_create_from_message_iterator( struct bt_self_component_port_input *input_port, struct bt_self_component_port_input_message_iterator **message_iterator) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(self_msg_iter, "Message iterator"); return create_self_component_input_port_message_iterator(self_msg_iter, input_port, message_iterator); @@ -538,6 +539,7 @@ bt_self_component_port_input_message_iterator_create_from_sink_component( struct bt_self_component_port_input *input_port, struct bt_self_component_port_input_message_iterator **message_iterator) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(self_comp, "Sink component"); return create_self_component_input_port_message_iterator(NULL, input_port, message_iterator); @@ -882,6 +884,7 @@ bt_self_component_port_input_message_iterator_next( { enum bt_message_iterator_next_status status = BT_FUNC_STATUS_OK; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(iterator, "Message iterator"); BT_ASSERT_PRE_DEV_NON_NULL(msgs, "Message array (output)"); BT_ASSERT_PRE_DEV_NON_NULL(user_count, "Message count (output)"); @@ -988,6 +991,7 @@ bt_self_component_port_input_message_iterator_can_seek_ns_from_origin( { enum bt_message_iterator_can_seek_ns_from_origin_status status; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); BT_ASSERT_PRE_NON_NULL(can_seek, "Result (output)"); BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator); @@ -1058,6 +1062,7 @@ bt_self_component_port_input_message_iterator_can_seek_beginning( { enum bt_message_iterator_can_seek_beginning_status status; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); BT_ASSERT_PRE_NON_NULL(can_seek, "Result (output)"); BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator); @@ -1150,6 +1155,7 @@ bt_self_component_port_input_message_iterator_seek_beginning( { int status; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator); BT_ASSERT_PRE( @@ -1714,6 +1720,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( GHashTable *stream_states = NULL; bt_bool can_seek_by_itself; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator); BT_ASSERT_PRE( diff --git a/src/lib/graph/message/discarded-items.c b/src/lib/graph/message/discarded-items.c index b3522adf7..0b19abc36 100644 --- a/src/lib/graph/message/discarded-items.c +++ b/src/lib/graph/message/discarded-items.c @@ -225,6 +225,8 @@ struct bt_message *bt_message_discarded_events_create( struct bt_self_message_iterator *message_iterator, const struct bt_stream *stream) { + BT_ASSERT_PRE_DEV_NO_ERROR(); + return create_discarded_items_message(message_iterator, BT_MESSAGE_TYPE_DISCARDED_EVENTS, (void *) stream, false, 0, 0); @@ -235,6 +237,8 @@ struct bt_message *bt_message_discarded_events_create_with_default_clock_snapsho const struct bt_stream *stream, uint64_t beginning_raw_value, uint64_t end_raw_value) { + BT_ASSERT_PRE_DEV_NO_ERROR(); + return create_discarded_items_message(message_iterator, BT_MESSAGE_TYPE_DISCARDED_EVENTS, (void *) stream, true, beginning_raw_value, end_raw_value); @@ -296,6 +300,8 @@ struct bt_message *bt_message_discarded_packets_create( struct bt_self_message_iterator *message_iterator, const struct bt_stream *stream) { + BT_ASSERT_PRE_DEV_NO_ERROR(); + return create_discarded_items_message(message_iterator, BT_MESSAGE_TYPE_DISCARDED_PACKETS, (void *) stream, false, 0, 0); @@ -306,6 +312,8 @@ struct bt_message *bt_message_discarded_packets_create_with_default_clock_snapsh const struct bt_stream *stream, uint64_t beginning_raw_value, uint64_t end_raw_value) { + BT_ASSERT_PRE_DEV_NO_ERROR(); + return create_discarded_items_message(message_iterator, BT_MESSAGE_TYPE_DISCARDED_PACKETS, (void *) stream, true, beginning_raw_value, end_raw_value); diff --git a/src/lib/graph/message/event.c b/src/lib/graph/message/event.c index 576257900..7c4754f97 100644 --- a/src/lib/graph/message/event.c +++ b/src/lib/graph/message/event.c @@ -177,6 +177,7 @@ struct bt_message *bt_message_event_create( const struct bt_event_class *event_class, const struct bt_stream *stream) { + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream, "Stream"); return create_event_message(msg_iter, event_class, NULL, stream, false, 0); } @@ -186,6 +187,7 @@ struct bt_message *bt_message_event_create_with_packet( const struct bt_event_class *event_class, const struct bt_packet *packet) { + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(packet, "Packet"); return create_event_message(msg_iter, event_class, packet, packet->stream, false, 0); @@ -197,6 +199,7 @@ struct bt_message *bt_message_event_create_with_default_clock_snapshot( const struct bt_stream *stream, uint64_t raw_value) { + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream, "Stream"); return create_event_message(msg_iter, event_class, NULL, stream, true, raw_value); @@ -209,6 +212,7 @@ bt_message_event_create_with_packet_and_default_clock_snapshot( const struct bt_packet *packet, uint64_t raw_value) { + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(packet, "Packet"); return create_event_message(msg_iter, event_class, packet, packet->stream, true, raw_value); diff --git a/src/lib/graph/message/message-iterator-inactivity.c b/src/lib/graph/message/message-iterator-inactivity.c index adfa4c574..e5776ae04 100644 --- a/src/lib/graph/message/message-iterator-inactivity.c +++ b/src/lib/graph/message/message-iterator-inactivity.c @@ -61,6 +61,7 @@ struct bt_message *bt_message_message_iterator_inactivity_create( struct bt_message_message_iterator_inactivity *message; struct bt_message *ret_msg = NULL; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); BT_ASSERT_PRE_NON_NULL(default_clock_class, "Default clock class"); BT_LIB_LOGD("Creating message iterator inactivity message object: " diff --git a/src/lib/graph/message/packet.c b/src/lib/graph/message/packet.c index 061254173..25c1abf49 100644 --- a/src/lib/graph/message/packet.c +++ b/src/lib/graph/message/packet.c @@ -174,6 +174,7 @@ struct bt_message *bt_message_packet_beginning_create( struct bt_self_component_port_input_message_iterator *msg_iter = (void *) self_msg_iter; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); return create_packet_message(msg_iter, (void *) packet, &msg_iter->graph->packet_begin_msg_pool, false, 0); @@ -186,6 +187,7 @@ struct bt_message *bt_message_packet_beginning_create_with_default_clock_snapsho struct bt_self_component_port_input_message_iterator *msg_iter = (void *) self_msg_iter; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); return create_packet_message(msg_iter, (void *) packet, &msg_iter->graph->packet_begin_msg_pool, true, raw_value); @@ -198,6 +200,7 @@ struct bt_message *bt_message_packet_end_create( struct bt_self_component_port_input_message_iterator *msg_iter = (void *) self_msg_iter; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); return create_packet_message(msg_iter, (void *) packet, &msg_iter->graph->packet_end_msg_pool, false, 0); @@ -210,6 +213,7 @@ struct bt_message *bt_message_packet_end_create_with_default_clock_snapshot( struct bt_self_component_port_input_message_iterator *msg_iter = (void *) self_msg_iter; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); return create_packet_message(msg_iter, (void *) packet, &msg_iter->graph->packet_end_msg_pool, true, raw_value); diff --git a/src/lib/graph/message/stream.c b/src/lib/graph/message/stream.c index a110338aa..40903d001 100644 --- a/src/lib/graph/message/stream.c +++ b/src/lib/graph/message/stream.c @@ -113,6 +113,8 @@ struct bt_message *bt_message_stream_beginning_create( struct bt_self_message_iterator *self_msg_iter, const struct bt_stream *stream) { + BT_ASSERT_PRE_DEV_NO_ERROR(); + return create_stream_message(self_msg_iter, (void *) stream, BT_MESSAGE_TYPE_STREAM_BEGINNING); } @@ -121,6 +123,8 @@ struct bt_message *bt_message_stream_end_create( struct bt_self_message_iterator *self_msg_iter, const struct bt_stream *stream) { + BT_ASSERT_PRE_DEV_NO_ERROR(); + return create_stream_message(self_msg_iter, (void *) stream, BT_MESSAGE_TYPE_STREAM_END); } diff --git a/src/lib/graph/mip.c b/src/lib/graph/mip.c index 2e0aac35d..a4704c5d5 100644 --- a/src/lib/graph/mip.c +++ b/src/lib/graph/mip.c @@ -195,6 +195,7 @@ bt_get_greatest_operative_mip_version( { int status = BT_FUNC_STATUS_OK; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_descr_set, "Component descriptor set"); BT_ASSERT_PRE_NON_NULL(operative_mip_version, "Operative MIP version (output)"); diff --git a/src/lib/graph/query-executor.c b/src/lib/graph/query-executor.c index c798cfe5b..9a78d790a 100644 --- a/src/lib/graph/query-executor.c +++ b/src/lib/graph/query-executor.c @@ -74,6 +74,7 @@ struct bt_query_executor *bt_query_executor_create_with_method_data( { struct bt_query_executor *query_exec; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(object, "Object"); BT_LIB_LOGD("Creating query executor: " @@ -137,6 +138,7 @@ struct bt_query_executor *bt_query_executor_create( const bt_component_class *comp_cls, const char *object, const bt_value *params) { + BT_ASSERT_PRE_NO_ERROR(); return bt_query_executor_create_with_method_data(comp_cls, object, params, NULL); } @@ -157,6 +159,7 @@ enum bt_query_executor_query_status bt_query_executor_query( enum bt_component_class_query_method_status query_status; method_t method = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(query_exec, "Query executor"); BT_ASSERT_PRE_NON_NULL(user_result, "Result (output)"); @@ -256,6 +259,7 @@ enum bt_query_executor_add_interrupter_status bt_query_executor_add_interrupter( struct bt_query_executor *query_exec, const struct bt_interrupter *intr) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(query_exec, "Query executor"); BT_ASSERT_PRE_NON_NULL(intr, "Interrupter"); g_ptr_array_add(query_exec->interrupters, (void *) intr); diff --git a/src/lib/integer-range-set.c b/src/lib/integer-range-set.c index 3c01ba35b..e1c5e6d1e 100644 --- a/src/lib/integer-range-set.c +++ b/src/lib/integer-range-set.c @@ -180,11 +180,15 @@ struct bt_integer_range_set *create_range_set(void) struct bt_integer_range_set_unsigned *bt_integer_range_set_unsigned_create(void) { + BT_ASSERT_PRE_NO_ERROR(); + return (void *) create_range_set(); } struct bt_integer_range_set_signed *bt_integer_range_set_signed_create(void) { + BT_ASSERT_PRE_NO_ERROR(); + return (void *) create_range_set(); } @@ -211,6 +215,7 @@ bt_integer_range_set_unsigned_add_range( struct bt_integer_range_set_unsigned *range_set, uint64_t lower, uint64_t upper) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE(lower <= upper, "Range's upper bound is less than lower bound: " "upper=%" PRIu64 ", lower=%" PRIu64, lower, upper); @@ -223,6 +228,7 @@ bt_integer_range_set_signed_add_range( struct bt_integer_range_set_signed *range_set, int64_t lower, int64_t upper) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE(lower <= upper, "Range's upper bound is less than lower bound: " "upper=%" PRId64 ", lower=%" PRId64, lower, upper); diff --git a/src/lib/plugin/plugin.c b/src/lib/plugin/plugin.c index 58a241904..16850d80e 100644 --- a/src/lib/plugin/plugin.c +++ b/src/lib/plugin/plugin.c @@ -188,6 +188,8 @@ enum bt_plugin_find_all_from_static_status bt_plugin_find_all_from_static( bt_bool fail_on_load_error, const struct bt_plugin_set **plugin_set_out) { + BT_ASSERT_PRE_NO_ERROR(); + /* bt_plugin_so_create_all_from_static() logs errors */ return bt_plugin_so_create_all_from_static(fail_on_load_error, (void *) plugin_set_out); @@ -199,6 +201,7 @@ enum bt_plugin_find_all_from_file_status bt_plugin_find_all_from_file( { enum bt_plugin_find_all_from_file_status status; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(path, "Path"); BT_ASSERT_PRE_NON_NULL(path, "Plugin set (output)"); BT_LOGI("Creating plugins from file: path=\"%s\"", path); @@ -282,6 +285,7 @@ enum bt_plugin_find_all_status bt_plugin_find_all(bt_bool find_in_std_env_var, int status = BT_FUNC_STATUS_OK; uint64_t dir_i, plugin_i; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(plugin_set_out, "Plugin set (output)"); BT_LOGI("Finding all plugins in standard directories and built-in plugins: " "find-in-std-env-var=%d, find-in-user-dir=%d, " @@ -465,6 +469,7 @@ enum bt_plugin_find_status bt_plugin_find(const char *plugin_name, const struct bt_plugin_set *plugin_set = NULL; uint64_t i; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(plugin_name, "Name"); BT_ASSERT_PRE_NON_NULL(plugin_out, "Plugin (output)"); BT_LOGI("Finding named plugin in standard directories and built-in plugins: " @@ -666,6 +671,7 @@ enum bt_plugin_find_all_from_dir_status bt_plugin_find_all_from_dir( enum bt_plugin_find_all_from_dir_status status = BT_FUNC_STATUS_OK; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(plugin_set_out, "Plugin set (output)"); BT_LOGI("Creating all plugins in directory: path=\"%s\", recurse=%d", path, recurse); diff --git a/src/lib/trace-ir/clock-class.c b/src/lib/trace-ir/clock-class.c index 0b449e277..736e0b8e2 100644 --- a/src/lib/trace-ir/clock-class.c +++ b/src/lib/trace-ir/clock-class.c @@ -88,6 +88,7 @@ struct bt_clock_class *bt_clock_class_create(bt_self_component *self_comp) int ret; struct bt_clock_class *clock_class = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(self_comp, "Self component"); BT_LOGD_STR("Creating default clock class object"); @@ -152,6 +153,7 @@ const char *bt_clock_class_get_name(const struct bt_clock_class *clock_class) enum bt_clock_class_set_name_status bt_clock_class_set_name( struct bt_clock_class *clock_class, const char *name) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_DEV_CLOCK_CLASS_HOT(clock_class); @@ -171,6 +173,7 @@ const char *bt_clock_class_get_description( enum bt_clock_class_set_description_status bt_clock_class_set_description( struct bt_clock_class *clock_class, const char *descr) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); BT_ASSERT_PRE_NON_NULL(descr, "Description"); BT_ASSERT_PRE_DEV_CLOCK_CLASS_HOT(clock_class); @@ -301,6 +304,7 @@ bt_clock_class_cycles_to_ns_from_origin( { int ret; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(clock_class, "Clock class"); BT_ASSERT_PRE_DEV_NON_NULL(ns, "Nanoseconds (output)"); ret = bt_util_ns_from_origin_clock_class(clock_class, cycles, ns); diff --git a/src/lib/trace-ir/clock-snapshot.c b/src/lib/trace-ir/clock-snapshot.c index cbce39c14..19aab80aa 100644 --- a/src/lib/trace-ir/clock-snapshot.c +++ b/src/lib/trace-ir/clock-snapshot.c @@ -149,6 +149,7 @@ bt_clock_snapshot_get_ns_from_origin( { int ret = BT_FUNC_STATUS_OK; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(clock_snapshot, "Clock snapshot"); BT_ASSERT_PRE_DEV_NON_NULL(ret_value_ns, "Value (ns) (output)"); BT_ASSERT_PRE_DEV(clock_snapshot->is_set, diff --git a/src/lib/trace-ir/event-class.c b/src/lib/trace-ir/event-class.c index ba79f28b6..22211cd1a 100644 --- a/src/lib/trace-ir/event-class.c +++ b/src/lib/trace-ir/event-class.c @@ -178,6 +178,7 @@ struct bt_event_class *create_event_class_with_id( struct bt_event_class *bt_event_class_create( struct bt_stream_class *stream_class) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); BT_ASSERT_PRE(stream_class->assigns_automatic_event_class_id, "Stream class does not automatically assigns event class IDs: " @@ -189,6 +190,7 @@ struct bt_event_class *bt_event_class_create( struct bt_event_class *bt_event_class_create_with_id( struct bt_stream_class *stream_class, uint64_t id) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE(!stream_class->assigns_automatic_event_class_id, "Stream class automatically assigns event class IDs: " "%![sc-]+S", stream_class); @@ -204,6 +206,7 @@ const char *bt_event_class_get_name(const struct bt_event_class *event_class) enum bt_event_class_set_name_status bt_event_class_set_name( struct bt_event_class *event_class, const char *name) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class); @@ -251,6 +254,7 @@ enum bt_event_class_set_emf_uri_status bt_event_class_set_emf_uri( struct bt_event_class *event_class, const char *emf_uri) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); BT_ASSERT_PRE_NON_NULL(emf_uri, "EMF URI"); BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class); @@ -304,6 +308,7 @@ bt_event_class_set_specific_context_field_class( .event_payload = NULL, }; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class); @@ -368,6 +373,7 @@ bt_event_class_set_payload_field_class( .event_payload = field_class, }; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class); diff --git a/src/lib/trace-ir/field-class.c b/src/lib/trace-ir/field-class.c index a282c9bce..e036cfae2 100644 --- a/src/lib/trace-ir/field-class.c +++ b/src/lib/trace-ir/field-class.c @@ -98,6 +98,7 @@ struct bt_field_class *bt_field_class_bit_array_create( { struct bt_field_class_bit_array *ba_fc = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class"); BT_ASSERT_PRE(length > 0 && length <= 64, "Unsupported length for bit array field class " @@ -150,6 +151,7 @@ struct bt_field_class *bt_field_class_bool_create( { struct bt_field_class_bool *bool_fc = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class"); BT_LOGD("Creating default boolean field class object."); bool_fc = g_new0(struct bt_field_class_bool, 1); @@ -236,6 +238,8 @@ struct bt_field_class *create_integer_field_class(bt_trace_class *trace_class, struct bt_field_class *bt_field_class_integer_unsigned_create( bt_trace_class *trace_class) { + BT_ASSERT_PRE_NO_ERROR(); + return create_integer_field_class(trace_class, BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER); } @@ -243,6 +247,8 @@ struct bt_field_class *bt_field_class_integer_unsigned_create( struct bt_field_class *bt_field_class_integer_signed_create( bt_trace_class *trace_class) { + BT_ASSERT_PRE_NO_ERROR(); + return create_integer_field_class(trace_class, BT_FIELD_CLASS_TYPE_SIGNED_INTEGER); } @@ -400,6 +406,8 @@ struct bt_field_class *create_enumeration_field_class( struct bt_field_class *bt_field_class_enumeration_unsigned_create( bt_trace_class *trace_class) { + BT_ASSERT_PRE_NO_ERROR(); + return create_enumeration_field_class(trace_class, BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION); } @@ -407,6 +415,8 @@ struct bt_field_class *bt_field_class_enumeration_unsigned_create( struct bt_field_class *bt_field_class_enumeration_signed_create( bt_trace_class *trace_class) { + BT_ASSERT_PRE_NO_ERROR(); + return create_enumeration_field_class(trace_class, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION); } @@ -532,6 +542,7 @@ bt_field_class_enumeration_unsigned_get_mapping_labels_for_value( const struct bt_field_class_enumeration *enum_fc = (const void *) fc; uint64_t i; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(fc, "Field class"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)"); BT_ASSERT_PRE_DEV_NON_NULL(count, "Count (output)"); @@ -572,6 +583,7 @@ bt_field_class_enumeration_signed_get_mapping_labels_for_value( const struct bt_field_class_enumeration *enum_fc = (const void *) fc; uint64_t i; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(fc, "Field class"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)"); BT_ASSERT_PRE_DEV_NON_NULL(count, "Count (output)"); @@ -638,6 +650,7 @@ add_mapping_to_enumeration_field_class(struct bt_field_class *fc, struct bt_field_class_enumeration *enum_fc = (void *) fc; struct bt_field_class_enumeration_mapping mapping = { 0 }; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT(fc); BT_ASSERT_PRE_NON_NULL(label, "Label"); BT_ASSERT_PRE_NON_NULL(range_set, "Integer range set"); @@ -667,6 +680,7 @@ bt_field_class_enumeration_unsigned_add_mapping( struct bt_field_class *fc, const char *label, const struct bt_integer_range_set_unsigned *range_set) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(fc, "Field class"); BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, "Field class"); @@ -679,6 +693,7 @@ bt_field_class_enumeration_signed_add_mapping( struct bt_field_class *fc, const char *label, const struct bt_integer_range_set_signed *range_set) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(fc, "Field class"); BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, "Field class"); @@ -727,6 +742,8 @@ struct bt_field_class *create_real_field_class(bt_trace_class *trace_class, struct bt_field_class *bt_field_class_real_single_precision_create( bt_trace_class *trace_class) { + BT_ASSERT_PRE_NO_ERROR(); + return create_real_field_class(trace_class, BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL); } @@ -734,6 +751,8 @@ struct bt_field_class *bt_field_class_real_single_precision_create( struct bt_field_class *bt_field_class_real_double_precision_create( bt_trace_class *trace_class) { + BT_ASSERT_PRE_NO_ERROR(); + return create_real_field_class(trace_class, BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL); } @@ -847,6 +866,7 @@ struct bt_field_class *bt_field_class_structure_create( int ret; struct bt_field_class_structure *struct_fc = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class"); BT_LOGD_STR("Creating default structure field class object."); struct_fc = g_new0(struct bt_field_class_structure, 1); @@ -1001,6 +1021,7 @@ bt_field_class_structure_append_member( enum bt_field_class_structure_append_member_status status; struct bt_named_field_class *named_fc = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(fc, "Field class"); BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE, "Field class"); @@ -1258,6 +1279,8 @@ struct bt_field_class *bt_field_class_option_without_selector_create( struct bt_trace_class *trace_class, struct bt_field_class *content_fc) { + BT_ASSERT_PRE_NO_ERROR(); + return create_option_field_class(trace_class, BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD, content_fc, NULL); @@ -1268,17 +1291,11 @@ struct bt_field_class *bt_field_class_option_with_selector_field_bool_create( struct bt_field_class *content_fc, struct bt_field_class *selector_fc) { - struct bt_field_class_option_with_selector_field_bool *fc = - (void *) create_option_field_class(trace_class, - BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD, - content_fc, selector_fc); + BT_ASSERT_PRE_NO_ERROR(); - if (!fc) { - goto end; - } - -end: - return (void *) fc; + return create_option_field_class(trace_class, + BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD, + content_fc, selector_fc); } struct bt_field_class * @@ -1292,6 +1309,7 @@ bt_field_class_option_with_selector_field_integer_unsigned_create( const struct bt_integer_range_set *range_set = (const void *) u_range_set; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(range_set, "Integer range set"); BT_ASSERT_PRE(range_set->ranges->len > 0, "Integer range set is empty: %!+R", range_set); @@ -1322,6 +1340,7 @@ bt_field_class_option_with_selector_field_integer_signed_create( const struct bt_integer_range_set *range_set = (const void *) i_range_set; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(range_set, "Integer range set"); BT_ASSERT_PRE(range_set->ranges->len > 0, "Integer range set is empty: %!+R", range_set); @@ -1461,6 +1480,7 @@ struct bt_field_class *bt_field_class_variant_create( struct bt_field_class_variant_with_selector_field *var_with_sel_fc = NULL; enum bt_field_class_type fc_type; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class"); if (selector_fc) { @@ -1538,6 +1558,7 @@ bt_field_class_variant_without_selector_append_option(struct bt_field_class *fc, enum bt_field_class_variant_without_selector_append_option_status status; struct bt_named_field_class *named_fc = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(fc, "Field class"); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_NON_NULL(option_fc, "Option field class"); @@ -1708,6 +1729,8 @@ bt_field_class_variant_with_selector_field_integer_unsigned_append_option( struct bt_field_class *option_fc, const struct bt_integer_range_set_unsigned *range_set) { + BT_ASSERT_PRE_NO_ERROR(); + return append_option_to_variant_with_selector_field_field_class(fc, name, option_fc, (const void *) range_set, BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD); @@ -1719,6 +1742,8 @@ bt_field_class_variant_with_selector_field_integer_signed_append_option( struct bt_field_class *option_fc, const struct bt_integer_range_set_signed *range_set) { + BT_ASSERT_PRE_NO_ERROR(); + return append_option_to_variant_with_selector_field_field_class(fc, name, option_fc, (const void *) range_set, BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD); @@ -1937,6 +1962,7 @@ bt_field_class_array_static_create(bt_trace_class *trace_class, { struct bt_field_class_array_static *array_fc = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class"); BT_ASSERT_PRE_NON_NULL(element_fc, "Element field class"); BT_LOGD_STR("Creating default static array field class object."); @@ -2017,6 +2043,7 @@ struct bt_field_class *bt_field_class_array_dynamic_create( { struct bt_field_class_array_dynamic *array_fc = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class"); BT_ASSERT_PRE_NON_NULL(element_fc, "Element field class"); BT_LOGD_STR("Creating default dynamic array field class object."); @@ -2059,6 +2086,7 @@ bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const( { const struct bt_field_class_array_dynamic *seq_fc = (const void *) fc; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(fc, "Field class"); BT_ASSERT_PRE_DEV_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, @@ -2079,6 +2107,7 @@ struct bt_field_class *bt_field_class_string_create(bt_trace_class *trace_class) { struct bt_field_class_string *string_fc = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class"); BT_LOGD_STR("Creating default string field class object."); string_fc = g_new0(struct bt_field_class_string, 1); diff --git a/src/lib/trace-ir/field.c b/src/lib/trace-ir/field.c index 8db595ec8..91e918dda 100644 --- a/src/lib/trace-ir/field.c +++ b/src/lib/trace-ir/field.c @@ -797,6 +797,7 @@ bt_field_enumeration_unsigned_get_mapping_labels( { const struct bt_field_integer *int_field = (const void *) field; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)"); @@ -816,6 +817,7 @@ bt_field_enumeration_signed_get_mapping_labels( { const struct bt_field_integer *int_field = (const void *) field; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)"); @@ -862,6 +864,7 @@ void clear_string_field(struct bt_field *field) enum bt_field_string_set_value_status bt_field_string_set_value( struct bt_field *field, const char *value) { + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_NON_NULL(value, "Value"); BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field"); @@ -875,6 +878,8 @@ enum bt_field_string_set_value_status bt_field_string_set_value( enum bt_field_string_append_status bt_field_string_append( struct bt_field *field, const char *value) { + BT_ASSERT_PRE_DEV_NO_ERROR(); + return bt_field_string_append_with_length(field, value, (uint64_t) strlen(value)); } @@ -886,6 +891,7 @@ enum bt_field_string_append_status bt_field_string_append_with_length( char *data; uint64_t new_length; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_NON_NULL(value, "Value"); BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field"); @@ -935,6 +941,7 @@ enum bt_field_array_dynamic_set_length_status bt_field_array_dynamic_set_length( int ret = BT_FUNC_STATUS_OK; struct bt_field_array *array_field = (void *) field; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(field, "Field"); BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field"); @@ -1171,6 +1178,7 @@ bt_field_variant_select_option_field_by_index( { struct bt_field_variant *var_field = (void *) field; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field"); BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field"); diff --git a/src/lib/trace-ir/packet-context-field.c b/src/lib/trace-ir/packet-context-field.c index 786cbdf6a..c5a628c2e 100644 --- a/src/lib/trace-ir/packet-context-field.c +++ b/src/lib/trace-ir/packet-context-field.c @@ -62,6 +62,7 @@ struct bt_packet_context_field *bt_packet_context_field_create( { struct bt_field_wrapper *field_wrapper; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); BT_ASSERT_PRE(stream_class->supports_packets, "Stream class does not support packets: %![sc-]+S", diff --git a/src/lib/trace-ir/packet.c b/src/lib/trace-ir/packet.c index a5c3fc7a1..166f7ca2e 100644 --- a/src/lib/trace-ir/packet.c +++ b/src/lib/trace-ir/packet.c @@ -219,6 +219,7 @@ struct bt_packet *bt_packet_create(const struct bt_stream *c_stream) struct bt_packet *packet = NULL; struct bt_stream *stream = (void *) c_stream; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream, "Stream"); BT_ASSERT_PRE(stream->class->supports_packets, "Stream class does not support packets: %![sc-]+S", @@ -248,6 +249,7 @@ enum bt_packet_move_context_field_status bt_packet_move_context_field( struct bt_stream_class *stream_class; struct bt_field_wrapper *field_wrapper = (void *) context_field; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(packet, "Packet"); BT_ASSERT_PRE_DEV_NON_NULL(field_wrapper, "Context field"); BT_ASSERT_PRE_DEV_HOT(packet, "Packet", ": %!+a", packet); diff --git a/src/lib/trace-ir/stream-class.c b/src/lib/trace-ir/stream-class.c index c87978b5a..e580b2a9e 100644 --- a/src/lib/trace-ir/stream-class.c +++ b/src/lib/trace-ir/stream-class.c @@ -177,6 +177,7 @@ struct bt_stream_class *create_stream_class_with_id( struct bt_stream_class *bt_stream_class_create(struct bt_trace_class *tc) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(tc, "Trace class"); BT_ASSERT_PRE(tc->assigns_automatic_stream_class_id, "Trace class does not automatically assigns stream class IDs: " @@ -188,6 +189,7 @@ struct bt_stream_class *bt_stream_class_create(struct bt_trace_class *tc) struct bt_stream_class *bt_stream_class_create_with_id( struct bt_trace_class *tc, uint64_t id) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(tc, "Trace class"); BT_ASSERT_PRE(!tc->assigns_automatic_stream_class_id, "Trace class automatically assigns stream class IDs: " @@ -218,6 +220,7 @@ enum bt_stream_class_set_name_status bt_stream_class_set_name( struct bt_stream_class *stream_class, const char *name) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class); @@ -315,6 +318,7 @@ bt_stream_class_set_packet_context_field_class( .event_payload = NULL, }; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); BT_ASSERT_PRE(stream_class->supports_packets, "Stream class does not support packets: %![sc-]+S", @@ -377,6 +381,7 @@ bt_stream_class_set_event_common_context_field_class( .event_payload = NULL, }; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class); @@ -425,6 +430,7 @@ bt_stream_class_set_default_clock_class( struct bt_stream_class *stream_class, struct bt_clock_class *clock_class) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class); diff --git a/src/lib/trace-ir/stream.c b/src/lib/trace-ir/stream.c index ec97a292c..c35b9da99 100644 --- a/src/lib/trace-ir/stream.c +++ b/src/lib/trace-ir/stream.c @@ -167,6 +167,7 @@ struct bt_stream *bt_stream_create(struct bt_stream_class *stream_class, { uint64_t id; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE(stream_class->assigns_automatic_stream_id, @@ -179,6 +180,7 @@ struct bt_stream *bt_stream_create(struct bt_stream_class *stream_class, struct bt_stream *bt_stream_create_with_id(struct bt_stream_class *stream_class, struct bt_trace *trace, uint64_t id) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE(!stream_class->assigns_automatic_stream_id, @@ -220,6 +222,7 @@ const char *bt_stream_get_name(const struct bt_stream *stream) enum bt_stream_set_name_status bt_stream_set_name(struct bt_stream *stream, const char *name) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(stream, "Stream"); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_DEV_STREAM_HOT(stream); diff --git a/src/lib/trace-ir/trace-class.c b/src/lib/trace-ir/trace-class.c index 3e6a872c1..f9aedea09 100644 --- a/src/lib/trace-ir/trace-class.c +++ b/src/lib/trace-ir/trace-class.c @@ -128,6 +128,7 @@ struct bt_trace_class *bt_trace_class_create(bt_self_component *self_comp) { struct bt_trace_class *tc = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(self_comp, "Self component"); BT_LOGD_STR("Creating default trace class object."); tc = g_new0(struct bt_trace_class, 1); @@ -181,6 +182,7 @@ enum bt_trace_class_add_listener_status bt_trace_class_add_destruction_listener( .data = data, }; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(tc, "Trace class"); BT_ASSERT_PRE_NON_NULL(listener, "Listener"); @@ -225,6 +227,7 @@ enum bt_trace_class_remove_listener_status bt_trace_class_remove_destruction_lis struct bt_trace_class *tc = (void *) _tc; struct bt_trace_class_destruction_listener_elem *elem; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(tc, "Trace class"); BT_ASSERT_PRE(has_listener_id(tc, listener_id), "Trace class has no such trace class destruction listener ID: " diff --git a/src/lib/trace-ir/trace.c b/src/lib/trace-ir/trace.c index 3bf26b7bc..d155cae2e 100644 --- a/src/lib/trace-ir/trace.c +++ b/src/lib/trace-ir/trace.c @@ -150,6 +150,8 @@ struct bt_trace *bt_trace_create(struct bt_trace_class *tc) { struct bt_trace *trace = NULL; + BT_ASSERT_PRE_NO_ERROR(); + BT_LIB_LOGD("Creating trace object: %![tc-]+T", tc); trace = g_new0(struct bt_trace, 1); if (!trace) { @@ -219,6 +221,7 @@ const char *bt_trace_get_name(const struct bt_trace *trace) enum bt_trace_set_name_status bt_trace_set_name(struct bt_trace *trace, const char *name) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_DEV_TRACE_HOT(trace); @@ -289,9 +292,12 @@ bt_trace_set_environment_entry_string( { int ret; struct bt_value *value_obj; + + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_NON_NULL(value, "Value"); + value_obj = bt_value_string_create_init(value); if (!value_obj) { BT_LIB_LOGE_APPEND_CAUSE( @@ -314,8 +320,11 @@ bt_trace_set_environment_entry_integer( { int ret; struct bt_value *value_obj; + + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(name, "Name"); + value_obj = bt_value_integer_signed_create_init(value); if (!value_obj) { BT_LIB_LOGE_APPEND_CAUSE( @@ -422,6 +431,7 @@ enum bt_trace_add_listener_status bt_trace_add_destruction_listener( .data = data, }; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(listener, "Listener"); @@ -466,6 +476,7 @@ enum bt_trace_remove_listener_status bt_trace_remove_destruction_listener( struct bt_trace *trace = (void *) c_trace; struct bt_trace_destruction_listener_elem *elem; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE(has_listener_id(trace, listener_id), "Trace has no such trace destruction listener ID: " diff --git a/src/lib/util.c b/src/lib/util.c index af2d1a4a6..8c54e0ea4 100644 --- a/src/lib/util.c +++ b/src/lib/util.c @@ -42,6 +42,7 @@ bt_util_clock_cycles_to_ns_from_origin(uint64_t cycles, BT_FUNC_STATUS_OK; int ret; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(ns, "Nanoseconds (output)"); BT_ASSERT_PRE(frequency != UINT64_C(-1) && frequency != 0, "Invalid frequency: freq=%" PRIu64, frequency); diff --git a/src/lib/value.c b/src/lib/value.c index 96c01ac45..15a97a828 100644 --- a/src/lib/value.c +++ b/src/lib/value.c @@ -590,6 +590,8 @@ struct bt_value *bt_value_bool_create_init(bt_bool val) { struct bt_value_bool *bool_obj; + BT_ASSERT_PRE_NO_ERROR(); + BT_LOGD("Creating boolean value object: val=%d", val); bool_obj = g_new0(struct bt_value_bool, 1); if (!bool_obj) { @@ -608,6 +610,8 @@ struct bt_value *bt_value_bool_create_init(bt_bool val) struct bt_value *bt_value_bool_create(void) { + BT_ASSERT_PRE_NO_ERROR(); + return bt_value_bool_create_init(BT_FALSE); } @@ -647,23 +651,31 @@ struct bt_value *bt_value_integer_create_init(enum bt_value_type type, struct bt_value *bt_value_integer_unsigned_create_init(uint64_t val) { + BT_ASSERT_PRE_NO_ERROR(); + return bt_value_integer_create_init(BT_VALUE_TYPE_UNSIGNED_INTEGER, val); } struct bt_value *bt_value_integer_unsigned_create(void) { + BT_ASSERT_PRE_NO_ERROR(); + return bt_value_integer_unsigned_create_init(0); } struct bt_value *bt_value_integer_signed_create_init(int64_t val) { + BT_ASSERT_PRE_NO_ERROR(); + return bt_value_integer_create_init(BT_VALUE_TYPE_SIGNED_INTEGER, (uint64_t) val); } struct bt_value *bt_value_integer_signed_create(void) { + BT_ASSERT_PRE_NO_ERROR(); + return bt_value_integer_signed_create_init(0); } @@ -671,6 +683,8 @@ struct bt_value *bt_value_real_create_init(double val) { struct bt_value_real *real_obj; + BT_ASSERT_PRE_NO_ERROR(); + BT_LOGD("Creating real number value object: val=%f", val); real_obj = g_new0(struct bt_value_real, 1); if (!real_obj) { @@ -690,6 +704,8 @@ struct bt_value *bt_value_real_create_init(double val) struct bt_value *bt_value_real_create(void) { + BT_ASSERT_PRE_NO_ERROR(); + return bt_value_real_create_init(0.); } @@ -697,7 +713,9 @@ struct bt_value *bt_value_string_create_init(const char *val) { struct bt_value_string *string_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(val, "Value"); + BT_LOGD("Creating string value object: val-len=%zu", strlen(val)); string_obj = g_new0(struct bt_value_string, 1); if (!string_obj) { @@ -725,6 +743,8 @@ struct bt_value *bt_value_string_create_init(const char *val) struct bt_value *bt_value_string_create(void) { + BT_ASSERT_PRE_NO_ERROR(); + return bt_value_string_create_init(""); } @@ -732,6 +752,8 @@ struct bt_value *bt_value_array_create(void) { struct bt_value_array *array_obj; + BT_ASSERT_PRE_NO_ERROR(); + BT_LOGD_STR("Creating empty array value object."); array_obj = g_new0(struct bt_value_array, 1); if (!array_obj) { @@ -761,6 +783,8 @@ struct bt_value *bt_value_map_create(void) { struct bt_value_map *map_obj; + BT_ASSERT_PRE_NO_ERROR(); + BT_LOGD_STR("Creating empty map value object."); map_obj = g_new0(struct bt_value_map, 1); if (!map_obj) { @@ -872,6 +896,7 @@ const char *bt_value_string_get(const struct bt_value *string_obj) enum bt_value_string_set_status bt_value_string_set( struct bt_value *string_obj, const char *val) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(string_obj, "Value object"); BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_VALUE_TYPE_STRING); BT_ASSERT_PRE_DEV_VALUE_HOT(string_obj, "Value object"); @@ -915,6 +940,7 @@ enum bt_value_array_append_element_status bt_value_array_append_element( struct bt_value_array *typed_array_obj = BT_VALUE_TO_ARRAY(array_obj); + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object"); BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object"); BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY); @@ -933,6 +959,8 @@ bt_value_array_append_bool_element(struct bt_value *array_obj, bt_bool val) enum bt_value_array_append_element_status ret; struct bt_value *bool_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + bool_obj = bt_value_bool_create_init(val); ret = bt_value_array_append_element(array_obj, (void *) bool_obj); @@ -947,6 +975,8 @@ bt_value_array_append_unsigned_integer_element(struct bt_value *array_obj, enum bt_value_array_append_element_status ret; struct bt_value *integer_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + integer_obj = bt_value_integer_unsigned_create_init(val); ret = bt_value_array_append_element(array_obj, (void *) integer_obj); @@ -961,6 +991,8 @@ bt_value_array_append_signed_integer_element(struct bt_value *array_obj, enum bt_value_array_append_element_status ret; struct bt_value *integer_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + integer_obj = bt_value_integer_signed_create_init(val); ret = bt_value_array_append_element(array_obj, (void *) integer_obj); @@ -974,6 +1006,8 @@ bt_value_array_append_real_element(struct bt_value *array_obj, double val) enum bt_value_array_append_element_status ret; struct bt_value *real_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + real_obj = bt_value_real_create_init(val); ret = bt_value_array_append_element(array_obj, (void *) real_obj); @@ -988,6 +1022,8 @@ bt_value_array_append_string_element(struct bt_value *array_obj, enum bt_value_array_append_element_status ret; struct bt_value *string_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + string_obj = bt_value_string_create_init(val); ret = bt_value_array_append_element(array_obj, (void *) string_obj); @@ -1002,6 +1038,8 @@ bt_value_array_append_empty_array_element(struct bt_value *array_obj, enum bt_value_array_append_element_status ret; struct bt_value *empty_array_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + empty_array_obj = bt_value_array_create(); ret = bt_value_array_append_element(array_obj, (void *) empty_array_obj); @@ -1021,6 +1059,8 @@ bt_value_array_append_empty_map_element(struct bt_value *array_obj, enum bt_value_array_append_element_status ret; struct bt_value *map_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + map_obj = bt_value_map_create(); ret = bt_value_array_append_element(array_obj, (void *) map_obj); @@ -1040,6 +1080,7 @@ bt_value_array_set_element_by_index(struct bt_value *array_obj, uint64_t index, struct bt_value_array *typed_array_obj = BT_VALUE_TO_ARRAY(array_obj); + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object"); BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object"); BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY); @@ -1090,6 +1131,7 @@ enum bt_value_map_insert_entry_status bt_value_map_insert_entry( struct bt_value *map_obj, const char *key, struct bt_value *element_obj) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(map_obj, "Map value object"); BT_ASSERT_PRE_NON_NULL(key, "Key"); BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object"); @@ -1110,6 +1152,8 @@ enum bt_value_map_insert_entry_status bt_value_map_insert_bool_entry( enum bt_value_map_insert_entry_status ret; struct bt_value *bool_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + bool_obj = bt_value_bool_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, (void *) bool_obj); @@ -1124,6 +1168,8 @@ bt_value_map_insert_unsigned_integer_entry(struct bt_value *map_obj, enum bt_value_map_insert_entry_status ret; struct bt_value *integer_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + integer_obj = bt_value_integer_unsigned_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, (void *) integer_obj); @@ -1138,6 +1184,8 @@ bt_value_map_insert_signed_integer_entry(struct bt_value *map_obj, enum bt_value_map_insert_entry_status ret; struct bt_value *integer_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + integer_obj = bt_value_integer_signed_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, (void *) integer_obj); @@ -1151,6 +1199,8 @@ enum bt_value_map_insert_entry_status bt_value_map_insert_real_entry( enum bt_value_map_insert_entry_status ret; struct bt_value *real_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + real_obj = bt_value_real_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, (void *) real_obj); @@ -1165,6 +1215,8 @@ enum bt_value_map_insert_entry_status bt_value_map_insert_string_entry( enum bt_value_map_insert_entry_status ret; struct bt_value *string_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + string_obj = bt_value_string_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, (void *) string_obj); @@ -1180,6 +1232,8 @@ bt_value_map_insert_empty_array_entry( enum bt_value_map_insert_entry_status ret; struct bt_value *array_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + array_obj = bt_value_array_create(); ret = bt_value_map_insert_entry(map_obj, key, (void *) array_obj); @@ -1199,6 +1253,8 @@ bt_value_map_insert_empty_map_entry(struct bt_value *map_obj, const char *key, enum bt_value_map_insert_entry_status ret; struct bt_value *empty_map_obj = NULL; + BT_ASSERT_PRE_NO_ERROR(); + empty_map_obj = bt_value_map_create(); ret = bt_value_map_insert_entry(map_obj, key, (void *) empty_map_obj); @@ -1220,6 +1276,8 @@ enum bt_value_map_foreach_entry_status bt_value_map_foreach_entry( GHashTableIter iter; struct bt_value_map *typed_map_obj = BT_VALUE_TO_MAP(map_obj); + BT_ASSERT_PRE_NO_ERROR(); + BT_ASSERT_PRE_DEV_NON_NULL(map_obj, "Value object"); BT_ASSERT_PRE_DEV_NON_NULL(func, "Callback"); BT_ASSERT_PRE_DEV_VALUE_IS_TYPE(map_obj, BT_VALUE_TYPE_MAP); @@ -1244,6 +1302,8 @@ enum bt_value_map_foreach_entry_const_status bt_value_map_foreach_entry_const( const struct bt_value *map_obj, bt_value_map_foreach_entry_const_func func, void *data) { + BT_ASSERT_PRE_NO_ERROR(); + return (int) bt_value_map_foreach_entry((void *) map_obj, (bt_value_map_foreach_entry_func) func, data); } @@ -1305,6 +1365,7 @@ enum bt_value_map_extend_status bt_value_map_extend( .status = BT_FUNC_STATUS_OK, }; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object"); BT_ASSERT_PRE_DEV_VALUE_HOT(base_map_obj, "Base value object"); BT_ASSERT_PRE_NON_NULL(extension_obj, "Extension value object"); @@ -1334,6 +1395,7 @@ enum bt_value_copy_status bt_value_copy(const struct bt_value *object, { enum bt_value_copy_status status = BT_FUNC_STATUS_OK; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(object, "Value object"); BT_ASSERT_PRE_NON_NULL(copy_obj, "Value object copy (output)"); BT_LOGD("Copying value object: addr=%p", object);