From ae294457cab8841fdb945a70ee018637d4e62cc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 2 Jul 2015 14:43:12 -0400 Subject: [PATCH] Fix: Create stream after adding its stream class to a trace MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- formats/ctf/ir/trace.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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); -- 2.34.1