From: Jérémie Galarneau Date: Thu, 2 Jul 2015 18:43:12 +0000 (-0400) Subject: Fix: Create stream after adding its stream class to a trace X-Git-Tag: v2.0.0-pre1~1220 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=ae294457cab8841fdb945a70ee018637d4e62cc2 Fix: Create stream after adding its stream class to a trace This ensures that a stream class' id is set before we create a stream instance and initialize its packet header. Otherwise, the packet header stream_id is initialized to its default value (0). Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/trace.c b/formats/ctf/ir/trace.c index 158f2b8b..d911dfd6 100644 --- a/formats/ctf/ir/trace.c +++ b/formats/ctf/ir/trace.c @@ -156,11 +156,6 @@ struct bt_ctf_stream *bt_ctf_trace_create_stream(struct bt_ctf_trace *trace, goto error; } - stream = bt_ctf_stream_create(stream_class, trace); - if (!stream) { - goto error; - } - for (i = 0; i < trace->stream_classes->len; i++) { if (trace->stream_classes->pdata[i] == stream_class) { stream_class_found = 1; @@ -174,6 +169,11 @@ struct bt_ctf_stream *bt_ctf_trace_create_stream(struct bt_ctf_trace *trace, } } + stream = bt_ctf_stream_create(stream_class, trace); + if (!stream) { + goto error; + } + bt_ctf_stream_get(stream); g_ptr_array_add(trace->streams, stream);