X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-generate-io-struct.c;h=cda3329be4455be450b31d611ce0c8e0dee23690;hp=bab2f7869715a1ca8c26859b1bdbbd659cddf64d;hb=230da7433d746d56c6837b44794531c1bbee74e1;hpb=2d0bea29e27a0f1a9b651bb98dac7bf0c2550f78 diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index bab2f786..cda3329b 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -431,6 +431,13 @@ int ctf_struct_type_declarators_visit(FILE *fd, int depth, fprintf(fd, "[error] %s: unable to find struct field declaration type\n", __func__); return -EINVAL; } + + /* Check if field with same name already exists */ + if (struct_declaration_lookup_field_index(struct_declaration, field_name) >= 0) { + fprintf(fd, "[error] %s: duplicate field %s in struct\n", __func__, g_quark_to_string(field_name)); + return -EINVAL; + } + struct_declaration_add_field(struct_declaration, g_quark_to_string(field_name), field_declaration); @@ -461,6 +468,13 @@ int ctf_variant_type_declarators_visit(FILE *fd, int depth, fprintf(fd, "[error] %s: unable to find variant field declaration type\n", __func__); return -EINVAL; } + + if (untagged_variant_declaration_get_field_from_tag(untagged_variant_declaration, field_name) != NULL) { + fprintf(fd, "[error] %s: duplicate field %s in variant\n", __func__, g_quark_to_string(field_name)); + return -EINVAL; + } + + untagged_variant_declaration_add_field(untagged_variant_declaration, g_quark_to_string(field_name), field_declaration); @@ -570,7 +584,9 @@ int ctf_typealias_visit(FILE *fd, int depth, struct declaration_scope *scope, return 0; error: - type_declaration->declaration_free(type_declaration); + if (type_declaration) { + type_declaration->declaration_free(type_declaration); + } return err; }