bt_field_type_compare(): deep-compare mapped clock classes
[babeltrace.git] / lib / ctf-ir / field-types.c
index c2a5383ccc86cb71f8d5f602c7cfee7dc46f2b41..feb7a62bc506db5b59fa526a6d824314677f1df0 100644 (file)
@@ -2997,6 +2997,15 @@ int bt_field_type_get_alignment(struct bt_field_type *type)
                ret = (int) type->alignment;
                break;
        }
+       case BT_FIELD_TYPE_ID_ENUM:
+       {
+               struct bt_field_type *container =
+                       bt_field_type_enumeration_get_container_type(type);
+
+               ret = bt_field_type_get_alignment(container);
+               bt_put(container);
+               break;
+       }
        case BT_FIELD_TYPE_ID_UNKNOWN:
                BT_LOGW("Invalid parameter: unknown field type ID: "
                        "addr=%p, ft-id=%d", type, type_id);
@@ -3725,6 +3734,7 @@ void bt_field_type_enumeration_freeze(struct bt_field_type *type)
                type, struct bt_field_type_enumeration, parent);
 
        BT_LOGD("Freezing enumeration field type object: addr=%p", type);
+       type->alignment = bt_field_type_get_alignment(type);
        set_enumeration_range_overlap(type);
        generic_field_type_freeze(type);
        BT_LOGD("Freezing enumeration field type object's container field type: int-ft-addr=%p",
@@ -4733,17 +4743,26 @@ int bt_field_type_integer_compare(struct bt_field_type *type_a,
                goto end;
        }
 
-       /* Mapped clock */
-       if (int_type_a->mapped_clock != int_type_b->mapped_clock) {
-               BT_LOGV("Integer field types differ: different mapped clock classes: "
-                       "ft-a-mapped-clock-class-addr=%p, "
-                       "ft-b-mapped-clock-class-addr=%p, "
-                       "ft-a-mapped-clock-class-name=\"%s\", "
-                       "ft-b-mapped-clock-class-name=\"%s\"",
-                       int_type_a->mapped_clock, int_type_b->mapped_clock,
-                       int_type_a->mapped_clock ? bt_clock_class_get_name(int_type_a->mapped_clock) : "",
-                       int_type_b->mapped_clock ? bt_clock_class_get_name(int_type_b->mapped_clock) : "");
-               goto end;
+       /* Mapped clock class */
+       if (int_type_a->mapped_clock) {
+               if (!int_type_b->mapped_clock) {
+                       BT_LOGV_STR("Integer field types differ: field type A "
+                               "has a mapped clock class, but field type B "
+                               "does not.");
+                       goto end;
+               }
+
+               if (bt_clock_class_compare(int_type_a->mapped_clock,
+                               int_type_b->mapped_clock) != 0) {
+                       BT_LOGV_STR("Integer field types differ: different "
+                               "mapped clock classes.");
+               }
+       } else {
+               if (int_type_b->mapped_clock) {
+                       BT_LOGV_STR("Integer field types differ: field type A "
+                               "has no description, but field type B has one.");
+                       goto end;
+               }
        }
 
        /* Equal */
This page took 0.088627 seconds and 4 git commands to generate.