Fix: unused-variable warnings in lib/graph/iterator.c
[babeltrace.git] / lib / graph / iterator.c
index 5cfda703252e185f1cb4646f844909ba8ab055f2..1e02eb33c5eff3613ae6809a4d2c7322749cf205 100644 (file)
@@ -97,7 +97,7 @@ void _set_self_comp_port_input_msg_iterator_state(
 #ifdef BT_DEV_MODE
 # define set_self_comp_port_input_msg_iterator_state _set_self_comp_port_input_msg_iterator_state
 #else
-# define set_self_comp_port_input_msg_iterator_state(_a, _b)
+# define set_self_comp_port_input_msg_iterator_state(_a, _b) ((void) _a); ((void) _b);
 #endif
 
 static
@@ -526,39 +526,6 @@ void bt_self_message_iterator_set_data(
                "%!+i, user-data-addr=%p", iterator, data);
 }
 
-BT_ASSERT_PRE_FUNC
-static inline
-void bt_message_borrow_packet_stream(const struct bt_message *msg,
-               const struct bt_stream **stream,
-               const struct bt_packet **packet)
-{
-       BT_ASSERT(msg);
-
-       switch (msg->type) {
-       case BT_MESSAGE_TYPE_EVENT:
-               *packet = bt_event_borrow_packet_const(
-                       bt_message_event_borrow_event_const(msg));
-               *stream = bt_packet_borrow_stream_const(*packet);
-               break;
-       case BT_MESSAGE_TYPE_STREAM_BEGINNING:
-               *stream = bt_message_stream_beginning_borrow_stream_const(msg);
-               break;
-       case BT_MESSAGE_TYPE_STREAM_END:
-               *stream = bt_message_stream_end_borrow_stream_const(msg);
-               break;
-       case BT_MESSAGE_TYPE_PACKET_BEGINNING:
-               *packet = bt_message_packet_beginning_borrow_packet_const(msg);
-               *stream = bt_packet_borrow_stream_const(*packet);
-               break;
-       case BT_MESSAGE_TYPE_PACKET_END:
-               *packet = bt_message_packet_end_borrow_packet_const(msg);
-               *stream = bt_packet_borrow_stream_const(*packet);
-               break;
-       default:
-               break;
-       }
-}
-
 enum bt_message_iterator_status
 bt_self_component_port_input_message_iterator_next(
                struct bt_self_component_port_input_message_iterator *iterator,
@@ -750,6 +717,8 @@ bt_port_output_message_iterator_create(struct bt_graph *graph,
                (void *) graph,
                "Output port is not part of graph: %![graph-]+g, %![port-]+p",
                graph, output_port);
+       BT_ASSERT_PRE(!graph->has_sink,
+               "Graph already has a sink component: %![graph-]+g");
 
        /* Create message iterator */
        BT_LIB_LOGD("Creating message iterator on output port: "
@@ -944,7 +913,7 @@ void _set_iterator_state_after_seeking(
 #ifdef BT_DEV_MODE
 # define set_iterator_state_after_seeking      _set_iterator_state_after_seeking
 #else
-# define set_iterator_state_after_seeking(_iter, _status)
+# define set_iterator_state_after_seeking(_iter, _status) ((void) _iter); ((void) _status);
 #endif
 
 enum bt_message_iterator_status
@@ -975,7 +944,7 @@ bt_self_component_port_input_message_iterator_seek_beginning(
                status == BT_MESSAGE_ITERATOR_STATUS_NOMEM ||
                status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
                "Unexpected status: %![iter-]+i, status=%s",
-               iterator, bt_self_message_iterator_status_string(status));
+               iterator, bt_common_self_message_iterator_status_string(status));
        set_iterator_state_after_seeking(iterator, status);
        return status;
 }
@@ -1169,6 +1138,7 @@ enum bt_message_iterator_status auto_seek_handle_message(
 
 skip_msg:
        bt_object_put_no_null_check(msg);
+       msg = NULL;
        goto end;
 
 push_msg:
@@ -1205,7 +1175,7 @@ enum bt_message_iterator_status find_message_ge_ns_from_origin(
 
        BT_ASSERT(iterator->methods.next);
 
-       while (true) {
+       while (!got_first) {
                /*
                 * Call the user's "next" method to get the next
                 * messages and status.
@@ -1252,7 +1222,7 @@ enum bt_message_iterator_status find_message_ge_ns_from_origin(
                        status = auto_seek_handle_message(iterator,
                                ns_from_origin, messages[i], &got_first);
                        if (status == BT_MESSAGE_ITERATOR_STATUS_OK) {
-                               /* Message was either put or moved */
+                               /* Message was either pushed or moved */
                                messages[i] = NULL;
                        } else {
                                goto end;
@@ -1358,7 +1328,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin(
                        status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
                        "Unexpected status: %![iter-]+i, status=%s",
                        iterator,
-                       bt_self_message_iterator_status_string(status));
+                       bt_common_self_message_iterator_status_string(status));
        } else {
                /* Start automatic seeking: seek beginning first */
                BT_ASSERT(iterator->methods.can_seek_beginning(iterator));
@@ -1374,7 +1344,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin(
                        status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
                        "Unexpected status: %![iter-]+i, status=%s",
                        iterator,
-                       bt_self_message_iterator_status_string(status));
+                       bt_common_self_message_iterator_status_string(status));
                switch (status) {
                case BT_MESSAGE_ITERATOR_STATUS_OK:
                        break;
This page took 0.024867 seconds and 4 git commands to generate.