From 8c1aa858878b64d103166be4c02f110af87669df Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 30 Jul 2015 15:31:38 -0400 Subject: [PATCH] ir: empty structures are legal in CTF MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/event-fields.c | 2 +- formats/ctf/ir/visitor.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/formats/ctf/ir/event-fields.c b/formats/ctf/ir/event-fields.c index 829a4475..1092dc31 100644 --- a/formats/ctf/ir/event-fields.c +++ b/formats/ctf/ir/event-fields.c @@ -1257,7 +1257,7 @@ struct bt_ctf_field *bt_ctf_field_structure_create( struct bt_ctf_field_structure, 1); struct bt_ctf_field *field = NULL; - if (!structure || !structure_type->fields->len) { + if (!structure) { goto end; } diff --git a/formats/ctf/ir/visitor.c b/formats/ctf/ir/visitor.c index 62195b64..9b65ed58 100644 --- a/formats/ctf/ir/visitor.c +++ b/formats/ctf/ir/visitor.c @@ -273,10 +273,11 @@ int field_type_recursive_visit(struct bt_ctf_field_type *type, ctf_type_stack_peek(context->stack); int field_count = get_type_field_count(entry->type); - if (field_count <= 0) { + if (field_count <= 0 && + !bt_ctf_field_type_is_structure(entry->type)) { /* * Propagate error if one was given, else return - * -1 since empty structures or variants are invalid + * -1 since empty variants are invalid * at this point. */ ret = field_count < 0 ? field_count : -1; -- 2.34.1