src.ctf.fs: use ctf_fs_file::UP in create_ds_file_groups
[babeltrace.git] / src / plugins / ctf / fs-src / fs.cpp
index 8bdc1e0c323310e7b73f667cbcdbbade39494d56..c4428431b290d2b01b41983d295722a0aed834c2 100644 (file)
@@ -666,8 +666,6 @@ static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
     }
 
     while ((basename = g_dir_read_name(dir))) {
-        struct ctf_fs_file *file;
-
         if (strcmp(basename, CTF_FS_METADATA_FILENAME) == 0) {
             /* Ignore the metadata stream. */
             BT_CPPLOGI_SPEC(ctf_fs_trace->logger,
@@ -684,7 +682,7 @@ static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
         }
 
         /* Create the file. */
-        file = ctf_fs_file_create(ctf_fs_trace->logger).release();
+        const auto file = ctf_fs_file_create(ctf_fs_trace->logger);
         if (!file) {
             BT_CPPLOGE_APPEND_CAUSE_SPEC(
                 ctf_fs_trace->logger,
@@ -699,12 +697,10 @@ static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
         if (!g_file_test(file->path->str, G_FILE_TEST_IS_REGULAR)) {
             BT_CPPLOGI_SPEC(ctf_fs_trace->logger, "Ignoring non-regular file `{}`",
                             file->path->str);
-            ctf_fs_file_destroy(file);
-            file = NULL;
             continue;
         }
 
-        ret = ctf_fs_file_open(file, "rb");
+        ret = ctf_fs_file_open(file.get(), "rb");
         if (ret) {
             BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger, "Cannot open stream file `{}`",
                                          file->path->str);
@@ -714,7 +710,6 @@ static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
         if (file->size == 0) {
             /* Skip empty stream. */
             BT_CPPLOGI_SPEC(ctf_fs_trace->logger, "Ignoring empty file `{}`", file->path->str);
-            ctf_fs_file_destroy(file);
             continue;
         }
 
@@ -723,11 +718,8 @@ static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
             BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger,
                                          "Cannot add stream file `{}` to stream file group",
                                          file->path->str);
-            ctf_fs_file_destroy(file);
             goto error;
         }
-
-        ctf_fs_file_destroy(file);
     }
 
     goto end;
This page took 0.024106 seconds and 4 git commands to generate.