lib: make message iterator creation functions return a status
[babeltrace.git] / src / plugins / utils / counter / counter.c
index db269e78e636b9b39d7df57167a35edb48cdea1a..bf0e4a575f03d99499c84051889f4009a38dfba0 100644 (file)
@@ -23,7 +23,7 @@
 #define BT_COMP_LOG_SELF_COMP (counter->self_comp)
 #define BT_LOG_OUTPUT_LEVEL (counter->log_level)
 #define BT_LOG_TAG "PLUGIN/FLT.UTILS.COUNTER"
-#include "plugins/comp-logging.h"
+#include "logging/comp-logging.h"
 
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
@@ -53,8 +53,6 @@ uint64_t get_total_count(struct counter *counter)
        return counter->count.event +
                counter->count.stream_begin +
                counter->count.stream_end +
-               counter->count.stream_activity_begin +
-               counter->count.stream_activity_end +
                counter->count.packet_begin +
                counter->count.packet_end +
                counter->count.disc_events +
@@ -71,8 +69,6 @@ void print_count(struct counter *counter)
        PRINTF_COUNT("Event", event);
        PRINTF_COUNT("Stream beginning", stream_begin);
        PRINTF_COUNT("Stream end", stream_end);
-       PRINTF_COUNT("Stream activity beginning", stream_activity_begin);
-       PRINTF_COUNT("Stream activity end", stream_activity_end);
        PRINTF_COUNT("Packet beginning", packet_begin);
        PRINTF_COUNT("Packet end", packet_end);
        PRINTF_COUNT("Discarded event", disc_events);
@@ -118,8 +114,11 @@ void try_print_last(struct counter *counter)
 
 void destroy_private_counter_data(struct counter *counter)
 {
-       bt_self_component_port_input_message_iterator_put_ref(counter->msg_iter);
-       g_free(counter);
+       if (counter) {
+               bt_self_component_port_input_message_iterator_put_ref(
+                       counter->msg_iter);
+               g_free(counter);
+       }
 }
 
 BT_HIDDEN
@@ -182,7 +181,7 @@ bt_component_class_init_method_status counter_init(
                        goto error;
                }
 
-               counter->step = bt_value_unsigned_integer_get(step);
+               counter->step = bt_value_integer_unsigned_get(step);
        }
 
        hide_zero = bt_value_map_borrow_entry_value_const(params, "hide-zero");
@@ -218,25 +217,28 @@ bt_component_class_sink_graph_is_configured_method_status
 counter_graph_is_configured(
                bt_self_component_sink *comp)
 {
-       bt_component_class_sink_graph_is_configured_method_status status =
-               BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
+       bt_component_class_sink_graph_is_configured_method_status status;
+       bt_self_component_port_input_message_iterator_create_from_sink_component_status
+               msg_iter_status;
        struct counter *counter;
        bt_self_component_port_input_message_iterator *iterator;
 
        counter = bt_self_component_get_data(
                bt_self_component_sink_as_self_component(comp));
        BT_ASSERT(counter);
-       iterator = bt_self_component_port_input_message_iterator_create(
-               bt_self_component_sink_borrow_input_port_by_name(comp,
-                       in_port_name));
-       if (!iterator) {
-               status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR;
+
+       msg_iter_status = bt_self_component_port_input_message_iterator_create_from_sink_component(
+               comp, bt_self_component_sink_borrow_input_port_by_name(comp,
+                       in_port_name), &iterator);
+       if (msg_iter_status != BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_OK) {
+               status = (int) msg_iter_status;
                goto end;
        }
 
        BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_MOVE_REF(
                counter->msg_iter, iterator);
 
+       status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
 end:
        return status;
 }
@@ -298,12 +300,6 @@ bt_component_class_sink_consume_method_status counter_consume(
                        case BT_MESSAGE_TYPE_STREAM_END:
                                counter->count.stream_end++;
                                break;
-                       case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
-                               counter->count.stream_activity_begin++;
-                               break;
-                       case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
-                               counter->count.stream_activity_end++;
-                               break;
                        case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
                                counter->count.disc_events++;
                                break;
This page took 0.023988 seconds and 4 git commands to generate.