lib: internal: replace BT_ASSERT_PRE* -> BT_ASSERT_POST* where applicable
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jun 2019 20:44:25 +0000 (16:44 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 29 Jun 2019 06:04:08 +0000 (02:04 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8acc12b771a7d4040bc136d5860311fc7646295f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1575
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/lib/graph/component.c
src/lib/graph/graph.c
src/lib/graph/graph.h
src/lib/graph/iterator.c
src/lib/graph/query-executor.c

index cf6d40c183d8fe0bbc0258dbd102f5051a8df087..90129b073d46429f8f3a2f6d337f10b61a686fe5 100644 (file)
@@ -27,6 +27,7 @@
 #include "common/common.h"
 #include "common/assert.h"
 #include "lib/assert-pre.h"
+#include "lib/assert-post.h"
 #include <babeltrace2/graph/self-component.h>
 #include <babeltrace2/graph/component-const.h>
 #include <babeltrace2/graph/component-source-const.h>
@@ -551,7 +552,7 @@ enum bt_self_component_status bt_component_port_connected(
                status = method(comp, self_port, (void *) other_port);
                BT_LOGD("User method returned: status=%s",
                        bt_self_component_status_string(status));
-               BT_ASSERT_PRE(status == BT_SELF_COMPONENT_STATUS_OK ||
+               BT_ASSERT_POST(status == BT_SELF_COMPONENT_STATUS_OK ||
                        status == BT_SELF_COMPONENT_STATUS_ERROR ||
                        status == BT_SELF_COMPONENT_STATUS_NOMEM,
                        "Unexpected returned component status: status=%s",
index 7301d23dc64761360a9d13a167fd7049012bdd8e..62175cf98b8413eb59be2dd3b5399ac983ce0595 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "common/assert.h"
 #include "lib/assert-pre.h"
+#include "lib/assert-post.h"
 #include <babeltrace2/graph/graph.h>
 #include <babeltrace2/graph/graph-const.h>
 #include <babeltrace2/graph/component-source-const.h>
@@ -538,7 +539,7 @@ enum bt_graph_status consume_graph_sink(struct bt_component_sink *comp)
        comp_status = sink_class->methods.consume((void *) comp);
        BT_LOGD("User method returned: status=%s",
                bt_self_component_status_string(comp_status));
-       BT_ASSERT_PRE(comp_status == BT_SELF_COMPONENT_STATUS_OK ||
+       BT_ASSERT_POST(comp_status == BT_SELF_COMPONENT_STATUS_OK ||
                comp_status == BT_SELF_COMPONENT_STATUS_END ||
                comp_status == BT_SELF_COMPONENT_STATUS_AGAIN ||
                comp_status == BT_SELF_COMPONENT_STATUS_ERROR ||
index b3b178c647bf4e9ae9b49aa2af3bab96067b9762..f22b5800c7fe2bc2bc441a1156ba2242ea3f58ec 100644 (file)
@@ -256,8 +256,8 @@ enum bt_graph_status bt_graph_configure(struct bt_graph *graph)
                                bt_self_component_status_string(comp_status));
 #endif
 
-#ifdef BT_ASSERT_PRE
-                       BT_ASSERT_PRE(comp_status == BT_SELF_COMPONENT_STATUS_OK ||
+#ifdef BT_ASSERT_POST
+                       BT_ASSERT_POST(comp_status == BT_SELF_COMPONENT_STATUS_OK ||
                                comp_status == BT_SELF_COMPONENT_STATUS_ERROR ||
                                comp_status == BT_SELF_COMPONENT_STATUS_NOMEM,
                                "Unexpected returned status: status=%s",
index 08a49cfeee34136967256f7cbb2e4848e07692af..db8fa5375a2fda8ca45a95d2f3acc0f7d2f03a03 100644 (file)
@@ -58,6 +58,7 @@
 #include <babeltrace2/types.h>
 #include "common/assert.h"
 #include "lib/assert-pre.h"
+#include "lib/assert-post.h"
 #include <stdint.h>
 #include <inttypes.h>
 #include <stdlib.h>
@@ -535,7 +536,7 @@ void bt_self_message_iterator_set_data(
  * time.
  */
 
-BT_ASSERT_PRE_FUNC
+BT_ASSERT_POST_FUNC
 static
 bool clock_snapshots_are_monotonic_one(
                struct bt_self_component_port_input_message_iterator *iterator,
@@ -614,7 +615,7 @@ end:
        return result;
 }
 
-BT_ASSERT_PRE_FUNC
+BT_ASSERT_POST_FUNC
 static
 bool clock_snapshots_are_monotonic(
                struct bt_self_component_port_input_message_iterator *iterator,
@@ -641,7 +642,7 @@ end:
  * stream is compatible with what we've seen before.
  */
 
-BT_ASSERT_PRE_FUNC
+BT_ASSERT_POST_FUNC
 static
 bool clock_classes_are_compatible_one(struct bt_self_component_port_input_message_iterator *iterator,
                const struct bt_message *msg)
@@ -681,7 +682,7 @@ bool clock_classes_are_compatible_one(struct bt_self_component_port_input_messag
 
                case CLOCK_EXPECTATION_NONE:
                        if (clock_class) {
-                               BT_ASSERT_PRE_MSG("Expecting no clock class, got one: %![cc-]+K",
+                               BT_ASSERT_POST_MSG("Expecting no clock class, got one: %![cc-]+K",
                                        clock_class);
                                result = false;
                                goto end;
@@ -691,13 +692,13 @@ bool clock_classes_are_compatible_one(struct bt_self_component_port_input_messag
 
                case CLOCK_EXPECTATION_ORIGIN_UNIX:
                        if (!clock_class) {
-                               BT_ASSERT_PRE_MSG("Expecting a clock class, got none.");
+                               BT_ASSERT_POST_MSG("Expecting a clock class, got none.");
                                result = false;
                                goto end;
                        }
 
                        if (!bt_clock_class_origin_is_unix_epoch(clock_class)) {
-                               BT_ASSERT_PRE_MSG("Expecting a clock class with Unix epoch origin: %![cc-]+K",
+                               BT_ASSERT_POST_MSG("Expecting a clock class with Unix epoch origin: %![cc-]+K",
                                        clock_class);
                                result = false;
                                goto end;
@@ -706,27 +707,27 @@ bool clock_classes_are_compatible_one(struct bt_self_component_port_input_messag
 
                case CLOCK_EXPECTATION_ORIGIN_OTHER_UUID:
                        if (!clock_class) {
-                               BT_ASSERT_PRE_MSG("Expecting a clock class, got none.");
+                               BT_ASSERT_POST_MSG("Expecting a clock class, got none.");
                                result = false;
                                goto end;
                        }
 
                        if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
-                               BT_ASSERT_PRE_MSG("Expecting a clock class without Unix epoch origin: %![cc-]+K",
+                               BT_ASSERT_POST_MSG("Expecting a clock class without Unix epoch origin: %![cc-]+K",
                                        clock_class);
                                result = false;
                                goto end;
                        }
 
                        if (!clock_class_uuid) {
-                               BT_ASSERT_PRE_MSG("Expecting a clock class with UUID: %![cc-]+K",
+                               BT_ASSERT_POST_MSG("Expecting a clock class with UUID: %![cc-]+K",
                                        clock_class);
                                result = false;
                                goto end;
                        }
 
                        if (bt_uuid_compare(iterator->clock_expectation.uuid, clock_class_uuid)) {
-                               BT_ASSERT_PRE_MSG("Expecting a clock class with UUID, got one "
+                               BT_ASSERT_POST_MSG("Expecting a clock class with UUID, got one "
                                        "with a different UUID: %![cc-]+K, expected-uuid=%!u",
                                        clock_class, iterator->clock_expectation.uuid);
                                result = false;
@@ -736,20 +737,20 @@ bool clock_classes_are_compatible_one(struct bt_self_component_port_input_messag
 
                case CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID:
                        if (!clock_class) {
-                               BT_ASSERT_PRE_MSG("Expecting a clock class, got none.");
+                               BT_ASSERT_POST_MSG("Expecting a clock class, got none.");
                                result = false;
                                goto end;
                        }
 
                        if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
-                               BT_ASSERT_PRE_MSG("Expecting a clock class without Unix epoch origin: %![cc-]+K",
+                               BT_ASSERT_POST_MSG("Expecting a clock class without Unix epoch origin: %![cc-]+K",
                                        clock_class);
                                result = false;
                                goto end;
                        }
 
                        if (clock_class_uuid) {
-                               BT_ASSERT_PRE_MSG("Expecting a clock class without UUID: %![cc-]+K",
+                               BT_ASSERT_POST_MSG("Expecting a clock class without UUID: %![cc-]+K",
                                        clock_class);
                                result = false;
                                goto end;
@@ -764,7 +765,7 @@ end:
        return result;
 }
 
-BT_ASSERT_PRE_FUNC
+BT_ASSERT_POST_FUNC
 static
 bool clock_classes_are_compatible(
                struct bt_self_component_port_input_message_iterator *iterator,
@@ -800,13 +801,14 @@ bt_message_iterator_status call_iterator_next_method(
 
        BT_ASSERT(iterator->methods.next);
        BT_LOGD_STR("Calling user's \"next\" method.");
-
        status = iterator->methods.next(iterator, msgs, capacity, user_count);
+       BT_LOGD("User method returned: status=%s, msg-count=%" PRIu64,
+               bt_message_iterator_status_string(status), *user_count);
 
        if (status == BT_MESSAGE_ITERATOR_STATUS_OK) {
-               BT_ASSERT_PRE(clock_classes_are_compatible(iterator, msgs, *user_count),
+               BT_ASSERT_POST(clock_classes_are_compatible(iterator, msgs, *user_count),
                        "Clocks are not compatible");
-               BT_ASSERT_PRE(clock_snapshots_are_monotonic(iterator, msgs, *user_count),
+               BT_ASSERT_POST(clock_snapshots_are_monotonic(iterator, msgs, *user_count),
                        "Clock snapshots are not monotonic");
        }
 
@@ -846,8 +848,6 @@ bt_self_component_port_input_message_iterator_next(
        status = call_iterator_next_method(iterator,
                (void *) iterator->base.msgs->pdata, MSG_BATCH_SIZE,
                user_count);
-       BT_LOGD("User method returned: status=%s, msg-count=%" PRIu64,
-               bt_message_iterator_status_string(status), *user_count);
        if (status < 0) {
                BT_LOGW_STR("User method failed.");
                goto end;
@@ -867,7 +867,7 @@ bt_self_component_port_input_message_iterator_next(
 
        switch (status) {
        case BT_MESSAGE_ITERATOR_STATUS_OK:
-               BT_ASSERT_PRE(*user_count <= MSG_BATCH_SIZE,
+               BT_ASSERT_POST(*user_count <= MSG_BATCH_SIZE,
                        "Invalid returned message count: greater than "
                        "batch size: count=%" PRIu64 ", batch-size=%u",
                        *user_count, MSG_BATCH_SIZE);
@@ -1243,7 +1243,7 @@ bt_self_component_port_input_message_iterator_seek_beginning(
        status = iterator->methods.seek_beginning(iterator);
        BT_LOGD("User method returned: status=%s",
                bt_message_iterator_status_string(status));
-       BT_ASSERT_PRE(status == BT_MESSAGE_ITERATOR_STATUS_OK ||
+       BT_ASSERT_POST(status == BT_MESSAGE_ITERATOR_STATUS_OK ||
                status == BT_MESSAGE_ITERATOR_STATUS_ERROR ||
                status == BT_MESSAGE_ITERATOR_STATUS_NOMEM ||
                status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
@@ -1346,7 +1346,7 @@ enum bt_message_iterator_status auto_seek_handle_message(
                        (const void *) msg;
 
                clk_snapshot = event_msg->default_cs;
-               BT_ASSERT_PRE(clk_snapshot,
+               BT_ASSERT_POST(clk_snapshot,
                        "Event message has no default clock snapshot: %!+n",
                        event_msg);
                break;
@@ -1367,7 +1367,7 @@ enum bt_message_iterator_status auto_seek_handle_message(
                        (const void *) msg;
 
                clk_snapshot = packet_msg->default_cs;
-               BT_ASSERT_PRE(clk_snapshot,
+               BT_ASSERT_POST(clk_snapshot,
                        "Packet message has no default clock snapshot: %!+n",
                        packet_msg);
                break;
@@ -1378,7 +1378,7 @@ enum bt_message_iterator_status auto_seek_handle_message(
                struct bt_message_discarded_items *msg_disc_items =
                        (void *) msg;
 
-               BT_ASSERT_PRE(msg_disc_items->default_begin_cs &&
+               BT_ASSERT_POST(msg_disc_items->default_begin_cs &&
                        msg_disc_items->default_end_cs,
                        "Discarded events/packets message has no default clock snapshots: %!+n",
                        msg_disc_items);
@@ -1658,8 +1658,6 @@ enum bt_message_iterator_status find_message_ge_ns_from_origin(
                 */
                status = call_iterator_next_method(iterator,
                        &messages[0], MSG_BATCH_SIZE, &user_count);
-               BT_LOGD("User method returned: status=%s",
-                       bt_message_iterator_status_string(status));
 
                /*
                 * The user's "next" method must not do any action which
@@ -1670,7 +1668,7 @@ enum bt_message_iterator_status find_message_ge_ns_from_origin(
 
                switch (status) {
                case BT_MESSAGE_ITERATOR_STATUS_OK:
-                       BT_ASSERT_PRE(user_count <= MSG_BATCH_SIZE,
+                       BT_ASSERT_POST(user_count <= MSG_BATCH_SIZE,
                                "Invalid returned message count: greater than "
                                "batch size: count=%" PRIu64 ", batch-size=%u",
                                user_count, MSG_BATCH_SIZE);
@@ -1804,7 +1802,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin(
                        ns_from_origin);
                BT_LOGD("User method returned: status=%s",
                        bt_message_iterator_status_string(status));
-               BT_ASSERT_PRE(status == BT_MESSAGE_ITERATOR_STATUS_OK ||
+               BT_ASSERT_POST(status == BT_MESSAGE_ITERATOR_STATUS_OK ||
                        status == BT_MESSAGE_ITERATOR_STATUS_ERROR ||
                        status == BT_MESSAGE_ITERATOR_STATUS_NOMEM ||
                        status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
@@ -1823,7 +1821,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin(
                status = iterator->methods.seek_beginning(iterator);
                BT_LOGD("User method returned: status=%s",
                        bt_message_iterator_status_string(status));
-               BT_ASSERT_PRE(status == BT_MESSAGE_ITERATOR_STATUS_OK ||
+               BT_ASSERT_POST(status == BT_MESSAGE_ITERATOR_STATUS_OK ||
                        status == BT_MESSAGE_ITERATOR_STATUS_ERROR ||
                        status == BT_MESSAGE_ITERATOR_STATUS_NOMEM ||
                        status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
index 6d5334453b9aff444a06ff2d5a1441041424648d..59c44f7b89be4920e2fc6231652a1decaeb4ed53 100644 (file)
@@ -26,6 +26,7 @@
 #include "common/assert.h"
 #include "common/common.h"
 #include "lib/assert-pre.h"
+#include "lib/assert-post.h"
 #include <babeltrace2/graph/query-executor-const.h>
 #include <babeltrace2/graph/query-executor.h>
 #include <babeltrace2/graph/component-class.h>
@@ -134,7 +135,7 @@ enum bt_query_executor_status bt_query_executor_query(
                log_level, user_result);
        BT_LIB_LOGD("User method returned: status=%s, %![res-]+v",
                bt_query_status_string(status), *user_result);
-       BT_ASSERT_PRE(status != BT_QUERY_STATUS_OK || *user_result,
+       BT_ASSERT_POST(status != BT_QUERY_STATUS_OK || *user_result,
                "User method returned `BT_QUERY_STATUS_OK` without a result.");
        exec_status = (int) status;
        if (query_exec->canceled) {
This page took 0.031505 seconds and 4 git commands to generate.