lib: add missing MIP checks in bit array flag functions
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 22 Oct 2024 20:18:30 +0000 (16:18 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Nov 2024 16:17:44 +0000 (11:17 -0500)
Add some MIP checks, it seems like an oversight that these functions
don't have them.

I think that functions `bt_field_class_bit_array_flag_get_label()` and
`bt_field_class_bit_array_flag_borrow_index_ranges_const()` don't need
such checks, because it's not possible to get hold of a
`bt_field_class_bit_array_flag *` without going through function that
has the appropriate MIP check before.

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

index 32cc4a0e5f460493a7ccef8ae95ec1a10ac6bbb7..3b1eda2d733c441aaf1b5a316f2845fe889d7985 100644 (file)
@@ -180,6 +180,7 @@ uint64_t bt_field_class_bit_array_get_flag_count(const bt_field_class *fc)
        const struct bt_field_class_bit_array *ba_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_DEV_FC_MIP_VERSION_GE(fc, 1);
        BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "bit-array",
                BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field class");
        return ba_fc->flags->len;
@@ -199,6 +200,7 @@ bt_field_class_bit_array_add_flag_status bt_field_class_bit_array_add_flag(
 
        BT_ASSERT_PRE_NO_ERROR();
        BT_ASSERT_PRE_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_FC_MIP_VERSION_GE(fc, 1);
        BT_ASSERT_PRE_FC_HAS_TYPE("field-class", fc, "bit-array",
                BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field class");
        BT_ASSERT_PRE_NON_NULL("label", label, "Label");
@@ -271,6 +273,7 @@ bt_field_class_bit_array_borrow_flag_by_index_const(
        struct bt_field_class_bit_array *ba_fc = (void *) fc;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_DEV_FC_MIP_VERSION_GE(fc, 1);
        BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "bit-array",
                BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field class");
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, ba_fc->flags->len);
@@ -287,6 +290,7 @@ bt_field_class_bit_array_borrow_flag_by_label_const(
        uint64_t i;
 
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_DEV_FC_MIP_VERSION_GE(fc, 1);
        BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "bit-array",
                BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field class");
        BT_ASSERT_PRE_DEV_NON_NULL("label", label, "Label");
@@ -316,6 +320,7 @@ bt_field_class_bit_array_get_active_flag_labels_for_value_as_integer(
 
        BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_FC_NON_NULL(fc);
+       BT_ASSERT_PRE_DEV_FC_MIP_VERSION_GE(fc, 1);
        BT_ASSERT_PRE_DEV_FC_HAS_TYPE("field-class", fc, "bit-array",
                BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field class");
        BT_ASSERT_PRE_DEV_NON_NULL("label-array-output", label_array,
This page took 0.026113 seconds and 4 git commands to generate.