ir: validate field types on field creation
[babeltrace.git] / formats / ctf / ir / event-fields.c
index 3358ff0ed0f68af8055b7ab6c8a8436b0b3b0c33..65c9aee863a7511ec4629fb9c9aaecfd1b8d6285 100644 (file)
@@ -234,14 +234,22 @@ struct bt_ctf_field *bt_ctf_field_create(struct bt_ctf_field_type *type)
 {
        struct bt_ctf_field *field = NULL;
        enum ctf_type_id type_id;
+       int ret;
 
        if (!type) {
                goto error;
        }
 
        type_id = bt_ctf_field_type_get_type_id(type);
-       if (type_id <= CTF_TYPE_UNKNOWN || type_id >= NR_CTF_TYPES ||
-               bt_ctf_field_type_validate(type)) {
+       if (type_id <= CTF_TYPE_UNKNOWN || type_id >= NR_CTF_TYPES) {
+               goto error;
+       }
+
+       /* Field class MUST be valid */
+       ret = bt_ctf_field_type_validate(type);
+
+       if (ret) {
+               /* Invalid */
                goto error;
        }
 
This page took 0.023604 seconds and 4 git commands to generate.