From: Simon Marchi Date: Thu, 14 Jul 2011 13:37:51 +0000 (-0400) Subject: Duplicate struct field name check X-Git-Tag: v0.1~8 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=d3006d919ab4edb157e48083fe663f19502122c1;hp=01c76b246be85b5d9c8e99813950fb194c9f714f Duplicate struct field name check Check that no field with the same name has been defined in the struct. Signed-off-by: Mathieu Desnoyers --- 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);