Validate CTF semantics in selected CTF IR functions
[babeltrace.git] / lib / ctf-ir / field-types.c
index 92211a49f750409619560ba9be3b0206c9f99ef5..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)
 {
This page took 0.024695 seconds and 4 git commands to generate.