Notification iterator: transform precondition checks to BT_ASSERT_PRE()
[babeltrace.git] / plugins / text / pretty / pretty.c
index 4ac6ad6d5c20c5558483d3e5540019313e36c67b..8b5ecd2c63a14bbd1681da21bde951c338b763f1 100644 (file)
  * SOFTWARE.
  */
 
-#include <babeltrace/plugin/plugin-dev.h>
-#include <babeltrace/graph/component.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/private-component-sink.h>
-#include <babeltrace/graph/component-sink.h>
-#include <babeltrace/graph/port.h>
-#include <babeltrace/graph/private-port.h>
-#include <babeltrace/graph/connection.h>
-#include <babeltrace/graph/private-connection.h>
-#include <babeltrace/graph/notification.h>
-#include <babeltrace/graph/notification-iterator.h>
-#include <babeltrace/graph/notification-event.h>
+#include <babeltrace/babeltrace.h>
 #include <babeltrace/values.h>
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/common-internal.h>
@@ -46,7 +35,7 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <glib.h>
-#include <assert.h>
+#include <babeltrace/assert-internal.h>
 
 #include "pretty.h"
 
@@ -142,7 +131,7 @@ enum bt_component_status handle_notification(struct pretty_component *pretty,
 {
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
 
-       assert(pretty);
+       BT_ASSERT(pretty);
 
        switch (bt_notification_get_type(notification)) {
        case BT_NOTIFICATION_TYPE_EVENT:
@@ -151,17 +140,12 @@ enum bt_component_status handle_notification(struct pretty_component *pretty,
        case BT_NOTIFICATION_TYPE_INACTIVITY:
                fprintf(stderr, "Inactivity notification\n");
                break;
-       case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
-       case BT_NOTIFICATION_TYPE_PACKET_END:
-       case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
-       case BT_NOTIFICATION_TYPE_STREAM_END:
-               break;
        case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS:
        case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS:
                ret = pretty_print_discarded_elements(pretty, notification);
                break;
        default:
-               fprintf(stderr, "Unhandled notification type\n");
+               break;
        }
 
        return ret;
@@ -176,20 +160,14 @@ void pretty_port_connected(
        enum bt_connection_status conn_status;
        struct bt_private_connection *connection;
        struct pretty_component *pretty;
-       static const enum bt_notification_type notif_types[] = {
-               BT_NOTIFICATION_TYPE_EVENT,
-               BT_NOTIFICATION_TYPE_DISCARDED_PACKETS,
-               BT_NOTIFICATION_TYPE_DISCARDED_EVENTS,
-               BT_NOTIFICATION_TYPE_SENTINEL,
-       };
 
        pretty = bt_private_component_get_user_data(component);
-       assert(pretty);
-       assert(!pretty->input_iterator);
+       BT_ASSERT(pretty);
+       BT_ASSERT(!pretty->input_iterator);
        connection = bt_private_port_get_private_connection(self_port);
-       assert(connection);
+       BT_ASSERT(connection);
        conn_status = bt_private_connection_create_notification_iterator(
-               connection, notif_types, &pretty->input_iterator);
+               connection, &pretty->input_iterator);
        if (conn_status != BT_CONNECTION_STATUS_OK) {
                pretty->error = true;
        }
@@ -231,7 +209,7 @@ enum bt_component_status pretty_consume(struct bt_private_component *component)
        }
 
        notification = bt_notification_iterator_get_notification(it);
-       assert(notification);
+       BT_ASSERT(notification);
        ret = handle_notification(pretty, notification);
 
 end:
This page took 0.026233 seconds and 4 git commands to generate.