From d3006d919ab4edb157e48083fe663f19502122c1 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 14 Jul 2011 09:37:51 -0400 Subject: [PATCH] Duplicate struct field name check Check that no field with the same name has been defined in the struct. Signed-off-by: Mathieu Desnoyers --- formats/ctf/metadata/ctf-visitor-generate-io-struct.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index bab2f786..640b8fdf 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); -- 2.34.1