From b3dbeb52a97f27fd988794f4b95eeb59bfa2e292 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 11 Feb 2016 18:38:10 -0500 Subject: [PATCH] ir: validate integer FT's mapped clock against signedness MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It is invalid for a signed integer field type to be mapped to a clock. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/field-types.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/formats/ctf/ir/field-types.c b/formats/ctf/ir/field-types.c index b6c2102f..c0c396ff 100644 --- a/formats/ctf/ir/field-types.c +++ b/formats/ctf/ir/field-types.c @@ -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) { -- 2.34.1