lib, plugins: use bt_field_class_type_is() where suitable
[babeltrace.git] / src / plugins / lttng-utils / debug-info / trace-ir-metadata-field-class-copy.c
index c7680c8d962e24733b5d2c43ff8bd5c3affae8ed..f149281ab46898fa5bc6218b9bc1189e56d8cd9d 100644 (file)
@@ -51,7 +51,7 @@ const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
 
        BT_ASSERT(bt_field_class_get_type(fc) == BT_FIELD_CLASS_TYPE_STRUCTURE);
        BT_COMP_LOGD("Walking field path on field class: fp-addr=%p, fc-addr=%p",
-                       fp, fc);
+               fp, fc);
 
        fp_item_count = bt_field_path_get_item_count(fp);
        curr_fc = fc;
@@ -60,9 +60,7 @@ const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
                const bt_field_path_item *fp_item =
                        bt_field_path_borrow_item_by_index_const(fp, i);
 
-               switch (fc_type) {
-               case BT_FIELD_CLASS_TYPE_STRUCTURE:
-               {
+               if (fc_type == BT_FIELD_CLASS_TYPE_STRUCTURE) {
                        const bt_field_class_structure_member *member;
 
                        BT_ASSERT(bt_field_path_item_get_type(fp_item) ==
@@ -72,23 +70,13 @@ const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
                                bt_field_path_item_index_get_index(fp_item));
                        curr_fc = bt_field_class_structure_member_borrow_field_class_const(
                                member);
-                       break;
-               }
-               case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
-               case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
-               case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR:
-               case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR:
-               {
+               } else if (bt_field_class_type_is(fc_type, BT_FIELD_CLASS_TYPE_OPTION)) {
                        BT_ASSERT(bt_field_path_item_get_type(fp_item) ==
                                BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT);
                        curr_fc = bt_field_class_option_borrow_field_class_const(
                                curr_fc);
-                       break;
-               }
-               case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
-               case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
-               case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
-               {
+
+               } else if (bt_field_class_type_is(fc_type, BT_FIELD_CLASS_TYPE_VARIANT)) {
                        const bt_field_class_variant_option *option;
 
                        BT_ASSERT(bt_field_path_item_get_type(fp_item) ==
@@ -99,17 +87,13 @@ const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
                        curr_fc = bt_field_class_variant_option_borrow_field_class_const(
                                option);
                        break;
-               }
-               case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-               case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
-               {
+               } else if (bt_field_class_type_is(fc_type, BT_FIELD_CLASS_TYPE_ARRAY)) {
                        BT_ASSERT(bt_field_path_item_get_type(fp_item) ==
                                BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT);
                        curr_fc = bt_field_class_array_borrow_element_field_class_const(
                                curr_fc);
                        break;
-               }
-               default:
+               } else {
                        abort();
                }
        }
@@ -159,23 +143,24 @@ void field_class_integer_set_props(const bt_field_class *input_fc,
                bt_field_class *output_fc)
 {
        bt_field_class_integer_set_preferred_display_base(output_fc,
-                       bt_field_class_integer_get_preferred_display_base(input_fc));
+               bt_field_class_integer_get_preferred_display_base(input_fc));
        bt_field_class_integer_set_field_value_range(output_fc,
-                       bt_field_class_integer_get_field_value_range(input_fc));
+               bt_field_class_integer_get_field_value_range(input_fc));
 }
 
 static inline
-int field_class_bool_copy(
-               struct trace_ir_metadata_maps *md_maps,
+int field_class_bool_copy(struct trace_ir_metadata_maps *md_maps,
                const bt_field_class *in_field_class,
                bt_field_class *out_field_class)
 {
        BT_COMP_LOGD("Copying content of boolean field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
+       /*
+        * There is no content to copy. Keep this function call anyway for
+        * logging purposes.
+        */
        BT_COMP_LOGD("Copied content of boolean field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
        return 0;
 }
 
@@ -186,11 +171,13 @@ int field_class_bit_array_copy(
                bt_field_class *out_field_class)
 {
        BT_COMP_LOGD("Copying content of bit array field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
+       /*
+        * There is no content to copy. Keep this function call anyway for
+        * logging purposes.
+        */
        BT_COMP_LOGD("Copied content of bit array field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
        return 0;
 }
 
@@ -201,14 +188,12 @@ int field_class_unsigned_integer_copy(
                bt_field_class *out_field_class)
 {
        BT_COMP_LOGD("Copying content of unsigned integer field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
        field_class_integer_set_props(in_field_class, out_field_class);
 
        BT_COMP_LOGD("Copied content of unsigned integer field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
        return 0;
 }
 
@@ -219,14 +204,12 @@ int field_class_signed_integer_copy(
                bt_field_class *out_field_class)
 {
        BT_COMP_LOGD("Copying content of signed integer field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
        field_class_integer_set_props(in_field_class, out_field_class);
 
        BT_COMP_LOGD("Copied content of signed integer field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
        return 0;
 }
 
@@ -240,14 +223,14 @@ int field_class_unsigned_enumeration_copy(
        int ret = 0;
 
        BT_COMP_LOGD("Copying content of unsigned enumeration field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
        /* Copy properties of the inner integer. */
        field_class_integer_set_props(in_field_class, out_field_class);
 
        /* Copy all enumeration entries. */
-       enum_mapping_count = bt_field_class_enumeration_get_mapping_count(in_field_class);
+       enum_mapping_count = bt_field_class_enumeration_get_mapping_count(
+               in_field_class);
        for (i = 0; i < enum_mapping_count; i++) {
                const char *label;
                const bt_integer_range_set_unsigned *range_set;
@@ -255,7 +238,7 @@ int field_class_unsigned_enumeration_copy(
                const bt_field_class_enumeration_mapping *mapping;
 
                u_mapping = bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
-                               in_field_class, i);
+                       in_field_class, i);
                mapping = bt_field_class_enumeration_unsigned_mapping_as_mapping_const(
                        u_mapping);
                label = bt_field_class_enumeration_mapping_get_label(mapping);
@@ -269,8 +252,7 @@ int field_class_unsigned_enumeration_copy(
        }
 
        BT_COMP_LOGD("Copied content of unsigned enumeration field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
 error:
        return ret;
@@ -286,8 +268,7 @@ int field_class_signed_enumeration_copy(
        int ret = 0;
 
        BT_COMP_LOGD("Copying content of signed enumeration field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
        /* Copy properties of the inner integer. */
        field_class_integer_set_props(in_field_class, out_field_class);
@@ -302,7 +283,7 @@ int field_class_signed_enumeration_copy(
                const bt_field_class_enumeration_mapping *mapping;
 
                s_mapping = bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
-                               in_field_class, i);
+                       in_field_class, i);
                mapping = bt_field_class_enumeration_signed_mapping_as_mapping_const(
                        s_mapping);
                label = bt_field_class_enumeration_mapping_get_label(mapping);
@@ -316,8 +297,7 @@ int field_class_signed_enumeration_copy(
        }
 
        BT_COMP_LOGD("Copied content of signed enumeration field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
 error:
        return ret;
@@ -363,8 +343,7 @@ int field_class_structure_copy(
        int ret = 0;
 
        BT_COMP_LOGD("Copying content of structure field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
        /* Get the number of member in that struct. */
        struct_member_count =
                bt_field_class_structure_get_member_count(in_field_class);
@@ -383,16 +362,14 @@ int field_class_structure_copy(
                        in_member);
                member_name = bt_field_class_structure_member_get_name(in_member);
                BT_COMP_LOGD("Copying structure field class's field: "
-                       "index=%" PRId64 ", "
-                       "member-fc-addr=%p, field-name=\"%s\"",
+                       "index=%" PRId64 ", member-fc-addr=%p, field-name=\"%s\"",
                        i, in_member_fc, member_name);
 
                out_member_field_class = create_field_class_copy(md_maps,
                                in_member_fc);
                if (!out_member_field_class) {
                        BT_COMP_LOGE("Cannot copy structure field class's field: "
-                               "index=%" PRId64 ", "
-                               "field-fc-addr=%p, field-name=\"%s\"",
+                               "index=%" PRId64 ", field-fc-addr=%p, field-name=\"%s\"",
                                i, in_member_fc, member_name);
                        ret = -1;
                        goto error;
@@ -448,8 +425,7 @@ int field_class_variant_copy(
        int ret = 0;
 
        BT_COMP_LOGD("Copying content of variant field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
        variant_option_count =
                bt_field_class_variant_get_option_count(in_field_class);
        for (i = 0; i < variant_option_count; i++) {
@@ -472,54 +448,54 @@ int field_class_variant_copy(
                        goto error;
                }
                ret = copy_field_class_content_internal(md_maps, in_option_fc,
-                               out_option_field_class);
+                       out_option_field_class);
                if (ret) {
                        BT_COMP_LOGE_STR("Error copying content of option variant "
                                        "field class'");
                        goto error;
                }
 
-               if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR) {
-                       const bt_field_class_variant_with_selector_unsigned_option *spec_opt =
-                               bt_field_class_variant_with_selector_unsigned_borrow_option_by_index_const(
+               if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD) {
+                       const bt_field_class_variant_with_selector_field_integer_unsigned_option *spec_opt =
+                               bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(
                                        in_field_class, i);
                        const bt_integer_range_set_unsigned *ranges =
-                               bt_field_class_variant_with_selector_unsigned_option_borrow_ranges_const(
+                               bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const(
                                        spec_opt);
 
-                       if (bt_field_class_variant_with_selector_unsigned_append_option(
+                       if (bt_field_class_variant_with_selector_field_integer_unsigned_append_option(
                                        out_field_class, option_name,
                                        out_option_field_class, ranges) !=
-                                       BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_APPEND_OPTION_STATUS_OK) {
-                               BT_COMP_LOGE_STR("Cannot append option to variant field class with unsigned selector'");
+                                       BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK) {
+                               BT_COMP_LOGE_STR("Cannot append option to variant field class with unsigned integer selector'");
                                BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class);
                                ret = -1;
                                goto error;
                        }
-               } else if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR) {
-                       const bt_field_class_variant_with_selector_signed_option *spec_opt =
-                               bt_field_class_variant_with_selector_signed_borrow_option_by_index_const(
+               } else if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) {
+                       const bt_field_class_variant_with_selector_field_integer_signed_option *spec_opt =
+                               bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(
                                        in_field_class, i);
                        const bt_integer_range_set_signed *ranges =
-                               bt_field_class_variant_with_selector_signed_option_borrow_ranges_const(
+                               bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const(
                                        spec_opt);
 
-                       if (bt_field_class_variant_with_selector_signed_append_option(
+                       if (bt_field_class_variant_with_selector_field_integer_signed_append_option(
                                        out_field_class, option_name,
                                        out_option_field_class, ranges) !=
-                                       BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_APPEND_OPTION_STATUS_OK) {
-                               BT_COMP_LOGE_STR("Cannot append option to variant field class with signed selector'");
+                                       BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK) {
+                               BT_COMP_LOGE_STR("Cannot append option to variant field class with signed integer selector'");
                                BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class);
                                ret = -1;
                                goto error;
                        }
                } else {
-                       BT_ASSERT(fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR);
+                       BT_ASSERT(fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD);
 
                        if (bt_field_class_variant_without_selector_append_option(
                                        out_field_class, option_name,
                                        out_option_field_class) !=
-                                       BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_APPEND_OPTION_STATUS_OK) {
+                                       BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK) {
                                BT_COMP_LOGE_STR("Cannot append option to variant field class'");
                                BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class);
                                ret = -1;
@@ -555,13 +531,13 @@ int field_class_static_array_copy(
                bt_field_class *out_field_class)
 {
        BT_COMP_LOGD("Copying content of static array field class: in-fc-addr=%p, "
-                       "out-fc-addr=%p", in_field_class, out_field_class);
+               "out-fc-addr=%p", in_field_class, out_field_class);
        /*
         * There is no content to copy. Keep this function call anyway for
         * logging purposes.
         */
        BT_COMP_LOGD("Copied content of static array field class: in-fc-addr=%p, "
-                       "out-fc-addr=%p", in_field_class, out_field_class);
+               "out-fc-addr=%p", in_field_class, out_field_class);
 
        return 0;
 }
@@ -573,15 +549,13 @@ int field_class_dynamic_array_copy(
                bt_field_class *out_field_class)
 {
        BT_COMP_LOGD("Copying content of dynamic array field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
-
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
        /*
         * There is no content to copy. Keep this function call anyway for
         * logging purposes.
         */
-       BT_COMP_LOGD("Copied dynamic array field class: in-fc-addr=%p, "
-                       "out-fc-addr=%p", in_field_class, out_field_class);
+       BT_COMP_LOGD("Copied content of dynamic array field class: "
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
        return 0;
 }
@@ -593,19 +567,18 @@ int field_class_option_copy(
                bt_field_class *out_field_class)
 {
        BT_COMP_LOGD("Copying content of option field class: "
-                       "in-fc-addr=%p, out-fc-addr=%p",
-                       in_field_class, out_field_class);
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
        if (bt_field_class_get_type(out_field_class) ==
-                       BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR) {
-               bt_field_class_option_with_selector_bool_set_selector_is_reversed(
+                       BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD) {
+               bt_field_class_option_with_selector_field_bool_set_selector_is_reversed(
                        out_field_class,
-                       bt_field_class_option_with_selector_bool_selector_is_reversed(
+                       bt_field_class_option_with_selector_field_bool_selector_is_reversed(
                                in_field_class));
        }
 
-       BT_COMP_LOGD("Copied option field class: in-fc-addr=%p, "
-                       "out-fc-addr=%p", in_field_class, out_field_class);
+       BT_COMP_LOGD("Copied content of option field class: "
+               "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class);
 
        return 0;
 }
@@ -616,13 +589,13 @@ int field_class_string_copy(struct trace_ir_metadata_maps *md_maps,
                bt_field_class *out_field_class)
 {
        BT_COMP_LOGD("Copying content of string field class: in-fc-addr=%p, "
-                       "out-fc-addr=%p", in_field_class, out_field_class);
+               "out-fc-addr=%p", in_field_class, out_field_class);
        /*
         * There is no content to copy. Keep this function call anyway for
         * logging purposes.
         */
        BT_COMP_LOGD("Copied content of string field class: in-fc-addr=%p, "
-                       "out-fc-addr=%p", in_field_class, out_field_class);
+               "out-fc-addr=%p", in_field_class, out_field_class);
 
        return 0;
 }
@@ -636,16 +609,16 @@ bt_field_class *copy_field_class_array_element(struct trace_ir_metadata_maps *md
                create_field_class_copy_internal(md_maps, in_elem_fc);
        if (!out_elem_fc) {
                BT_COMP_LOGE("Error creating output elem field class "
-                               "from input elem field class for static array: "
-                               "in-fc-addr=%p", in_elem_fc);
+                       "from input elem field class for static array: "
+                       "in-fc-addr=%p", in_elem_fc);
                goto error;
        }
 
        ret = copy_field_class_content_internal(md_maps, in_elem_fc, out_elem_fc);
        if (ret) {
                BT_COMP_LOGE("Error creating output elem field class "
-                               "from input elem field class for static array: "
-                               "in-fc-addr=%p", in_elem_fc);
+                       "from input elem field class for static array: "
+                       "in-fc-addr=%p", in_elem_fc);
                BT_FIELD_CLASS_PUT_REF_AND_RESET(out_elem_fc);
                goto error;
        }
@@ -662,58 +635,58 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
        bt_field_class_type fc_type = bt_field_class_get_type(in_field_class);
 
        BT_COMP_LOGD("Creating bare field class based on field class: in-fc-addr=%p",
-                       in_field_class);
+               in_field_class);
 
        switch (fc_type) {
        case BT_FIELD_CLASS_TYPE_BOOL:
                out_field_class = bt_field_class_bool_create(
-                               md_maps->output_trace_class);
+                       md_maps->output_trace_class);
                break;
        case BT_FIELD_CLASS_TYPE_BIT_ARRAY:
                out_field_class = bt_field_class_bit_array_create(
-                               md_maps->output_trace_class,
-                               bt_field_class_bit_array_get_length(
-                                       in_field_class));
+                       md_maps->output_trace_class,
+                       bt_field_class_bit_array_get_length(
+                               in_field_class));
                break;
        case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
                out_field_class = bt_field_class_integer_unsigned_create(
-                               md_maps->output_trace_class);
+                       md_maps->output_trace_class);
                break;
        case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
                out_field_class = bt_field_class_integer_signed_create(
-                               md_maps->output_trace_class);
+                       md_maps->output_trace_class);
                break;
        case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
                out_field_class = bt_field_class_enumeration_unsigned_create(
-                               md_maps->output_trace_class);
+                       md_maps->output_trace_class);
                break;
        case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
                out_field_class = bt_field_class_enumeration_signed_create(
-                               md_maps->output_trace_class);
+                       md_maps->output_trace_class);
                break;
        case BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL:
                out_field_class = bt_field_class_real_single_precision_create(
-                               md_maps->output_trace_class);
+                       md_maps->output_trace_class);
                break;
        case BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL:
                out_field_class = bt_field_class_real_double_precision_create(
-                               md_maps->output_trace_class);
+                       md_maps->output_trace_class);
                break;
        case BT_FIELD_CLASS_TYPE_STRING:
                out_field_class = bt_field_class_string_create(
-                               md_maps->output_trace_class);
+                       md_maps->output_trace_class);
                break;
        case BT_FIELD_CLASS_TYPE_STRUCTURE:
                out_field_class = bt_field_class_structure_create(
-                               md_maps->output_trace_class);
+                       md_maps->output_trace_class);
                break;
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
        {
                const bt_field_class *in_elem_fc =
                        bt_field_class_array_borrow_element_field_class_const(
                                        in_field_class);
-               uint64_t array_len =
-                       bt_field_class_array_static_get_length(in_field_class);
+               uint64_t array_len = bt_field_class_array_static_get_length(
+                       in_field_class);
 
                bt_field_class *out_elem_fc = copy_field_class_array_element(
                                md_maps, in_elem_fc);
@@ -723,28 +696,32 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
                }
 
                out_field_class = bt_field_class_array_static_create(
-                               md_maps->output_trace_class,
-                               out_elem_fc, array_len);
+                       md_maps->output_trace_class,
+                       out_elem_fc, array_len);
                break;
        }
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
-       {
+       default:
+               break;
+       }
+
+       if (bt_field_class_type_is(fc_type,
+                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY)) {
                const bt_field_class *in_elem_fc =
                        bt_field_class_array_borrow_element_field_class_const(
                                        in_field_class);
-               const bt_field_path *length_fp =
-                       bt_field_class_array_dynamic_borrow_length_field_path_const(
-                               in_field_class);
                bt_field_class *out_length_fc = NULL;
-
                bt_field_class *out_elem_fc = copy_field_class_array_element(
                        md_maps, in_elem_fc);
+
                if (!out_elem_fc) {
                        out_field_class = NULL;
                        goto error;
                }
 
-               if (length_fp) {
+               if (fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
+                       const bt_field_path *length_fp =
+                               bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
+                                       in_field_class);
                        const bt_field_class *in_length_fc =
                                resolve_field_path_to_field_class(length_fp,
                                        md_maps);
@@ -756,24 +733,19 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
                }
 
                out_field_class = bt_field_class_array_dynamic_create(
-                               md_maps->output_trace_class,
-                               out_elem_fc, out_length_fc);
-               break;
-       }
-       case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR:
-       {
+                       md_maps->output_trace_class,
+                       out_elem_fc, out_length_fc);
+       } else if (bt_field_class_type_is(fc_type,
+                       BT_FIELD_CLASS_TYPE_OPTION)) {
                const bt_field_class *in_content_fc =
                        bt_field_class_option_borrow_field_class_const(
-                                       in_field_class);
+                               in_field_class);
                bt_field_class *out_selector_fc = NULL;
                bt_field_class *out_content_fc;
                int ret;
 
                out_content_fc = create_field_class_copy_internal(
-                               md_maps, in_content_fc);
+                       md_maps, in_content_fc);
                if (!out_content_fc) {
                        BT_COMP_LOGE_STR("Cannot copy option's content field class.");
                        goto error;
@@ -787,14 +759,14 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
                        goto error;
                }
 
-               if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR) {
+               if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD) {
                        out_field_class =
                                bt_field_class_option_without_selector_create(
                                        md_maps->output_trace_class,
                                        out_content_fc);
                } else {
                        const bt_field_path *in_selector_fp =
-                               bt_field_class_option_with_selector_borrow_selector_field_path_const(
+                               bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
                                        in_field_class);
                        const bt_field_class *in_selector_fc;
 
@@ -806,30 +778,30 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
                                md_maps->field_class_map, in_selector_fc);
                        BT_ASSERT(out_selector_fc);
 
-                       if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR) {
+                       if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD) {
                                out_field_class =
-                                       bt_field_class_option_with_selector_bool_create(
+                                       bt_field_class_option_with_selector_field_bool_create(
                                                md_maps->output_trace_class,
                                                out_content_fc, out_selector_fc);
-                       } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR) {
+                       } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD) {
                                const bt_integer_range_set_unsigned *ranges =
-                                       bt_field_class_option_with_selector_integer_unsigned_borrow_selector_ranges_const(
+                                       bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const(
                                                in_field_class);
 
                                BT_ASSERT(ranges);
                                out_field_class =
-                                       bt_field_class_option_with_selector_integer_unsigned_create(
+                                       bt_field_class_option_with_selector_field_integer_unsigned_create(
                                                md_maps->output_trace_class,
                                                out_content_fc, out_selector_fc,
                                                ranges);
-                       } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR) {
+                       } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) {
                                const bt_integer_range_set_signed *ranges =
-                                       bt_field_class_option_with_selector_integer_signed_borrow_selector_ranges_const(
+                                       bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const(
                                                in_field_class);
 
                                BT_ASSERT(ranges);
                                out_field_class =
-                                       bt_field_class_option_with_selector_integer_signed_create(
+                                       bt_field_class_option_with_selector_field_integer_signed_create(
                                                md_maps->output_trace_class,
                                                out_content_fc, out_selector_fc,
                                                ranges);
@@ -837,19 +809,15 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
                }
 
                BT_ASSERT(out_field_class);
-               break;
-       }
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
-       {
+       } else if (bt_field_class_type_is(fc_type,
+                       BT_FIELD_CLASS_TYPE_VARIANT)) {
                bt_field_class *out_sel_fc = NULL;
 
-               if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR ||
-                               fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR) {
+               if (bt_field_class_type_is(fc_type,
+                               BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD)) {
                        const bt_field_class *in_sel_fc;
                        const bt_field_path *sel_fp =
-                               bt_field_class_variant_with_selector_borrow_selector_field_path_const(
+                               bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
                                        in_field_class);
 
                        BT_ASSERT(sel_fp);
@@ -863,10 +831,6 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
 
                out_field_class = bt_field_class_variant_create(
                        md_maps->output_trace_class, out_sel_fc);
-               break;
-       }
-       default:
-               abort();
        }
 
        /*
@@ -874,8 +838,9 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
         * the resolution of field paths in variant and dynamic array field
         * classes.
         */
+       BT_ASSERT(out_field_class);
        g_hash_table_insert(md_maps->field_class_map,
-                       (gpointer) in_field_class, out_field_class);
+               (gpointer) in_field_class, out_field_class);
 
 error:
        if(out_field_class){
@@ -896,6 +861,8 @@ int copy_field_class_content_internal(
                bt_field_class *out_field_class)
 {
        int ret = 0;
+       bt_field_class_type in_fc_type =
+               bt_field_class_get_type(in_field_class);
 
        /*
         * Safe to use the same value object because it's frozen at this
@@ -904,69 +871,52 @@ int copy_field_class_content_internal(
        bt_field_class_set_user_attributes(out_field_class,
                bt_field_class_borrow_user_attributes_const(in_field_class));
 
-       switch(bt_field_class_get_type(in_field_class)) {
-       case BT_FIELD_CLASS_TYPE_BOOL:
+       if (in_fc_type == BT_FIELD_CLASS_TYPE_BOOL) {
                ret = field_class_bool_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_BIT_ARRAY:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_BIT_ARRAY) {
                ret = field_class_bit_array_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER) {
                ret = field_class_unsigned_integer_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER) {
                ret = field_class_signed_integer_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) {
                ret = field_class_unsigned_enumeration_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) {
                ret = field_class_signed_enumeration_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL) {
                ret = field_class_single_precision_real_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL) {
                ret = field_class_double_precision_real_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_STRING:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_STRING) {
                ret = field_class_string_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_STRUCTURE:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_STRUCTURE) {
                ret = field_class_structure_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
+       } else if (in_fc_type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY) {
                ret = field_class_static_array_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       } else if (bt_field_class_type_is(in_fc_type,
+                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY)) {
                ret = field_class_dynamic_array_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR:
+       } else if (bt_field_class_type_is(in_fc_type,
+                       BT_FIELD_CLASS_TYPE_OPTION)) {
                ret = field_class_option_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
+       } else if (bt_field_class_type_is(in_fc_type,
+                       BT_FIELD_CLASS_TYPE_VARIANT)) {
                ret = field_class_variant_copy(md_maps,
                                in_field_class, out_field_class);
-               break;
-       default:
+       } else {
                abort();
        }
 
This page took 0.034469 seconds and 4 git commands to generate.