src.ctf.fs: remove ctf_fs_file_create
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 11 Dec 2023 17:24:27 +0000 (12:24 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Remove this function, it's now just a wrapper around constructing a
ctf_fs_file.

Change-Id: I95e4d6eb26b0d359e0f480cac51af11f3a1db539
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8297
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12333
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/fs-src/data-stream-file.cpp
src/plugins/ctf/fs-src/file.cpp
src/plugins/ctf/fs-src/file.hpp
src/plugins/ctf/fs-src/fs.cpp
src/plugins/ctf/fs-src/metadata.cpp

index 24b32a2bab175c1f556da1b0a061313dcd4f7868..e85c854ee08e13b7813d2bcf9b44940c972147fa 100644 (file)
@@ -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<ctf_fs_ds_file>(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<ctf_fs_file>(parentLogger);
     ds_file->stream = std::move(stream);
     ds_file->metadata = ctf_fs_trace->metadata.get();
     ds_file->file->path = path;
index 56c9c451da2b8089591f62d941db73b5282adf60..13e279cd38b1fb085318f36c2bbb31555ea3995d 100644 (file)
@@ -8,16 +8,10 @@
 #include <stdio.h>
 #include <sys/stat.h>
 
-#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<ctf_fs_file>(parentLogger);
-}
-
 int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode)
 {
     int ret = 0;
index d367cb505b074f544a93e80d59e339884ff1081b..ee6441cbe6bdaa9c8887d49ec7e30e5baea6d1aa 100644 (file)
@@ -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 */
index 7d96e6a46fbf8de54b068f1c04032efe6990cf88..113bf8d30c75a414f4421a14d82ec898ea33c426 100644 (file)
@@ -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;
         }
     }
index f19a1f47da7e3fe43b76e2aa735de650e61e41c8..bf905d3ae0975c3c88b29cdb30ca03424996eee9 100644 (file)
@@ -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<ctf_fs_file>(logger);
 
     if (!file) {
         goto error;
This page took 0.027786 seconds and 4 git commands to generate.