X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-generate-io-struct.c;h=4515b53e437fb16238530f9371b20a745b79f2b2;hb=fbad6b84b7a1a9e1d046d9ef983ca001f4f7ba29;hp=17479ebaec39f384056ce479d68db3552c6c4560;hpb=139fdb6040119758ffce99e19e1834600d8d1e5f;p=babeltrace.git diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index 17479eba..4515b53e 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include "ctf-scanner.h" @@ -271,7 +271,7 @@ struct ctf_stream_declaration *trace_stream_lookup(struct ctf_trace *trace, uint static struct ctf_clock *trace_clock_lookup(struct ctf_trace *trace, GQuark clock_name) { - return g_hash_table_lookup(trace->clocks, (gpointer) (unsigned long) clock_name); + return g_hash_table_lookup(trace->parent.clocks, (gpointer) (unsigned long) clock_name); } static @@ -649,7 +649,7 @@ int ctf_typedef_visit(FILE *fd, int depth, struct declaration_scope *scope, bt_list_for_each_entry(iter, type_declarators, siblings) { struct bt_declaration *type_declaration; int ret; - + type_declaration = ctf_type_declarator_visit(fd, depth, type_specifier_list, &identifier, iter, @@ -865,7 +865,6 @@ struct bt_declaration *ctf_declaration_struct_visit(FILE *fd, if (name) { if (bt_lookup_struct_declaration(g_quark_from_string(name), declaration_scope)) { - fprintf(fd, "[error] %s: struct %s already declared in scope\n", __func__, name); return NULL; } @@ -876,7 +875,6 @@ struct bt_declaration *ctf_declaration_struct_visit(FILE *fd, ret = get_unary_unsigned(min_align, &min_align_value); if (ret) { fprintf(fd, "[error] %s: unexpected unary expression for structure \"align\" attribute\n", __func__); - ret = -EINVAL; goto error; } } @@ -936,7 +934,6 @@ struct bt_declaration *ctf_declaration_variant_visit(FILE *fd, if (name) { if (bt_lookup_variant_declaration(g_quark_from_string(name), declaration_scope)) { - fprintf(fd, "[error] %s: variant %s already declared in scope\n", __func__, name); return NULL; } @@ -1105,7 +1102,6 @@ struct bt_declaration *ctf_declaration_enum_visit(FILE *fd, int depth, if (name) { if (bt_lookup_enum_declaration(g_quark_from_string(name), declaration_scope)) { - fprintf(fd, "[error] %s: enum %s already declared in scope\n", __func__, name); return NULL; } @@ -1233,7 +1229,7 @@ int get_boolean(FILE *fd, int depth, struct ctf_node *unary_expression) fprintf(fd, "[error] %s: unexpected unary expression type\n", __func__); return -EINVAL; - } + } } @@ -1323,6 +1319,11 @@ struct bt_declaration *ctf_declaration_integer_visit(FILE *fd, int depth, return NULL; } size = right->u.unary_expression.u.unsigned_constant; + if (!size) { + fprintf(fd, "[error] %s: integer size: expecting non-zero constant\n", + __func__); + return NULL; + } has_size = 1; } else if (!strcmp(left->u.unary_expression.u.string, "align")) { if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { @@ -1479,9 +1480,9 @@ struct bt_declaration *ctf_declaration_floating_point_visit(FILE *fd, int depth, struct ctf_trace *trace) { struct ctf_node *expression; - uint64_t alignment = 1, exp_dig = 0, mant_dig = 0, - byte_order = trace->byte_order; - int has_alignment = 0, has_exp_dig = 0, has_mant_dig = 0; + uint64_t alignment = 1, exp_dig = 0, mant_dig = 0; + int byte_order = trace->byte_order, has_alignment = 0, + has_exp_dig = 0, has_mant_dig = 0; struct declaration_float *float_declaration; bt_list_for_each_entry(expression, expressions, siblings) { @@ -2403,6 +2404,7 @@ int ctf_clock_declaration_visit(FILE *fd, int depth, struct ctf_node *node, goto error; } clock->absolute = ret; + ret = 0; } else { fprintf(fd, "[warning] %s: attribute \"%s\" is unknown in clock declaration.\n", __func__, left); } @@ -2450,13 +2452,13 @@ int ctf_clock_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace fprintf(fd, "[error] %s: missing name field in clock declaration\n", __func__); goto error; } - if (g_hash_table_size(trace->clocks) > 0) { + if (g_hash_table_size(trace->parent.clocks) > 0) { fprintf(fd, "[error] Only CTF traces with a single clock description are supported by this babeltrace version.\n"); ret = -EINVAL; goto error; } - trace->single_clock = clock; - g_hash_table_insert(trace->clocks, (gpointer) (unsigned long) clock->name, clock); + trace->parent.single_clock = clock; + g_hash_table_insert(trace->parent.clocks, (gpointer) (unsigned long) clock->name, clock); return 0; error: @@ -2490,8 +2492,8 @@ void ctf_clock_default(FILE *fd, int depth, struct ctf_trace *trace) clock->absolute = 0; /* Not an absolute reference across traces */ } - trace->single_clock = clock; - g_hash_table_insert(trace->clocks, (gpointer) (unsigned long) clock->name, clock); + trace->parent.single_clock = clock; + g_hash_table_insert(trace->parent.clocks, (gpointer) (unsigned long) clock->name, clock); } static @@ -2920,8 +2922,8 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node, printf_verbose("CTF visitor: metadata construction...\n"); trace->byte_order = byte_order; - trace->clocks = g_hash_table_new_full(g_direct_hash, g_direct_equal, - NULL, clock_free); + trace->parent.clocks = g_hash_table_new_full(g_direct_hash, + g_direct_equal, NULL, clock_free); trace->callsites = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, callsite_free); @@ -3023,7 +3025,7 @@ retry: error: bt_free_declaration_scope(trace->root_declaration_scope); g_hash_table_destroy(trace->callsites); - g_hash_table_destroy(trace->clocks); + g_hash_table_destroy(trace->parent.clocks); return ret; } @@ -3122,7 +3124,7 @@ int ctf_destroy_metadata(struct ctf_trace *trace) bt_free_declaration_scope(trace->declaration_scope); g_hash_table_destroy(trace->callsites); - g_hash_table_destroy(trace->clocks); + g_hash_table_destroy(trace->parent.clocks); metadata_stream = container_of(trace->metadata, struct ctf_file_stream, parent); g_free(metadata_stream);