X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-generate-io-struct.c;h=bdb5c68d6cfaa45ec3395fc7ad408eb23ff9792a;hp=bab2f7869715a1ca8c26859b1bdbbd659cddf64d;hb=43f9090cab93646a1651720ecc1c52758cae7795;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..bdb5c68d 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);