Fix: ir: bt_ctf_field_type_variant_validate(): do not compare to tag length
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 2 May 2017 21:19:53 +0000 (17:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:42 +0000 (12:57 -0400)
Because the same label can map to multiple values in an enumeration FT,
the number of fields in a variant FT does not need to be the same as the
number of mappings in its tag FT for the variant FT to be considered
valid.

Relax this by only making sure that each tag FT mapping has an entry in
the variant FT which shares the same name. Unused variant FT
fields/choices are not a problem per se, just a waste of space.

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

index 2c334183ee4b631a60dc1697e189efbee97a40e2..3ce3758b8b5030ac2e94b777ce4cec1badfbbf4a 100644 (file)
@@ -683,11 +683,14 @@ int bt_ctf_field_type_variant_validate(struct bt_ctf_field_type *type)
                bt_ctf_field_type_enumeration_get_mapping_count(
                        (struct bt_ctf_field_type *) variant->tag);
 
-       if (tag_mappings_count != variant->fields->len) {
-               ret = -1;
-               goto end;
-       }
-
+       /*
+        * Validate that each mapping found in the tag has a name which
+        * is also the name of a field in this variant field type.
+        *
+        * The opposite is accepted: variant FT fields which cannot be
+        * selected because the variant FT tag has no mapping named as
+        * such. This scenario, while not ideal, cannot cause any error.
+        */
        for (i = 0; i < tag_mappings_count; ++i) {
                const char *label;
                struct bt_ctf_field_type *ft;
This page took 0.026066 seconds and 4 git commands to generate.