Validate CTF semantics in selected CTF IR functions
[babeltrace.git] / lib / ctf-ir / field-types.c
index 6df6bdf1dabd4aca28d699b8181c694133bc0e3c..0cf5d1ef4293c7a0f3732f4be49ee59346abfec8 100644 (file)
@@ -1181,7 +1181,8 @@ end:
        return clock_class;
 }
 
-int bt_ctf_field_type_integer_set_mapped_clock_class(
+BT_HIDDEN
+int bt_ctf_field_type_integer_set_mapped_clock_class_no_check(
                struct bt_ctf_field_type *type,
                struct bt_ctf_clock_class *clock_class)
 {
@@ -1200,10 +1201,10 @@ int bt_ctf_field_type_integer_set_mapped_clock_class(
                goto end;
        }
 
-       if (type->frozen) {
-               BT_LOGW("Invalid parameter: field type is frozen: addr=%p",
-                       type);
-               ret = -1;
+       if (type->id != BT_CTF_FIELD_TYPE_ID_INTEGER) {
+               BT_LOGW("Invalid parameter: field type is not an integer field type: "
+                       "addr=%p, ft-id=%s", type,
+                       bt_ctf_field_type_id_string(type->id));
                goto end;
        }
 
@@ -1226,6 +1227,32 @@ end:
        return ret;
 }
 
+int bt_ctf_field_type_integer_set_mapped_clock_class(
+               struct bt_ctf_field_type *type,
+               struct bt_ctf_clock_class *clock_class)
+{
+       int ret = 0;
+
+       if (!type) {
+               BT_LOGW_STR("Invalid parameter: field type is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (type->frozen) {
+               BT_LOGW("Invalid parameter: field type is frozen: addr=%p",
+                       type);
+               ret = -1;
+               goto end;
+       }
+
+       ret = bt_ctf_field_type_integer_set_mapped_clock_class_no_check(
+               type, clock_class);
+
+end:
+       return ret;
+}
+
 static
 void bt_ctf_field_type_enum_iter_destroy(struct bt_object *obj)
 {
@@ -4022,7 +4049,7 @@ int bt_ctf_field_type_structure_serialize(struct bt_ctf_field_type *type,
 {
        size_t i;
        unsigned int indent;
-       int64_t ret = 0;
+       int ret = 0;
        struct bt_ctf_field_type_structure *structure = container_of(type,
                struct bt_ctf_field_type_structure, parent);
        GString *structure_field_name = context->field_name;
This page took 0.026752 seconds and 4 git commands to generate.