From: Simon Marchi Date: Tue, 22 Oct 2024 20:18:30 +0000 (-0400) Subject: lib: add missing MIP checks in bit array flag functions X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=c52941f11843997d8c1679442d517c28db4aa153;p=babeltrace.git lib: add missing MIP checks in bit array flag functions 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 Reviewed-on: https://review.lttng.org/c/babeltrace/+/13397 Reviewed-by: Philippe Proulx --- diff --git a/src/lib/trace-ir/field-class.c b/src/lib/trace-ir/field-class.c index 32cc4a0e..3b1eda2d 100644 --- a/src/lib/trace-ir/field-class.c +++ b/src/lib/trace-ir/field-class.c @@ -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,