X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-generate-io-struct.c;h=2eba30bd46d3475cf9a2c74e679646bba7fef119;hb=7c8a138614de162b26bd280934a4d0569701f07c;hp=6c9246fb2a4f82a1441701226fcc3bb3882043a7;hpb=a7d3eed364faffe9054776b3423572d792103316;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 6c9246fb..2eba30bd 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -119,7 +119,7 @@ int get_unary_uuid(struct cds_list_head *head, uuid_t *uuid) assert(node->u.unary_expression.link == UNARY_LINK_UNKNOWN); assert(i == 0); src_string = node->u.unary_expression.u.string; - ret = uuid_parse(node->u.unary_expression.u.string, *uuid); + ret = uuid_parse(src_string, *uuid); } return ret; } @@ -726,7 +726,7 @@ struct declaration *ctf_declaration_struct_visit(FILE *fd, ret = ctf_struct_declaration_list_visit(fd, depth + 1, iter, struct_declaration, trace); if (ret) - goto error; + goto error_free_declaration; } if (name) { ret = register_struct_declaration(g_quark_from_string(name), @@ -736,8 +736,9 @@ struct declaration *ctf_declaration_struct_visit(FILE *fd, } return &struct_declaration->p; } -error: +error_free_declaration: struct_declaration->p.declaration_free(&struct_declaration->p); +error: return NULL; } @@ -1092,7 +1093,7 @@ struct declaration *ctf_declaration_integer_visit(FILE *fd, int depth, struct ctf_trace *trace) { struct ctf_node *expression; - uint64_t alignment, size; + uint64_t alignment = 1, size; int byte_order = trace->byte_order; int signedness = 0; int has_alignment = 0, has_size = 0; @@ -1247,7 +1248,8 @@ struct declaration *ctf_declaration_floating_point_visit(FILE *fd, int depth, struct ctf_trace *trace) { struct ctf_node *expression; - uint64_t alignment, exp_dig, mant_dig, byte_order = trace->byte_order; + 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; struct declaration_float *float_declaration; @@ -1896,7 +1898,15 @@ int ctf_trace_declaration_visit(FILE *fd, int depth, struct ctf_node *node, stru ret = -EPERM; goto error; } else { - trace->byte_order = byte_order; + if (byte_order != trace->byte_order) { + trace->byte_order = byte_order; + /* + * We need to restart + * construction of the + * intermediate representation. + */ + return -EINTR; + } } CTF_TRACE_SET_FIELD(trace, byte_order); } else if (!strcmp(left, "packet.header")) { @@ -1944,6 +1954,7 @@ int ctf_trace_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace int ret = 0; struct ctf_node *iter; +restart: if (trace->declaration_scope) return -EEXIST; trace->declaration_scope = new_declaration_scope(trace->root_declaration_scope); @@ -1990,6 +2001,12 @@ error: declaration_unref(&trace->packet_header_decl->p); g_ptr_array_free(trace->streams, TRUE); free_declaration_scope(trace->declaration_scope); + trace->declaration_scope = NULL; + /* byte order changed while creating types, retry. */ + if (ret == -EINTR) { + trace->field_mask = 0; + goto restart; + } return ret; } @@ -2045,7 +2062,6 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node, struct ctf_node *iter; printf_verbose("CTF visitor: metadata construction... "); - memset(trace, 0, sizeof(struct ctf_trace)); trace->root_declaration_scope = new_declaration_scope(NULL); trace->byte_order = byte_order;