From f0940b019844bc5d4dcfc0e32f90c324a366d3d5 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 9 Jun 2022 13:52:02 -0400 Subject: [PATCH] src.ctf.fs: remove uneeded check in create_streams_for_trace At this point, we certainly have a stream class. The ir_sc field is set in ctf_stream_class_to_ir. ctf_stream_class_to_ir is called by ctf_trace_class_translate, which is called by ctf_visitor_generate_ir_visit_node if ctx->trace_class is set. That trace_class field is set if a self_comp was passed to ctf_visitor_generate_ir_create, in the decoder_config object. Going up the stack, we get to ctf_fs_metadata_set_trace_class, called by ctf_fs_trace_create, called by ctf_fs_component_create_ctf_fs_trace. create_streams_for_trace is called by ctf_fs_trace_create, which always passes a self_comp to ctf_fs_component_create_ctf_fs_trace, ensuring we always end up with a stream class. ctf_fs_component_create_ctf_fs_trace is also used in the context of queries, where no self_comp if passed, and therefore no stream class is created.. But in that context, create_streams_for_trace is not called. Change-Id: I5e8ef72a1013fc156a7bc6ac0d4cbb231a5ab704 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8237 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/12274 Tested-by: jenkins --- src/plugins/ctf/fs-src/fs.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/plugins/ctf/fs-src/fs.cpp b/src/plugins/ctf/fs-src/fs.cpp index 39abdd6c..f2bd9618 100644 --- a/src/plugins/ctf/fs-src/fs.cpp +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -2076,22 +2076,18 @@ static int create_streams_for_trace(struct ctf_fs_trace *ctf_fs_trace) goto error; } - if (ds_file_group->sc->ir_sc) { - BT_ASSERT(ctf_fs_trace->trace); - - if (ds_file_group->stream_id == UINT64_C(-1)) { - /* No stream ID: use 0 */ - ds_file_group->stream = bt_stream_create_with_id( - ds_file_group->sc->ir_sc, ctf_fs_trace->trace, ctf_fs_trace->next_stream_id); - ctf_fs_trace->next_stream_id++; - } else { - /* Specific stream ID */ - ds_file_group->stream = - bt_stream_create_with_id(ds_file_group->sc->ir_sc, ctf_fs_trace->trace, - (uint64_t) ds_file_group->stream_id); - } + BT_ASSERT(ds_file_group->sc->ir_sc); + BT_ASSERT(ctf_fs_trace->trace); + + if (ds_file_group->stream_id == UINT64_C(-1)) { + /* No stream ID: use 0 */ + ds_file_group->stream = bt_stream_create_with_id( + ds_file_group->sc->ir_sc, ctf_fs_trace->trace, ctf_fs_trace->next_stream_id); + ctf_fs_trace->next_stream_id++; } else { - ds_file_group->stream = NULL; + /* Specific stream ID */ + ds_file_group->stream = bt_stream_create_with_id( + ds_file_group->sc->ir_sc, ctf_fs_trace->trace, (uint64_t) ds_file_group->stream_id); } if (!ds_file_group->stream) { -- 2.34.1