From 4726b1eeed55cb732cc4f0efc2ac13207088e549 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 11 Dec 2023 12:24:27 -0500 Subject: [PATCH] src.ctf.fs: remove ctf_fs_file_create Remove this function, it's now just a wrapper around constructing a ctf_fs_file. Change-Id: I95e4d6eb26b0d359e0f480cac51af11f3a1db539 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8297 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/12333 Tested-by: jenkins --- src/plugins/ctf/fs-src/data-stream-file.cpp | 6 +---- src/plugins/ctf/fs-src/file.cpp | 6 ----- src/plugins/ctf/fs-src/file.hpp | 2 -- src/plugins/ctf/fs-src/fs.cpp | 27 ++++++++------------- src/plugins/ctf/fs-src/metadata.cpp | 3 ++- 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/plugins/ctf/fs-src/data-stream-file.cpp b/src/plugins/ctf/fs-src/data-stream-file.cpp index 24b32a2b..e85c854e 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.cpp +++ b/src/plugins/ctf/fs-src/data-stream-file.cpp @@ -805,11 +805,7 @@ ctf_fs_ds_file::UP ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace, auto ds_file = bt2s::make_unique(parentLogger); size_t offset_align; - ds_file->file = ctf_fs_file_create(parentLogger); - if (!ds_file->file) { - goto error; - } - + ds_file->file = bt2s::make_unique(parentLogger); ds_file->stream = std::move(stream); ds_file->metadata = ctf_fs_trace->metadata.get(); ds_file->file->path = path; diff --git a/src/plugins/ctf/fs-src/file.cpp b/src/plugins/ctf/fs-src/file.cpp index 56c9c451..13e279cd 100644 --- a/src/plugins/ctf/fs-src/file.cpp +++ b/src/plugins/ctf/fs-src/file.cpp @@ -8,16 +8,10 @@ #include #include -#include "cpp-common/bt2s/make-unique.hpp" #include "cpp-common/vendor/fmt/format.h" #include "file.hpp" -ctf_fs_file::UP ctf_fs_file_create(const bt2c::Logger& parentLogger) -{ - return bt2s::make_unique(parentLogger); -} - int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode) { int ret = 0; diff --git a/src/plugins/ctf/fs-src/file.hpp b/src/plugins/ctf/fs-src/file.hpp index d367cb50..ee6441cb 100644 --- a/src/plugins/ctf/fs-src/file.hpp +++ b/src/plugins/ctf/fs-src/file.hpp @@ -33,8 +33,6 @@ struct ctf_fs_file off_t size = 0; }; -ctf_fs_file::UP ctf_fs_file_create(const bt2c::Logger& parentLogger); - int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode); #endif /* CTF_FS_FILE_H */ diff --git a/src/plugins/ctf/fs-src/fs.cpp b/src/plugins/ctf/fs-src/fs.cpp index 7d96e6a4..113bf8d3 100644 --- a/src/plugins/ctf/fs-src/fs.cpp +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -613,41 +613,34 @@ static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace) } /* Create the file. */ - const auto file = ctf_fs_file_create(ctf_fs_trace->logger); - if (!file) { - BT_CPPLOGE_APPEND_CAUSE_SPEC( - ctf_fs_trace->logger, - "Cannot create stream file object for file `{}" G_DIR_SEPARATOR_S "{}`", - ctf_fs_trace->path, basename); - goto error; - } + ctf_fs_file file {ctf_fs_trace->logger}; /* Create full path string. */ - file->path = fmt::format("{}" G_DIR_SEPARATOR_S "{}", ctf_fs_trace->path, basename); + file.path = fmt::format("{}" G_DIR_SEPARATOR_S "{}", ctf_fs_trace->path, basename); - if (!g_file_test(file->path.c_str(), G_FILE_TEST_IS_REGULAR)) { - BT_CPPLOGI_SPEC(ctf_fs_trace->logger, "Ignoring non-regular file `{}`", file->path); + if (!g_file_test(file.path.c_str(), G_FILE_TEST_IS_REGULAR)) { + BT_CPPLOGI_SPEC(ctf_fs_trace->logger, "Ignoring non-regular file `{}`", file.path); continue; } - ret = ctf_fs_file_open(file.get(), "rb"); + ret = ctf_fs_file_open(&file, "rb"); if (ret) { BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger, "Cannot open stream file `{}`", - file->path); + file.path); goto error; } - if (file->size == 0) { + if (file.size == 0) { /* Skip empty stream. */ - BT_CPPLOGI_SPEC(ctf_fs_trace->logger, "Ignoring empty file `{}`", file->path); + BT_CPPLOGI_SPEC(ctf_fs_trace->logger, "Ignoring empty file `{}`", file.path); continue; } - ret = add_ds_file_to_ds_file_group(ctf_fs_trace, file->path.c_str()); + ret = add_ds_file_to_ds_file_group(ctf_fs_trace, file.path.c_str()); if (ret) { BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger, "Cannot add stream file `{}` to stream file group", - file->path); + file.path); goto error; } } diff --git a/src/plugins/ctf/fs-src/metadata.cpp b/src/plugins/ctf/fs-src/metadata.cpp index f19a1f47..bf905d3a 100644 --- a/src/plugins/ctf/fs-src/metadata.cpp +++ b/src/plugins/ctf/fs-src/metadata.cpp @@ -6,6 +6,7 @@ */ #include "common/assert.h" +#include "cpp-common/bt2s/make-unique.hpp" #include "../common/src/metadata/tsdl/decoder.hpp" #include "file.hpp" @@ -37,7 +38,7 @@ end: static ctf_fs_file::UP get_file(const bt2c::CStringView trace_path, const bt2c::Logger& logger) { - auto file = ctf_fs_file_create(logger); + auto file = bt2s::make_unique(logger); if (!file) { goto error; -- 2.34.1