Duplicate struct field name check
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 14 Jul 2011 13:37:51 +0000 (09:37 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 14 Jul 2011 13:37:51 +0000 (09:37 -0400)
Check that no field with the same name has been defined in the struct.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/metadata/ctf-visitor-generate-io-struct.c

index bab2f7869715a1ca8c26859b1bdbbd659cddf64d..640b8fdff7c1ae6dc5095735328b2224972a1c79 100644 (file)
@@ -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);
This page took 0.026451 seconds and 4 git commands to generate.