From 2b6f09e084ab556aae9d1920926b3b7d91f3b272 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 5 Dec 2023 03:17:40 +0000 Subject: [PATCH] src.ctf.fs: use ctf_fs_file::UP in create_ds_file_groups Change-Id: I45b50e6c808d5ae17ac755b96e03f260a0972c15 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8262 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/12300 --- src/plugins/ctf/fs-src/fs.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/plugins/ctf/fs-src/fs.cpp b/src/plugins/ctf/fs-src/fs.cpp index 8bdc1e0c..c4428431 100644 --- a/src/plugins/ctf/fs-src/fs.cpp +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -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; -- 2.34.1