lib: add `size >= 1` pre-condition to bt_field_class_integer_set_field_value_range
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 9 Apr 2020 19:32:13 +0000 (15:32 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 10 Apr 2020 19:31:04 +0000 (15:31 -0400)
An integer of 0 bits is not very useful.

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

index 4e1505c68ab5ac4c2413cacd448af5cebe965877..078e0080db1907e3c52aa52ac1c0773e0e4f2bda 100644 (file)
@@ -1737,7 +1737,7 @@ See the \ref api-tir-fc-int-prop-size "field value range" property.
 @bt_pre_hot{field_class}
 @bt_pre_is_int_fc{field_class}
 @pre
-    \bt_p{n} ⩽ 64.
+    1 ⩽ \bt_p{n} ⩽ 64.
 
 @sa bt_field_class_integer_get_field_value_range() &mdash;
     Returns the field value range of an integer field class.
index 316d6e4d6166f54dd64457237a541ce36a8a7dc6..00a7cd3ca8afc749ecef899b714433d5cbc467d6 100644 (file)
@@ -261,9 +261,9 @@ void bt_field_class_integer_set_field_value_range(
        BT_ASSERT_PRE_NON_NULL(fc, "Field class");
        BT_ASSERT_PRE_FC_IS_INT(fc, "Field class");
        BT_ASSERT_PRE_DEV_FC_HOT(fc, "Field class");
-       BT_ASSERT_PRE(size <= 64,
+       BT_ASSERT_PRE(size >= 1 && size <= 64,
                "Unsupported size for integer field class's field value range "
-               "(maximum is 64): size=%" PRIu64, size);
+               "(minimum is 1, maximum is 64): size=%" PRIu64, size);
        BT_ASSERT_PRE(
                int_fc->common.type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER ||
                int_fc->common.type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER ||
This page took 0.027863 seconds and 4 git commands to generate.