doc/api/libbabeltrace2/DoxygenLayout.xml: use `topics` tab
[babeltrace.git] / src / plugins / ctf / fs-src / fs.cpp
index 02cf97df32426d5c74b2d12b68de992e7ca3b52a..e86d30cecf8544041365c4d23890b44722c01fe4 100644 (file)
@@ -406,7 +406,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
         bt_common_get_page_size(static_cast<int>(ctf_fs_trace->logger.level())) * 8,
         ctf_fs_ds_file_medops, ds_file.get(), nullptr, ctf_fs_trace->logger);
     if (!msg_iter) {
-        BT_CPPLOGE_STR_SPEC(ctf_fs_trace->logger, "Cannot create a CTF message iterator.");
+        BT_CPPLOGE_SPEC(ctf_fs_trace->logger, "Cannot create a CTF message iterator.");
         return -1;
     }
 
@@ -470,15 +470,9 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
          * there's no timestamp to order the file within its
          * group.
          */
-        auto new_ds_file_group =
-            ctf_fs_ds_file_group_create(ctf_fs_trace, sc, UINT64_C(-1), std::move(*index));
-
-        if (!new_ds_file_group) {
-            return -1;
-        }
-
-        new_ds_file_group->insert_ds_file_info_sorted(std::move(ds_file_info));
-        ctf_fs_trace->ds_file_groups.emplace_back(std::move(new_ds_file_group));
+        ctf_fs_trace->ds_file_groups.emplace_back(bt2s::make_unique<ctf_fs_ds_file_group>(
+            ctf_fs_trace, sc, UINT64_C(-1), std::move(*index)));
+        ctf_fs_trace->ds_file_groups.back()->insert_ds_file_info_sorted(std::move(ds_file_info));
         return 0;
     }
 
@@ -494,17 +488,10 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
         }
     }
 
-    ctf_fs_ds_file_group::UP new_ds_file_group;
-
     if (!ds_file_group) {
-        new_ds_file_group =
-            ctf_fs_ds_file_group_create(ctf_fs_trace, sc, stream_instance_id, std::move(*index));
-        if (!new_ds_file_group) {
-            return -1;
-        }
-
-        ds_file_group = new_ds_file_group.get();
-        ctf_fs_trace->ds_file_groups.emplace_back(std::move(new_ds_file_group));
+        ctf_fs_trace->ds_file_groups.emplace_back(bt2s::make_unique<ctf_fs_ds_file_group>(
+            ctf_fs_trace, sc, static_cast<std::uint64_t>(stream_instance_id), std::move(*index)));
+        ds_file_group = ctf_fs_trace->ds_file_groups.back().get();
     } else {
         merge_ctf_fs_ds_indexes(ds_file_group->index, *index);
     }
@@ -786,15 +773,9 @@ static int merge_matching_ctf_fs_ds_file_groups(struct ctf_fs_trace *dest_trace,
                 dest_trace->metadata->tc, src_group->sc->id);
             BT_ASSERT(sc);
 
-            auto new_dest_group =
-                ctf_fs_ds_file_group_create(dest_trace, sc, src_group->stream_id, {});
-
-            if (!new_dest_group) {
-                return -1;
-            }
-
-            dest_group = new_dest_group.get();
-            dest_trace->ds_file_groups.emplace_back(std::move(new_dest_group));
+            dest_trace->ds_file_groups.emplace_back(bt2s::make_unique<ctf_fs_ds_file_group>(
+                dest_trace, sc, src_group->stream_id, ctf_fs_ds_index {}));
+            dest_group = dest_trace->ds_file_groups.back().get();
         }
 
         BT_ASSERT(dest_group);
@@ -966,10 +947,10 @@ static int decode_packet_last_event_timestamp(struct ctf_fs_trace *ctf_fs_trace,
  *
  * To fix up this erroneous data we do the following:
  *  1. If it's not the stream file's last packet: set the packet index entry's
- *     end time to the next packet's beginning time.
+ *     end time to the next packet's beginning time.
  *  2. If it's the stream file's last packet, set the packet index entry's end
- *     time to the packet's last event's time, if any, or to the packet's
- *     beginning time otherwise.
+ *     time to the packet's last event's time, if any, or to the packet's
+ *     beginning time otherwise.
  *
  * Known buggy tracer versions:
  *  - before lttng-ust 2.11.0
@@ -1301,7 +1282,7 @@ static int fix_packet_index_tracer_bugs(ctf_fs_trace *trace)
          * are needed. Failing to extract these entries is not
          * an error.
          */
-        BT_CPPLOGI_STR_SPEC(
+        BT_CPPLOGI_SPEC(
             trace->logger,
             "Cannot extract tracer information necessary to compare with buggy versions.");
         return 0;
@@ -1309,9 +1290,8 @@ static int fix_packet_index_tracer_bugs(ctf_fs_trace *trace)
 
     /* Check if the trace may be affected by old tracer bugs. */
     if (is_tracer_affected_by_lttng_event_after_packet_bug(&current_tracer_info)) {
-        BT_CPPLOGI_STR_SPEC(
-            trace->logger,
-            "Trace may be affected by LTTng tracer packet timestamp bug. Fixing up.");
+        BT_CPPLOGI_SPEC(trace->logger,
+                        "Trace may be affected by LTTng tracer packet timestamp bug. Fixing up.");
         ret = fix_index_lttng_event_after_packet_bug(trace);
         if (ret) {
             BT_CPPLOGE_APPEND_CAUSE_SPEC(trace->logger,
@@ -1322,9 +1302,8 @@ static int fix_packet_index_tracer_bugs(ctf_fs_trace *trace)
     }
 
     if (is_tracer_affected_by_barectf_event_before_packet_bug(&current_tracer_info)) {
-        BT_CPPLOGI_STR_SPEC(
-            trace->logger,
-            "Trace may be affected by barectf tracer packet timestamp bug. Fixing up.");
+        BT_CPPLOGI_SPEC(trace->logger,
+                        "Trace may be affected by barectf tracer packet timestamp bug. Fixing up.");
         ret = fix_index_barectf_event_before_packet_bug(trace);
         if (ret) {
             BT_CPPLOGE_APPEND_CAUSE_SPEC(trace->logger,
@@ -1481,31 +1460,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);
-        }
-
-        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 = sc.instantiate(*ctf_fs_trace->trace, ds_file_group->stream_id);
         }
 
-        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.025193 seconds and 4 git commands to generate.