X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Futils%2Fcounter%2Fcounter.c;h=0ef6b8200483a43ea56261b7252835562e022588;hb=c6a7ea93dbe7b3ff25f3b22a1cc53fc8a63acd98;hp=be03014d69ecdef9f8be4ea615fabbc51e6d4d7b;hpb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;p=babeltrace.git diff --git a/src/plugins/utils/counter/counter.c b/src/plugins/utils/counter/counter.c index be03014d..0ef6b820 100644 --- a/src/plugins/utils/counter/counter.c +++ b/src/plugins/utils/counter/counter.c @@ -108,7 +108,6 @@ void destroy_private_counter_data(struct counter *counter) } } -BT_HIDDEN void counter_finalize(bt_self_component_sink *comp) { struct counter *counter; @@ -129,12 +128,11 @@ struct bt_param_validation_map_value_entry_descr counter_params[] = { BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END }; -BT_HIDDEN bt_component_class_initialize_method_status counter_init( bt_self_component_sink *component, - bt_self_component_sink_configuration *config, + bt_self_component_sink_configuration *config __attribute__((unused)), const bt_value *params, - __attribute__((unused)) void *init_method_data) + void *init_method_data __attribute__((unused))) { bt_component_class_initialize_method_status status; bt_self_component_add_port_status add_port_status; @@ -199,7 +197,6 @@ end: return status; } -BT_HIDDEN bt_component_class_sink_graph_is_configured_method_status counter_graph_is_configured( bt_self_component_sink *comp) @@ -230,34 +227,23 @@ end: return status; } -BT_HIDDEN bt_component_class_sink_consume_method_status counter_consume( bt_self_component_sink *comp) { - bt_component_class_sink_consume_method_status status = - BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; struct counter *counter; bt_message_iterator_next_status next_status; uint64_t msg_count; bt_message_array_const msgs; + bt_self_component *self_comp = + bt_self_component_sink_as_self_component(comp); - counter = bt_self_component_get_data( - bt_self_component_sink_as_self_component(comp)); + counter = bt_self_component_get_data(self_comp); BT_ASSERT_DBG(counter); - - if (G_UNLIKELY(!counter->msg_iter)) { - try_print_last(counter); - status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END; - goto end; - } + BT_ASSERT_DBG(counter->msg_iter); /* Consume messages */ next_status = bt_message_iterator_next( counter->msg_iter, &msgs, &msg_count); - if (next_status < 0) { - status = (int) next_status; - goto end; - } switch (next_status) { case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK: @@ -300,25 +286,20 @@ bt_component_class_sink_consume_method_status counter_consume( bt_message_put_ref(msg); } - status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; + try_print_count(counter, msg_count); break; } - case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN: - status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN; - goto end; case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: try_print_last(counter); - status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END; - goto end; + break; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR: case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR: - status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR; - goto end; + BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT(self_comp, + "Failed to get messages from upstream component"); + break; default: break; } - try_print_count(counter, msg_count); - -end: - return status; + return (int) next_status; }