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=f137f6d32e9d90efe8dcd828435bc20a9450391c;hb=43f9090cab93646a1651720ecc1c52758cae7795;hpb=e28d4618a97ed5c6da7cda25af9d1121808664cf diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index f137f6d3..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); @@ -1747,7 +1761,7 @@ int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node, stream->declaration_scope = new_declaration_scope(parent_declaration_scope); stream->events_by_id = g_ptr_array_new(); stream->event_quark_to_id = g_hash_table_new(g_direct_hash, g_direct_equal); - stream->files = g_ptr_array_new(); + stream->streams = g_ptr_array_new(); if (node) { cds_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) { ret = ctf_stream_declaration_visit(fd, depth + 1, iter, stream, trace); @@ -1785,7 +1799,7 @@ error: declaration_unref(&stream->event_context_decl->p); if (stream->packet_context_decl) declaration_unref(&stream->packet_context_decl->p); - g_ptr_array_free(stream->files, TRUE); + g_ptr_array_free(stream->streams, TRUE); g_ptr_array_free(stream->events_by_id, TRUE); g_hash_table_destroy(stream->event_quark_to_id); free_declaration_scope(stream->declaration_scope);