ir: validate integer FT's mapped clock against signedness
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 11 Feb 2016 23:38:10 +0000 (18:38 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 19 Feb 2016 22:22:11 +0000 (17:22 -0500)
It is invalid for a signed integer field type to be mapped to a clock.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/field-types.c

index b6c2102fb08335d4cbd06d88925b8476c8081b9d..c0c396ffca7f52df5f7097ffb7663c71ef8ef494 100644 (file)
@@ -270,6 +270,8 @@ int (* const type_compare_funcs[])(struct bt_ctf_field_type *,
        [BT_CTF_TYPE_ID_STRING] = bt_ctf_field_type_string_compare,
 };
 
+static
+int bt_ctf_field_type_integer_validate(struct bt_ctf_field_type *);
 static
 int bt_ctf_field_type_enumeration_validate(struct bt_ctf_field_type *);
 static
@@ -283,7 +285,7 @@ int bt_ctf_field_type_sequence_validate(struct bt_ctf_field_type *);
 
 static
 int (* const type_validate_funcs[])(struct bt_ctf_field_type *) = {
-       [BT_CTF_TYPE_ID_INTEGER] = NULL,
+       [BT_CTF_TYPE_ID_INTEGER] = bt_ctf_field_type_integer_validate,
        [BT_CTF_TYPE_ID_FLOAT] = NULL,
        [BT_CTF_TYPE_ID_STRING] = NULL,
        [BT_CTF_TYPE_ID_ENUM] = bt_ctf_field_type_enumeration_validate,
@@ -425,6 +427,24 @@ void bt_ctf_field_type_destroy(struct bt_object *obj)
        type_destroy_funcs[type_id](type);
 }
 
+static
+int bt_ctf_field_type_integer_validate(struct bt_ctf_field_type *type)
+{
+       int ret = 0;
+
+       struct bt_ctf_field_type_integer *integer =
+               container_of(type, struct bt_ctf_field_type_integer,
+                       parent);
+
+       if (integer->mapped_clock && integer->declaration.signedness) {
+               ret = -1;
+               goto end;
+       }
+
+end:
+       return ret;
+}
+
 static
 int bt_ctf_field_type_enumeration_validate(struct bt_ctf_field_type *type)
 {
This page took 0.027042 seconds and 4 git commands to generate.