lib: use common precond. assert. macros from `assert-cond.h` thru lib
[babeltrace.git] / src / lib / trace-ir / field.c
index 0b8529b28be98afe61ea70c7e3fbe07c6a3c81a7..b1d8486761c10fa690a9724ea97e6e07cd74f128 100644 (file)
@@ -1,43 +1,31 @@
 /*
+ * SPDX-License-Identifier: MIT
+ *
  * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
  * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #define BT_LOG_TAG "LIB/FIELD"
 #include "lib/logging.h"
 
-#include "lib/assert-pre.h"
+#include "lib/assert-cond.h"
 #include <babeltrace2/trace-ir/field.h>
-#include <babeltrace2/trace-ir/field-const.h>
 #include "lib/object.h"
 #include "compat/compiler.h"
 #include "compat/fcntl.h"
 #include "common/align.h"
 #include "common/assert.h"
 #include <inttypes.h>
+#include <stdbool.h>
 
 #include "field.h"
 #include "field-class.h"
 #include "lib/func-status.h"
 
+#define BT_ASSERT_PRE_DEV_FIELD_HOT(_field)                            \
+       BT_ASSERT_PRE_DEV_HOT((const struct bt_field *) (_field),       \
+               "Field", ": %!+f", (_field))
+
 static
 void reset_single_field(struct bt_field *field);
 
@@ -205,20 +193,20 @@ void destroy_variant_field(struct bt_field *field);
 
 struct bt_field_class *bt_field_borrow_class(struct bt_field *field)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        return field->class;
 }
 
 const struct bt_field_class *bt_field_borrow_class_const(
                const struct bt_field *field)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        return field->class;
 }
 
 enum bt_field_class_type bt_field_get_class_type(const struct bt_field *field)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        return field->class->type;
 }
 
@@ -271,7 +259,7 @@ struct bt_field *bt_field_create(struct bt_field_class *fc)
                field = create_variant_field(fc);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        if (!field) {
@@ -636,8 +624,8 @@ bt_bool bt_field_bool_get_value(const struct bt_field *field)
 {
        const struct bt_field_bool *bool_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_BOOL,
                "Field");
        return (bt_bool) bool_field->value;
@@ -647,10 +635,10 @@ void bt_field_bool_set_value(struct bt_field *field, bt_bool value)
 {
        struct bt_field_bool *bool_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_BOOL,
                "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        bool_field->value = (bool) value;
        bt_field_set_single(field, true);
 }
@@ -659,8 +647,8 @@ uint64_t bt_field_bit_array_get_value_as_integer(const struct bt_field *field)
 {
        const struct bt_field_bit_array *ba_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
        return ba_field->value_as_int;
@@ -672,10 +660,10 @@ void bt_field_bit_array_set_value_as_integer(struct bt_field *field,
        struct bt_field_bit_array *ba_field = (void *) field;
        struct bt_field_class_bit_array *ba_fc;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        ba_fc = (void *) field->class;
        ba_field->value_as_int = value;
 
@@ -691,8 +679,8 @@ int64_t bt_field_integer_signed_get_value(const struct bt_field *field)
 {
        const struct bt_field_integer *int_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(field, "Field");
        return int_field->value.i;
 }
@@ -701,9 +689,9 @@ void bt_field_integer_signed_set_value(struct bt_field *field, int64_t value)
 {
        struct bt_field_integer *int_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        BT_ASSERT_PRE_DEV(bt_util_value_is_in_range_signed(
                ((struct bt_field_class_integer *) field->class)->range, value),
                "Value is out of bounds: value=%" PRId64 ", %![field-]+f, "
@@ -716,8 +704,8 @@ uint64_t bt_field_integer_unsigned_get_value(const struct bt_field *field)
 {
        const struct bt_field_integer *int_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(field, "Field");
        return int_field->value.u;
 }
@@ -726,9 +714,9 @@ void bt_field_integer_unsigned_set_value(struct bt_field *field, uint64_t value)
 {
        struct bt_field_integer *int_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        BT_ASSERT_PRE_DEV(bt_util_value_is_in_range_unsigned(
                ((struct bt_field_class_integer *) field->class)->range, value),
                "Value is out of bounds: value=%" PRIu64 ", %![field-]+f, "
@@ -741,8 +729,8 @@ float bt_field_real_single_precision_get_value(const struct bt_field *field)
 {
        const struct bt_field_real *real_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, "Field");
        return (float) real_field->value;
@@ -752,8 +740,8 @@ double bt_field_real_double_precision_get_value(const struct bt_field *field)
 {
        const struct bt_field_real *real_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, "Field");
 
@@ -765,10 +753,10 @@ void bt_field_real_single_precision_set_value(struct bt_field *field,
 {
        struct bt_field_real *real_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
 
        real_field->value = (double) value;
        bt_field_set_single(field, true);
@@ -779,10 +767,10 @@ void bt_field_real_double_precision_set_value(struct bt_field *field,
 {
        struct bt_field_real *real_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
 
        real_field->value = value;
        bt_field_set_single(field, true);
@@ -796,10 +784,11 @@ bt_field_enumeration_unsigned_get_mapping_labels(
 {
        const struct bt_field_integer *int_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_NO_ERROR();
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
        BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, "Field");
        return (int)
@@ -815,10 +804,11 @@ bt_field_enumeration_signed_get_mapping_labels(
 {
        const struct bt_field_integer *int_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_NO_ERROR();
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
        BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, "Field");
        return (int)
@@ -830,8 +820,8 @@ const char *bt_field_string_get_value(const struct bt_field *field)
 {
        const struct bt_field_string *string_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
                "Field");
        return (const char *) string_field->buf->data;
@@ -841,8 +831,8 @@ uint64_t bt_field_string_get_length(const struct bt_field *field)
 {
        const struct bt_field_string *string_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+       BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
                "Field");
        return string_field->length;
@@ -853,7 +843,7 @@ void clear_string_field(struct bt_field *field)
 {
        struct bt_field_string *string_field = (void *) field;
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        string_field->length = 0;
        bt_field_set_single(field, true);
 }
@@ -861,9 +851,10 @@ void clear_string_field(struct bt_field *field)
 enum bt_field_string_set_value_status bt_field_string_set_value(
                struct bt_field *field, const char *value)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_NO_ERROR();
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_NON_NULL(value, "Value");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
                "Field");
        clear_string_field(field);
@@ -874,6 +865,8 @@ enum bt_field_string_set_value_status bt_field_string_set_value(
 enum bt_field_string_append_status bt_field_string_append(
                struct bt_field *field, const char *value)
 {
+       BT_ASSERT_PRE_DEV_NO_ERROR();
+
        return bt_field_string_append_with_length(field,
                value, (uint64_t) strlen(value));
 }
@@ -885,9 +878,10 @@ enum bt_field_string_append_status bt_field_string_append_with_length(
        char *data;
        uint64_t new_length;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_NO_ERROR();
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_NON_NULL(value, "Value");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_STRING, "Field");
 
@@ -912,8 +906,8 @@ enum bt_field_string_append_status bt_field_string_append_with_length(
 
 void bt_field_string_clear(struct bt_field *field)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_STRING, "Field");
        clear_string_field(field);
@@ -923,7 +917,7 @@ uint64_t bt_field_array_get_length(const struct bt_field *field)
 {
        const struct bt_field_array *array_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(field, "Field");
        return array_field->length;
 }
@@ -934,9 +928,10 @@ enum bt_field_array_dynamic_set_length_status bt_field_array_dynamic_set_length(
        int ret = BT_FUNC_STATUS_OK;
        struct bt_field_array *array_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_NO_ERROR();
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
 
        if (G_UNLIKELY(length > array_field->fields->len)) {
                /* Make more room */
@@ -961,7 +956,7 @@ enum bt_field_array_dynamic_set_length_status bt_field_array_dynamic_set_length(
                                goto end;
                        }
 
-                       BT_ASSERT(!array_field->fields->pdata[i]);
+                       BT_ASSERT_DBG(!array_field->fields->pdata[i]);
                        array_field->fields->pdata[i] = elem_field;
                }
        }
@@ -978,7 +973,7 @@ struct bt_field *borrow_array_field_element_field_by_index(
 {
        struct bt_field_array *array_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(field, "Field");
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, array_field->length);
        return array_field->fields->pdata[index];
@@ -1003,7 +998,7 @@ struct bt_field *borrow_structure_field_member_field_by_index(
 {
        struct bt_field_structure *struct_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, struct_field->fields->len);
@@ -1035,7 +1030,7 @@ struct bt_field *borrow_structure_field_member_field_by_name(
        gpointer orig_key;
        gpointer index;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_NON_NULL(name, "Field name");
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
@@ -1047,7 +1042,7 @@ struct bt_field *borrow_structure_field_member_field_by_name(
        }
 
        ret_field = struct_field->fields->pdata[GPOINTER_TO_UINT(index)];
-       BT_ASSERT(ret_field);
+       BT_ASSERT_DBG(ret_field);
 
 end:
        return ret_field;
@@ -1070,9 +1065,9 @@ void bt_field_option_set_has_field(struct bt_field *field, bt_bool has_field)
 {
        struct bt_field_option *opt_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
 
        if (has_field) {
                opt_field->selected_field = opt_field->content_field;
@@ -1085,7 +1080,7 @@ struct bt_field *bt_field_option_borrow_field(struct bt_field *field)
 {
        struct bt_field_option *opt_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(field, "Field");
        return opt_field->selected_field;
 }
@@ -1102,7 +1097,7 @@ struct bt_field *borrow_variant_field_selected_option_field(
 {
        struct bt_field_variant *var_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
        BT_ASSERT_PRE_DEV(var_field->selected_field,
                "Variant field has no selected field: %!+f", field);
@@ -1128,7 +1123,7 @@ borrow_variant_field_selected_class_option(const struct bt_field *field)
        const struct bt_field_class_named_field_class_container *container_fc;
        const struct bt_field_variant *var_field = (const void *) field;
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_ASSERT_PRE_DEV(var_field->selected_field,
                "Variant field has no selected field: %!+f", field);
        container_fc = (const void *) field->class;
@@ -1136,55 +1131,56 @@ borrow_variant_field_selected_class_option(const struct bt_field *field)
 }
 
 const struct bt_field_class_variant_option *
-bt_field_variant_borrow_selected_class_option_const(
+bt_field_variant_borrow_selected_option_class_const(
                const struct bt_field *field)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
        return borrow_variant_field_selected_class_option(field);
 }
 
 const struct bt_field_class_variant_with_selector_field_integer_unsigned_option *
-bt_field_variant_with_unsigned_integer_selector_borrow_selected_class_option_const(
+bt_field_variant_with_selector_field_integer_unsigned_borrow_selected_option_class_const(
                const struct bt_field *field)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD, "Field");
        return (const void *) borrow_variant_field_selected_class_option(field);
 }
 
 const struct bt_field_class_variant_with_selector_field_integer_signed_option *
-bt_field_variant_with_signed_integer_selector_borrow_selected_class_option_const(
+bt_field_variant_with_selector_field_integer_signed_borrow_selected_option_class_const(
                const struct bt_field *field)
 {
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
                BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, "Field");
        return (const void *) borrow_variant_field_selected_class_option(field);
 }
 
-enum bt_field_variant_select_option_field_by_index_status
-bt_field_variant_select_option_field_by_index(
+enum bt_field_variant_select_option_by_index_status
+bt_field_variant_select_option_by_index(
                struct bt_field *field, uint64_t index)
 {
        struct bt_field_variant *var_field = (void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_NO_ERROR();
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
-       BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_HOT(field);
        BT_ASSERT_PRE_DEV_VALID_INDEX(index, var_field->fields->len);
        var_field->selected_field = var_field->fields->pdata[index];
        var_field->selected_index = index;
        return BT_FUNC_STATUS_OK;
 }
 
-uint64_t bt_field_variant_get_selected_option_field_index(
+uint64_t bt_field_variant_get_selected_option_index(
                const struct bt_field *field)
 {
        const struct bt_field_variant *var_field = (const void *) field;
 
-       BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+       BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
        BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
        BT_ASSERT_PRE_DEV(var_field->selected_field,
                "Variant field has no selected field: %!+f", field);
@@ -1364,14 +1360,14 @@ void bt_field_destroy(struct bt_field *field)
                destroy_variant_field(field);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 }
 
 static
 void reset_single_field(struct bt_field *field)
 {
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        field->is_set = false;
 }
 
@@ -1381,7 +1377,7 @@ void reset_structure_field(struct bt_field *field)
        uint64_t i;
        struct bt_field_structure *struct_field = (void *) field;
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
 
        for (i = 0; i < struct_field->fields->len; i++) {
                bt_field_reset(struct_field->fields->pdata[i]);
@@ -1393,7 +1389,7 @@ void reset_option_field(struct bt_field *field)
 {
        struct bt_field_option *opt_field = (void *) field;
 
-       BT_ASSERT(opt_field);
+       BT_ASSERT_DBG(opt_field);
        bt_field_reset(opt_field->content_field);
        opt_field->selected_field = NULL;
 }
@@ -1404,7 +1400,7 @@ void reset_variant_field(struct bt_field *field)
        uint64_t i;
        struct bt_field_variant *var_field = (void *) field;
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
 
        for (i = 0; i < var_field->fields->len; i++) {
                bt_field_reset(var_field->fields->pdata[i]);
@@ -1417,7 +1413,7 @@ void reset_array_field(struct bt_field *field)
        uint64_t i;
        struct bt_field_array *array_field = (void *) field;
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
 
        for (i = 0; i < array_field->fields->len; i++) {
                bt_field_reset(array_field->fields->pdata[i]);
@@ -1508,17 +1504,17 @@ BT_HIDDEN
 void _bt_field_set_is_frozen(const struct bt_field *field,
                bool is_frozen)
 {
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_LIB_LOGD("Setting field object's frozen state: %!+f, is-frozen=%d",
                field, is_frozen);
-       BT_ASSERT(field->methods->set_is_frozen);
+       BT_ASSERT_DBG(field->methods->set_is_frozen);
        field->methods->set_is_frozen((void *) field, is_frozen);
 }
 
 static
 bool single_field_is_set(const struct bt_field *field)
 {
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        return field->is_set;
 }
 
@@ -1529,7 +1525,7 @@ bool structure_field_is_set(const struct bt_field *field)
        uint64_t i;
        const struct bt_field_structure *struct_field = (const void *) field;
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
 
        for (i = 0; i < struct_field->fields->len; i++) {
                is_set = bt_field_is_set(struct_field->fields->pdata[i]);
@@ -1548,7 +1544,7 @@ bool option_field_is_set(const struct bt_field *field)
        const struct bt_field_option *opt_field = (const void *) field;
        bool is_set = false;
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
 
        if (opt_field->selected_field) {
                is_set = bt_field_is_set(opt_field->selected_field);
@@ -1563,7 +1559,7 @@ bool variant_field_is_set(const struct bt_field *field)
        const struct bt_field_variant *var_field = (const void *) field;
        bool is_set = false;
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
 
        if (var_field->selected_field) {
                is_set = bt_field_is_set(var_field->selected_field);
@@ -1579,7 +1575,7 @@ bool array_field_is_set(const struct bt_field *field)
        uint64_t i;
        const struct bt_field_array *array_field = (const void *) field;
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
 
        for (i = 0; i < array_field->length; i++) {
                is_set = bt_field_is_set(array_field->fields->pdata[i]);
This page took 0.034246 seconds and 4 git commands to generate.