src.ctf.fs: make create_streams_for_trace use bt2::StreamClass to instantiate streams
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 6 Dec 2023 21:34:54 +0000 (21:34 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Wrap the stream class (ds_file_group->sc->ir_sc) in a bt2::StreamClass,
then use that to instantiate streams.

Change-Id: I9e9917dd96b0d1115b443463a0a2cd8f2da42323
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8437
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12362
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/fs-src/fs.cpp

index 09f663e342b2d739944cf594ad0204a94fb7b688..f9b2523caa4a52b00b1429e73cda272abe549a69 100644 (file)
@@ -1462,31 +1462,18 @@ static int create_streams_for_trace(struct ctf_fs_trace *ctf_fs_trace)
         BT_ASSERT(ds_file_group->sc->ir_sc);
         BT_ASSERT(ctf_fs_trace->trace);
 
-        bt_stream *stream;
+        const bt2::StreamClass sc {ds_file_group->sc->ir_sc};
 
         if (ds_file_group->stream_id == UINT64_C(-1)) {
             /* No stream ID: use 0 */
-            stream =
-                bt_stream_create_with_id(ds_file_group->sc->ir_sc, ctf_fs_trace->trace->libObjPtr(),
-                                         ctf_fs_trace->next_stream_id);
+            ds_file_group->stream =
+                sc.instantiate(*ctf_fs_trace->trace, ctf_fs_trace->next_stream_id);
             ctf_fs_trace->next_stream_id++;
         } else {
             /* Specific stream ID */
-            stream =
-                bt_stream_create_with_id(ds_file_group->sc->ir_sc, ctf_fs_trace->trace->libObjPtr(),
-                                         (uint64_t) ds_file_group->stream_id);
+            ds_file_group->stream = sc.instantiate(*ctf_fs_trace->trace, ds_file_group->stream_id);
         }
 
-        if (!stream) {
-            BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger,
-                                         "Cannot create stream for DS file group: "
-                                         "addr={}, stream-name=\"{}\"",
-                                         fmt::ptr(ds_file_group), name);
-            return -1;
-        }
-
-        ds_file_group->stream = bt2::Stream::Shared::createWithoutRef(stream);
-
         int ret = bt_stream_set_name(ds_file_group->stream->libObjPtr(), name.c_str());
         if (ret) {
             BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger,
This page took 0.025105 seconds and 4 git commands to generate.