+
+ for (i = 0; i < struct_ft->fields->len; i++) {
+ struct bt_field_type_common_structure_field *field =
+ BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, i);
+
+ BT_LOGD("Freezing structure field type field: "
+ "ft-addr=%p, name=\"%s\"",
+ field->type, g_quark_to_string(field->name));
+ bt_field_type_common_freeze(field->type);
+ }
+}
+
+BT_HIDDEN
+int bt_field_type_common_variant_update_choices(struct bt_field_type_common *ft)
+{
+ struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ uint64_t i;
+ int ret = 0;
+ bool is_signed;
+
+ if (ft->frozen && var_ft->choices_up_to_date) {
+ goto end;
+ }
+
+ BT_ASSERT(var_ft->tag_ft);
+ is_signed = !!var_ft->tag_ft->container_ft->is_signed;
+
+ for (i = 0; i < var_ft->choices->len; i++) {
+ struct bt_field_type_common_variant_choice *choice =
+ BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(ft, i);
+ const char *choice_name = g_quark_to_string(choice->name);
+ struct bt_field_type_enumeration_mapping_iterator *iter =
+ bt_field_type_common_enumeration_find_mappings_by_name(
+ BT_TO_COMMON(var_ft->tag_ft), choice_name);
+
+ if (!iter) {
+ ret = -1;
+ goto end;
+ }
+
+ BT_ASSERT(choice->ranges);
+ g_array_set_size(choice->ranges, 0);
+
+ while (bt_field_type_enumeration_mapping_iterator_next(iter) == 0) {
+ struct bt_field_type_common_variant_choice_range range;
+
+ if (is_signed) {
+ ret = bt_field_type_enumeration_mapping_iterator_signed_get(
+ iter, NULL,
+ &range.lower.i, &range.upper.i);
+ } else {
+ ret = bt_field_type_enumeration_mapping_iterator_unsigned_get(
+ iter, NULL,
+ &range.lower.u, &range.upper.u);
+ }
+
+ BT_ASSERT(ret == 0);
+ g_array_append_val(choice->ranges, range);
+ }
+
+ bt_put(iter);
+ }
+
+ var_ft->choices_up_to_date = true;
+
+end:
+ return ret;