X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-generate-io-struct.c;h=1eb763de79b1f407a9e4b268c9e1012a04386990;hp=f54307118f2601029688326f231360eb7d017ea4;hb=8c572eba034b95716a4bbd019dfbe0827605ba90;hpb=b40c80907b06191926275b96d818fdcbb4db5055 diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index f5430711..1eb763de 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -1442,13 +1442,6 @@ int ctf_event_visit(FILE *fd, int depth, struct ctf_node *node, fprintf(fd, "[error] %s: missing name field in event declaration\n", __func__); goto error; } - /* Allow only one event without id per stream */ - if (!CTF_EVENT_FIELD_IS_SET(event, id) - && event->stream->events_by_id->len != 0) { - ret = -EPERM; - fprintf(fd, "[error] %s: missing id field in event declaration\n", __func__); - goto error; - } if (!CTF_EVENT_FIELD_IS_SET(event, stream_id)) { /* Allow missing stream_id if there is only a single stream */ if (trace->streams->len == 1) { @@ -1460,6 +1453,13 @@ int ctf_event_visit(FILE *fd, int depth, struct ctf_node *node, goto error; } } + /* Allow only one event without id per stream */ + if (!CTF_EVENT_FIELD_IS_SET(event, id) + && event->stream->events_by_id->len != 0) { + ret = -EPERM; + fprintf(fd, "[error] %s: missing id field in event declaration\n", __func__); + goto error; + } if (event->stream->events_by_id->len <= event->id) g_ptr_array_set_size(event->stream->events_by_id, event->id + 1); g_ptr_array_index(event->stream->events_by_id, event->id) = event; @@ -1646,14 +1646,14 @@ int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node, fprintf(fd, "[error] %s: missing stream_id field in packet header declaration, but stream_id attribute is declared for stream.\n", __func__); goto error; } - } - - /* Allow only one id-less stream */ - if (!CTF_STREAM_FIELD_IS_SET(stream, stream_id) - && trace->streams->len != 0) { - ret = -EPERM; - fprintf(fd, "[error] %s: missing id field in stream declaration\n", __func__); - goto error; + } else { + /* Allow only one id-less stream */ + if (trace->streams->len != 0) { + ret = -EPERM; + fprintf(fd, "[error] %s: missing id field in stream declaration\n", __func__); + goto error; + } + stream->stream_id = 0; } if (trace->streams->len <= stream->stream_id) g_ptr_array_set_size(trace->streams, stream->stream_id + 1);