X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Ftrace-ir%2Ffield.c;h=37e6731ecd4b35d31bde09beb073118bb7683472;hb=79545cc9503203b8508867244ef0265257fd3e84;hp=b554248611dcafcf0ae2bd9fb9538b1a1482bfd7;hpb=c4f23e30bf67d2523163614bc9461d84cbe1ae80;p=babeltrace.git diff --git a/src/lib/trace-ir/field.c b/src/lib/trace-ir/field.c index b5542486..37e6731e 100644 --- a/src/lib/trace-ir/field.c +++ b/src/lib/trace-ir/field.c @@ -1,32 +1,15 @@ /* + * SPDX-License-Identifier: MIT + * * Copyright 2017-2018 Philippe Proulx * Copyright 2013, 2014 Jérémie Galarneau - * - * 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 -#include #include "lib/object.h" #include "compat/compiler.h" #include "compat/fcntl.h" @@ -272,7 +255,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) { @@ -797,6 +780,7 @@ bt_field_enumeration_unsigned_get_mapping_labels( { const struct bt_field_integer *int_field = (const void *) field; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)"); @@ -816,6 +800,7 @@ bt_field_enumeration_signed_get_mapping_labels( { const struct bt_field_integer *int_field = (const void *) field; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)"); BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)"); @@ -862,6 +847,7 @@ 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_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_NON_NULL(value, "Value"); BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field"); @@ -875,6 +861,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)); } @@ -886,6 +874,7 @@ enum bt_field_string_append_status bt_field_string_append_with_length( char *data; uint64_t new_length; + BT_ASSERT_PRE_DEV_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_NON_NULL(value, "Value"); BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field"); @@ -935,6 +924,7 @@ 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_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(field, "Field"); BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field"); @@ -1137,7 +1127,7 @@ 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"); @@ -1146,7 +1136,7 @@ bt_field_variant_borrow_selected_class_option_const( } 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"); @@ -1156,7 +1146,7 @@ bt_field_variant_with_unsigned_integer_selector_borrow_selected_class_option_con } 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"); @@ -1165,12 +1155,13 @@ bt_field_variant_with_signed_integer_selector_borrow_selected_class_option_const 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_NO_ERROR(); BT_ASSERT_PRE_DEV_NON_NULL(field, "Field"); BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field"); BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field"); @@ -1180,7 +1171,7 @@ bt_field_variant_select_option_field_by_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; @@ -1365,7 +1356,7 @@ void bt_field_destroy(struct bt_field *field) destroy_variant_field(field); break; default: - abort(); + bt_common_abort(); } }