src.ctf.fs: remove ctf_fs_ds_index::UP
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 9 Apr 2024 19:44:48 +0000 (15:44 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
We don't need to dynamically allocate ctf_fs_ds_index objects, we can
store / return / pass objects directly.  Remove ctf_fs_ds_index::UP and
update all users.

Change-Id: I7ce9de83b111c782299a1caebea3ead0fd945cb5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8401
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12344
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/fs-src/data-stream-file.cpp
src/plugins/ctf/fs-src/data-stream-file.hpp
src/plugins/ctf/fs-src/fs.cpp
src/plugins/ctf/fs-src/query.cpp

index 41950683ad12edc089d561916feb896f1b58528d..f578e1e3dc53a8d3088a823dcc5ddb90e47a37ac 100644 (file)
@@ -312,7 +312,7 @@ static enum ctf_msg_iter_medium_status medop_group_switch_packet(void *void_data
     struct ctf_fs_ds_group_medops_data *data = (struct ctf_fs_ds_group_medops_data *) void_data;
 
     /* If we have gone through all index entries, we are done. */
-    if (data->next_index_entry_index >= data->ds_file_group->index->entries.size()) {
+    if (data->next_index_entry_index >= data->ds_file_group->index.entries.size()) {
         return CTF_MSG_ITER_MEDIUM_STATUS_EOF;
     }
 
@@ -321,7 +321,7 @@ static enum ctf_msg_iter_medium_status medop_group_switch_packet(void *void_data
      *  for reading.
      */
     ctf_msg_iter_medium_status status = ctf_fs_ds_group_medops_set_file(
-        data, &data->ds_file_group->index->entries[data->next_index_entry_index]);
+        data, &data->ds_file_group->index.entries[data->next_index_entry_index]);
     if (status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
         return status;
     }
@@ -342,8 +342,7 @@ enum ctf_msg_iter_medium_status ctf_fs_ds_group_medops_data_create(
 {
     BT_ASSERT(self_msg_iter);
     BT_ASSERT(ds_file_group);
-    BT_ASSERT(ds_file_group->index);
-    BT_ASSERT(!ds_file_group->index->entries.empty());
+    BT_ASSERT(!ds_file_group->index.entries.empty());
 
     out.reset(new ctf_fs_ds_group_medops_data {parentLogger});
 
@@ -384,9 +383,9 @@ static int convert_cycles_to_ns(struct ctf_clock_class *clock_class, uint64_t cy
                                                   clock_class->offset_cycles, ns);
 }
 
-static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_file,
-                                                     struct ctf_fs_ds_file_info *file_info,
-                                                     struct ctf_msg_iter *msg_iter)
+static bt2s::optional<ctf_fs_ds_index>
+build_index_from_idx_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_info *file_info,
+                          struct ctf_msg_iter *msg_iter)
 {
     bt2c::GCharUP directory;
     bt2c::GCharUP basename;
@@ -396,7 +395,6 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
     gsize filesize;
     const char *mmap_begin = NULL, *file_pos = NULL;
     const struct ctf_packet_index_file_hdr *header = NULL;
-    ctf_fs_ds_index::UP index;
     ctf_fs_ds_index_entry *prev_index_entry = NULL;
     auto totalPacketsSize = bt2c::DataLen::fromBytes(0);
     size_t file_index_entry_size;
@@ -412,14 +410,14 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
     if (ret) {
         BT_CPPLOGI_STR_SPEC(ds_file->logger,
                             "Cannot read first packet's header and context fields.");
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     sc = ctf_trace_class_borrow_stream_class_by_id(ds_file->metadata->tc, props.stream_class_id);
     BT_ASSERT(sc);
     if (!sc->default_clock_class) {
         BT_CPPLOGI_STR_SPEC(ds_file->logger, "Cannot find stream class's default clock class.");
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     /* Look for index file in relative path index/name.idx. */
@@ -427,14 +425,14 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
     if (!basename) {
         BT_CPPLOGE_SPEC(ds_file->logger, "Cannot get the basename of datastream file {}",
                         ds_file->file->path);
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     directory.reset(g_path_get_dirname(ds_file->file->path.c_str()));
     if (!directory) {
         BT_CPPLOGE_SPEC(ds_file->logger, "Cannot get dirname of datastream file {}",
                         ds_file->file->path);
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     index_basename = fmt::format("{}.idx", basename.get());
@@ -442,7 +440,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
     mapped_file.reset(g_mapped_file_new(index_file_path.get(), FALSE, NULL));
     if (!mapped_file) {
         BT_CPPLOGD_SPEC(ds_file->logger, "Cannot create new mapped file {}", index_file_path.get());
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     /*
@@ -456,7 +454,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
                         "Invalid LTTng trace index file: "
                         "file size ({} bytes) < header size ({} bytes)",
                         filesize, sizeof(*header));
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     mmap_begin = g_mapped_file_get_contents(mapped_file.get());
@@ -466,7 +464,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
     if (be32toh(header->magic) != CTF_INDEX_MAGIC) {
         BT_CPPLOGW_STR_SPEC(ds_file->logger,
                             "Invalid LTTng trace index: \"magic\" field validation failed");
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     version_major = be32toh(header->index_major);
@@ -474,7 +472,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
     if (version_major != 1) {
         BT_CPPLOGW_SPEC(ds_file->logger, "Unknown LTTng trace index version: major={}, minor={}",
                         version_major, version_minor);
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     file_index_entry_size = be32toh(header->packet_index_len);
@@ -484,7 +482,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
             "Invalid `packet_index_len` in LTTng trace index file (`packet_index_len` < CTF index 1.0 index entry size): "
             "packet_index_len={}, CTF_INDEX_1_0_SIZE={}",
             file_index_entry_size, CTF_INDEX_1_0_SIZE);
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     file_entry_count = (filesize - sizeof(*header)) / file_index_entry_size;
@@ -494,10 +492,10 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
                         "({} bytes) is not a multiple of the index entry size "
                         "({} bytes)",
                         (filesize - sizeof(*header)), sizeof(*header));
-        return nullptr;
+        return bt2s::nullopt;
     }
 
-    index = bt2s::make_unique<ctf_fs_ds_index>();
+    ctf_fs_ds_index index;
 
     for (i = 0; i < file_entry_count; i++) {
         struct ctf_packet_index *file_index = (struct ctf_packet_index *) file_pos;
@@ -506,7 +504,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
         if (packetSize.hasExtraBits()) {
             BT_CPPLOGW_SPEC(ds_file->logger,
                             "Invalid packet size encountered in LTTng trace index file");
-            return nullptr;
+            return bt2s::nullopt;
         }
 
         const auto offset = bt2c::DataLen::fromBytes(be64toh(file_index->offset));
@@ -517,7 +515,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
                 "Invalid, non-monotonic, packet offset encountered in LTTng trace index file: "
                 "previous offset={} bytes, current offset={} bytes",
                 prev_index_entry->offset.bytes(), offset.bytes());
-            return nullptr;
+            return bt2s::nullopt;
         }
 
         ctf_fs_ds_index_entry index_entry {offset, packetSize};
@@ -533,7 +531,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
                 "Invalid packet time bounds encountered in LTTng trace index file (begin > end): "
                 "timestamp_begin={}, timestamp_end={}",
                 index_entry.timestamp_begin, index_entry.timestamp_end);
-            return nullptr;
+            return bt2s::nullopt;
         }
 
         /* Convert the packet's bound to nanoseconds since Epoch. */
@@ -543,7 +541,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
             BT_CPPLOGI_STR_SPEC(
                 ds_file->logger,
                 "Failed to convert raw timestamp to nanoseconds since Epoch during index parsing");
-            return nullptr;
+            return bt2s::nullopt;
         }
         ret = convert_cycles_to_ns(sc->default_clock_class, index_entry.timestamp_end,
                                    &index_entry.timestamp_end_ns);
@@ -551,7 +549,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
             BT_CPPLOGI_STR_SPEC(
                 ds_file->logger,
                 "Failed to convert raw timestamp to nanoseconds since Epoch during LTTng trace index parsing");
-            return nullptr;
+            return bt2s::nullopt;
         }
 
         if (version_minor >= 1) {
@@ -561,9 +559,9 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
         totalPacketsSize += packetSize;
         file_pos += file_index_entry_size;
 
-        index->entries.emplace_back(index_entry);
+        index.entries.emplace_back(index_entry);
 
-        prev_index_entry = &index->entries.back();
+        prev_index_entry = &index.entries.back();
     }
 
     /* Validate that the index addresses the complete stream. */
@@ -572,7 +570,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
                         "Invalid LTTng trace index file; indexed size != stream file size: "
                         "file-size={} bytes, total-packets-size={} bytes",
                         ds_file->file->size, totalPacketsSize.bytes());
-        return nullptr;
+        return bt2s::nullopt;
     }
 
     return index;
@@ -621,9 +619,9 @@ static int init_index_entry(ctf_fs_ds_index_entry& entry, struct ctf_fs_ds_file
     return 0;
 }
 
-static ctf_fs_ds_index::UP build_index_from_stream_file(struct ctf_fs_ds_file *ds_file,
-                                                        struct ctf_fs_ds_file_info *file_info,
-                                                        struct ctf_msg_iter *msg_iter)
+static bt2s::optional<ctf_fs_ds_index>
+build_index_from_stream_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_info *file_info,
+                             struct ctf_msg_iter *msg_iter)
 {
     int ret;
     enum ctf_msg_iter_status iter_status = CTF_MSG_ITER_STATUS_OK;
@@ -631,7 +629,7 @@ static ctf_fs_ds_index::UP build_index_from_stream_file(struct ctf_fs_ds_file *d
 
     BT_CPPLOGI_SPEC(ds_file->logger, "Indexing stream file {}", ds_file->file->path);
 
-    ctf_fs_ds_index::UP index = bt2s::make_unique<ctf_fs_ds_index>();
+    ctf_fs_ds_index index;
 
     while (true) {
         struct ctf_msg_iter_packet_properties props;
@@ -639,7 +637,7 @@ static ctf_fs_ds_index::UP build_index_from_stream_file(struct ctf_fs_ds_file *d
         if (currentPacketOffset.bytes() > ds_file->file->size) {
             BT_CPPLOGE_STR_SPEC(ds_file->logger,
                                 "Unexpected current packet's offset (larger than file).");
-            return nullptr;
+            return bt2s::nullopt;
         } else if (currentPacketOffset.bytes() == ds_file->file->size) {
             /* No more data */
             break;
@@ -647,12 +645,12 @@ static ctf_fs_ds_index::UP build_index_from_stream_file(struct ctf_fs_ds_file *d
 
         iter_status = ctf_msg_iter_seek(msg_iter, currentPacketOffset.bytes());
         if (iter_status != CTF_MSG_ITER_STATUS_OK) {
-            return nullptr;
+            return bt2s::nullopt;
         }
 
         iter_status = ctf_msg_iter_get_packet_properties(msg_iter, &props);
         if (iter_status != CTF_MSG_ITER_STATUS_OK) {
-            return nullptr;
+            return bt2s::nullopt;
         }
 
         /*
@@ -671,7 +669,7 @@ static ctf_fs_ds_index::UP build_index_from_stream_file(struct ctf_fs_ds_file *d
                             "file-size-bytes={}",
                             ds_file->file->path, currentPacketOffset.bytes(),
                             currentPacketSize.bytes(), ds_file->file->size);
-            return nullptr;
+            return bt2s::nullopt;
         }
 
         ctf_fs_ds_index_entry index_entry {currentPacketOffset, currentPacketSize};
@@ -681,10 +679,10 @@ static ctf_fs_ds_index::UP build_index_from_stream_file(struct ctf_fs_ds_file *d
 
         ret = init_index_entry(index_entry, ds_file, &props);
         if (ret) {
-            return nullptr;
+            return bt2s::nullopt;
         }
 
-        index->entries.emplace_back(index_entry);
+        index.entries.emplace_back(index_entry);
 
         currentPacketOffset += currentPacketSize;
         BT_CPPLOGD_SPEC(ds_file->logger,
@@ -720,9 +718,9 @@ ctf_fs_ds_file::UP ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace,
     return ds_file;
 }
 
-ctf_fs_ds_index::UP ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file,
-                                               struct ctf_fs_ds_file_info *file_info,
-                                               struct ctf_msg_iter *msg_iter)
+bt2s::optional<ctf_fs_ds_index> ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file,
+                                                           struct ctf_fs_ds_file_info *file_info,
+                                                           struct ctf_msg_iter *msg_iter)
 {
     auto index = build_index_from_idx_file(ds_file, file_info, msg_iter);
     if (index) {
@@ -751,7 +749,7 @@ ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t beg
 ctf_fs_ds_file_group::UP ctf_fs_ds_file_group_create(struct ctf_fs_trace *ctf_fs_trace,
                                                      struct ctf_stream_class *sc,
                                                      uint64_t stream_instance_id,
-                                                     ctf_fs_ds_index::UP index)
+                                                     ctf_fs_ds_index index)
 {
     ctf_fs_ds_file_group::UP ds_file_group {new ctf_fs_ds_file_group};
 
index d99760bbd1fad426e1dec604f6bf5089158ff5dd..6abca11b438693dedadb6522ffc7b54250ca6222 100644 (file)
@@ -114,8 +114,6 @@ struct ctf_fs_ds_index_entry
 
 struct ctf_fs_ds_index
 {
-    using UP = std::unique_ptr<ctf_fs_ds_index>;
-
     std::vector<ctf_fs_ds_index_entry> entries;
 };
 
@@ -143,22 +141,22 @@ struct ctf_fs_ds_file_group
     /* Weak, belongs to component */
     struct ctf_fs_trace *ctf_fs_trace = nullptr;
 
-    ctf_fs_ds_index::UP index;
+    ctf_fs_ds_index index;
 };
 
 ctf_fs_ds_file::UP ctf_fs_ds_file_create(ctf_fs_trace *ctf_fs_trace, bt2::Stream::Shared stream,
                                          const char *path, const bt2c::Logger& logger);
 
-ctf_fs_ds_index::UP ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file,
-                                               struct ctf_fs_ds_file_info *ds_file_info,
-                                               struct ctf_msg_iter *msg_iter);
+bt2s::optional<ctf_fs_ds_index> ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file,
+                                                           struct ctf_fs_ds_file_info *ds_file_info,
+                                                           struct ctf_msg_iter *msg_iter);
 
 ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns);
 
 ctf_fs_ds_file_group::UP ctf_fs_ds_file_group_create(struct ctf_fs_trace *ctf_fs_trace,
                                                      struct ctf_stream_class *sc,
                                                      uint64_t stream_instance_id,
-                                                     ctf_fs_ds_index::UP index);
+                                                     ctf_fs_ds_index index);
 
 /*
  * Medium operations to iterate on a single ctf_fs_ds_file.
index 900db23fb32241a1ee68a7deba60b2ba601f6a8a..26ec15392f9e130c68261e13a0f861a958feaf7a 100644 (file)
@@ -420,7 +420,6 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
     struct ctf_fs_ds_file_group *ds_file_group = NULL;
     ctf_fs_ds_file_group::UP new_ds_file_group;
     ctf_fs_ds_file_info::UP ds_file_info;
-    ctf_fs_ds_index::UP index;
     ctf_msg_iter_up msg_iter;
     struct ctf_stream_class *sc = NULL;
     struct ctf_msg_iter_packet_properties props;
@@ -478,7 +477,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
         return -1;
     }
 
-    index = ctf_fs_ds_file_build_index(ds_file.get(), ds_file_info.get(), msg_iter.get());
+    auto index = ctf_fs_ds_file_build_index(ds_file.get(), ds_file_info.get(), msg_iter.get());
     if (!index) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger, "Failed to index CTF stream file \'{}\'",
                                      ds_file->file->path);
@@ -503,7 +502,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
          * group.
          */
         new_ds_file_group =
-            ctf_fs_ds_file_group_create(ctf_fs_trace, sc, UINT64_C(-1), std::move(index));
+            ctf_fs_ds_file_group_create(ctf_fs_trace, sc, UINT64_C(-1), std::move(*index));
 
         if (!new_ds_file_group) {
             return -1;
@@ -527,7 +526,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
 
     if (!ds_file_group) {
         new_ds_file_group =
-            ctf_fs_ds_file_group_create(ctf_fs_trace, sc, stream_instance_id, std::move(index));
+            ctf_fs_ds_file_group_create(ctf_fs_trace, sc, stream_instance_id, std::move(*index));
         if (!new_ds_file_group) {
             return -1;
         }
@@ -535,7 +534,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
         ds_file_group = new_ds_file_group.get();
         ctf_fs_trace->ds_file_groups.emplace_back(std::move(new_ds_file_group));
     } else {
-        merge_ctf_fs_ds_indexes(ds_file_group->index.get(), *index);
+        merge_ctf_fs_ds_indexes(&ds_file_group->index, *index);
     }
 
     ds_file_group_insert_ds_file_info_sorted(ds_file_group, std::move(ds_file_info));
@@ -771,7 +770,7 @@ static void merge_ctf_fs_ds_file_groups(struct ctf_fs_ds_file_group *dest,
     }
 
     /* Merge both indexes. */
-    merge_ctf_fs_ds_indexes(dest->index.get(), *src->index);
+    merge_ctf_fs_ds_indexes(&dest->index, src->index);
 }
 
 /* Merge src_trace's data stream file groups into dest_trace's. */
@@ -831,8 +830,8 @@ static int merge_matching_ctf_fs_ds_file_groups(struct ctf_fs_trace *dest_trace,
                                                            src_group->sc->id);
             BT_ASSERT(sc);
 
-            auto new_dest_group = ctf_fs_ds_file_group_create(dest_trace, sc, src_group->stream_id,
-                                                              bt2s::make_unique<ctf_fs_ds_index>());
+            auto new_dest_group =
+                ctf_fs_ds_file_group_create(dest_trace, sc, src_group->stream_id, {});
 
             if (!new_dest_group) {
                 return -1;
@@ -1033,18 +1032,17 @@ static int fix_index_lttng_event_after_packet_bug(struct ctf_fs_trace *trace)
         struct ctf_clock_class *default_cc;
 
         BT_ASSERT(ds_file_group);
-        const auto index = ds_file_group->index.get();
+        auto& index = ds_file_group->index;
 
-        BT_ASSERT(index);
-        BT_ASSERT(!index->entries.empty());
+        BT_ASSERT(!index.entries.empty());
 
         /*
          * Iterate over all entries but the last one. The last one is
          * fixed differently after.
          */
-        for (size_t entry_i = 0; entry_i < index->entries.size() - 1; ++entry_i) {
-            auto& curr_entry = index->entries[entry_i];
-            const auto& next_entry = index->entries[entry_i + 1];
+        for (size_t entry_i = 0; entry_i < index.entries.size() - 1; ++entry_i) {
+            auto& curr_entry = index.entries[entry_i];
+            const auto& next_entry = index.entries[entry_i + 1];
 
             /*
              * 1. Set the current index entry `end` timestamp to
@@ -1058,7 +1056,7 @@ static int fix_index_lttng_event_after_packet_bug(struct ctf_fs_trace *trace)
          * 2. Fix the last entry by decoding the last event of the last
          * packet.
          */
-        auto& last_entry = index->entries.back();
+        auto& last_entry = index.entries.back();
 
         BT_ASSERT(ds_file_group->sc->default_clock_class);
         default_cc = ds_file_group->sc->default_clock_class;
@@ -1098,10 +1096,9 @@ static int fix_index_barectf_event_before_packet_bug(struct ctf_fs_trace *trace)
 {
     for (const auto& ds_file_group : trace->ds_file_groups) {
         struct ctf_clock_class *default_cc;
-        const auto index = ds_file_group->index.get();
+        auto& index = ds_file_group->index;
 
-        BT_ASSERT(index);
-        BT_ASSERT(!index->entries.empty());
+        BT_ASSERT(!index.entries.empty());
 
         BT_ASSERT(ds_file_group->sc->default_clock_class);
         default_cc = ds_file_group->sc->default_clock_class;
@@ -1110,9 +1107,9 @@ static int fix_index_barectf_event_before_packet_bug(struct ctf_fs_trace *trace)
          * 1. Iterate over the index, starting from the second entry
          * (index = 1).
          */
-        for (size_t entry_i = 1; entry_i < index->entries.size(); ++entry_i) {
-            auto& prev_entry = index->entries[entry_i - 1];
-            auto& curr_entry = index->entries[entry_i];
+        for (size_t entry_i = 1; entry_i < index.entries.size(); ++entry_i) {
+            auto& prev_entry = index.entries[entry_i - 1];
+            auto& curr_entry = index.entries[entry_i];
             /*
              * 2. Set the current entry `begin` timestamp to the
              * timestamp of the first event of the current packet.
@@ -1161,15 +1158,14 @@ static int fix_index_lttng_crash_quirk(struct ctf_fs_trace *trace)
         struct ctf_clock_class *default_cc;
 
         BT_ASSERT(ds_file_group);
-        const auto index = ds_file_group->index.get();
+        auto& index = ds_file_group->index;
 
         BT_ASSERT(ds_file_group->sc->default_clock_class);
         default_cc = ds_file_group->sc->default_clock_class;
 
-        BT_ASSERT(index);
-        BT_ASSERT(!index->entries.empty());
+        BT_ASSERT(!index.entries.empty());
 
-        auto& last_entry = index->entries.back();
+        auto& last_entry = index.entries.back();
 
         /* 1. Fix the last entry first. */
         if (last_entry.timestamp_end == 0 && last_entry.timestamp_begin != 0) {
@@ -1188,9 +1184,9 @@ static int fix_index_lttng_crash_quirk(struct ctf_fs_trace *trace)
         }
 
         /* Iterate over all entries but the last one. */
-        for (size_t entry_idx = 0; entry_idx < index->entries.size() - 1; ++entry_idx) {
-            auto& curr_entry = index->entries[entry_idx];
-            const auto& next_entry = index->entries[entry_idx + 1];
+        for (size_t entry_idx = 0; entry_idx < index.entries.size() - 1; ++entry_idx) {
+            auto& curr_entry = index.entries[entry_idx];
+            const auto& next_entry = index.entries[entry_idx + 1];
 
             if (curr_entry.timestamp_end == 0 && curr_entry.timestamp_begin != 0) {
                 /*
index 890a3445b62fb3c0e755ebc0e03c8bd519791348..729dc5acaef4d793572ab0cd61dbe5293c366479 100644 (file)
@@ -123,14 +123,13 @@ static void populate_stream_info(struct ctf_fs_ds_file_group *group, const bt2::
      * the timestamp_begin of the first index entry and the timestamp_end
      * of the last index entry.
      */
-    BT_ASSERT(group->index);
-    BT_ASSERT(!group->index->entries.empty());
+    BT_ASSERT(!group->index.entries.empty());
 
     /* First entry. */
-    const auto& first_ds_index_entry = group->index->entries.front();
+    const auto& first_ds_index_entry = group->index.entries.front();
 
     /* Last entry. */
-    const auto& last_ds_index_entry = group->index->entries.back();
+    const auto& last_ds_index_entry = group->index.entries.back();
 
     stream_range->begin_ns = first_ds_index_entry.timestamp_begin_ns;
     stream_range->end_ns = last_ds_index_entry.timestamp_end_ns;
This page took 0.035741 seconds and 4 git commands to generate.