From: Philippe Proulx Date: Thu, 11 Feb 2016 23:38:10 +0000 (-0500) Subject: ir: validate integer FT's mapped clock against signedness X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=b3dbeb52a97f27fd988794f4b95eeb59bfa2e292 ir: validate integer FT's mapped clock against signedness 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 --- 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) {