src.ctf.fs: use ctf_fs_file::UP in create_ds_file_groups
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 5 Dec 2023 03:17:40 +0000 (03:17 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Change-Id: I45b50e6c808d5ae17ac755b96e03f260a0972c15
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8262
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12300

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.025305 seconds and 4 git commands to generate.