lib: adjust son dev/non-dev precondition assertions in field-class.c
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 17 Feb 2022 04:10:29 +0000 (23:10 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 12:31:28 +0000 (08:31 -0400)
I found some functions using BT_ASSERT_PRE_DEV_FC_NON_NULL followed by
either BT_ASSERT_PRE_FC_HAS_TYPE or BT_ASSERT_PRE_FC_IS_STRUCT (i.e. a
dev followed by a non-dev).  This seems illogical to me.  Either the
function is considered "fast path" and we use the dev versions, either
it's not "fast path" and we use the non-dev versions.

Change a few assertions to be dev.  If some of these functions aren't
actually considered fast path, then I think we should switch the
BT_ASSERT_PRE_DEV_FC_NON_NULLs to be non-dev.

Change-Id: I4f0c1cb0ef1006beddcc688d4e71f37fdb561e15
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7326
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/lib/trace-ir/field-class.c

index 2a9230252243ba1aec674cf23078ceea8f99b055..a92ed060f8eb4018fe8283a00e599d2959630f97 100644 (file)
@@ -1046,7 +1046,7 @@ uint64_t bt_field_class_structure_get_member_count(
        struct bt_field_class_structure *struct_fc = (void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_STRUCT("field-class", fc, "Field class");
        return (uint64_t) struct_fc->common.named_fcs->len;
 }
 
@@ -1067,7 +1067,7 @@ bt_field_class_structure_borrow_member_by_index_const(
                const struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_STRUCT("field-class", fc, "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_at_index(
                        (void *) fc, index, __func__);
@@ -1078,7 +1078,7 @@ bt_field_class_structure_borrow_member_by_index(
                struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_STRUCT("field-class", fc, "Field class");
        return (void *)
                borrow_named_field_class_from_container_field_class_at_index(
                        (void *) fc, index, __func__);
@@ -1112,7 +1112,7 @@ bt_field_class_structure_borrow_member_by_name_const(
                const struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_STRUCT("field-class", fc, "Field class");
        return (const void *)
                borrow_named_field_class_from_container_field_class_by_name(
                        (void *) fc, name, __func__);
@@ -1123,7 +1123,7 @@ bt_field_class_structure_borrow_member_by_name(
                struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_IS_STRUCT("field-class", fc, "Field class");
+       BT_ASSERT_PRE_DEV_FC_IS_STRUCT("field-class", fc, "Field class");
        return (void *)
                borrow_named_field_class_from_container_field_class_by_name(
                        (void *) fc, name, __func__);
@@ -1827,7 +1827,7 @@ bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_nam
                const struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc,
                "variant-field-class-with-unsigned-integer-selector-field",
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
                "Field class");
@@ -1841,7 +1841,7 @@ bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_ind
                const struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc,
                "variant-field-class-with-unsigned-integer-selector-field",
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
                "Field class");
@@ -1855,7 +1855,7 @@ bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_
                const struct bt_field_class *fc, const char *name)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc,
                "variant-field-class-with-signed-integer-selector-field",
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
                "Field class");
@@ -1869,7 +1869,7 @@ bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index
                const struct bt_field_class *fc, uint64_t index)
 {
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc,
                "variant-field-class-with-signed-integer-selector-field",
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
                "Field class");
@@ -2042,7 +2042,7 @@ uint64_t bt_field_class_array_static_get_length(const struct bt_field_class *fc)
        const struct bt_field_class_array_static *array_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
-       BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc,
+       BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc,
                "static-array-field-class", BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
                "Field class");
        return (uint64_t) array_fc->length;
This page took 0.031289 seconds and 5 git commands to generate.