src.ctf.fs: use ctf_fs_ds_file::UP in add_ds_file_to_ds_file_group
[babeltrace.git] / src / plugins / ctf / fs-src / fs.cpp
index 272e98d51732abd5c5aa6e0b1b21edaab645906b..00985e6d8c45094c709fb6084207815aac698a2d 100644 (file)
@@ -512,7 +512,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;
     int ret;
-    struct ctf_fs_ds_file *ds_file = NULL;
     ctf_fs_ds_file_info::UP ds_file_info;
     ctf_fs_ds_index::UP index;
     struct ctf_msg_iter *msg_iter = NULL;
@@ -523,7 +522,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
      * Create a temporary ds_file to read some properties about the data
      * stream file.
      */
-    ds_file =
+    const auto ds_file =
         ctf_fs_ds_file_create(ctf_fs_trace, bt2::Stream::Shared {}, path, ctf_fs_trace->logger);
     if (!ds_file) {
         goto error;
@@ -533,7 +532,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
     msg_iter = ctf_msg_iter_create(
         ctf_fs_trace->metadata->tc,
         bt_common_get_page_size(static_cast<int>(ctf_fs_trace->logger.level())) * 8,
-        ctf_fs_ds_file_medops, ds_file, nullptr, ctf_fs_trace->logger);
+        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.");
         goto error;
@@ -572,7 +571,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
         goto error;
     }
 
-    index = ctf_fs_ds_file_build_index(ds_file, ds_file_info.get(), msg_iter);
+    index = ctf_fs_ds_file_build_index(ds_file.get(), ds_file_info.get(), msg_iter);
     if (!index) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger, "Failed to index CTF stream file \'{}\'",
                                      ds_file->file->path);
@@ -640,8 +639,6 @@ error:
     ret = -1;
 
 end:
-    ctf_fs_ds_file_destroy(ds_file);
-
     if (msg_iter) {
         ctf_msg_iter_destroy(msg_iter);
     }
@@ -1119,7 +1116,6 @@ static int decode_clock_snapshot_after_event(struct ctf_fs_trace *ctf_fs_trace,
                                              int64_t *ts_ns)
 {
     enum ctf_msg_iter_status iter_status = CTF_MSG_ITER_STATUS_OK;
-    struct ctf_fs_ds_file *ds_file = NULL;
     struct ctf_msg_iter *msg_iter = NULL;
     int ret = 0;
 
@@ -1127,8 +1123,8 @@ static int decode_clock_snapshot_after_event(struct ctf_fs_trace *ctf_fs_trace,
     BT_ASSERT(index_entry);
     BT_ASSERT(index_entry->path);
 
-    ds_file = ctf_fs_ds_file_create(ctf_fs_trace, bt2::Stream::Shared {}, index_entry->path,
-                                    ctf_fs_trace->logger);
+    const auto ds_file = ctf_fs_ds_file_create(ctf_fs_trace, bt2::Stream::Shared {},
+                                               index_entry->path, ctf_fs_trace->logger);
     if (!ds_file) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger, "Failed to create a ctf_fs_ds_file");
         ret = -1;
@@ -1141,7 +1137,7 @@ static int decode_clock_snapshot_after_event(struct ctf_fs_trace *ctf_fs_trace,
     msg_iter = ctf_msg_iter_create(
         ctf_fs_trace->metadata->tc,
         bt_common_get_page_size(static_cast<int>(ctf_fs_trace->logger.level())) * 8,
-        ctf_fs_ds_file_medops, ds_file, NULL, ctf_fs_trace->logger);
+        ctf_fs_ds_file_medops, ds_file.get(), NULL, ctf_fs_trace->logger);
     if (!msg_iter) {
         /* ctf_msg_iter_create() logs errors. */
         ret = -1;
@@ -1193,9 +1189,6 @@ static int decode_clock_snapshot_after_event(struct ctf_fs_trace *ctf_fs_trace,
     }
 
 end:
-    if (ds_file) {
-        ctf_fs_ds_file_destroy(ds_file);
-    }
     if (msg_iter) {
         ctf_msg_iter_destroy(msg_iter);
     }
This page took 0.02607 seconds and 4 git commands to generate.