src.ctf.fs: use GDirUp in create_ds_file_groups
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 5 Dec 2023 05:28:25 +0000 (05:28 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Change-Id: I0d0ca566d8123e8419a9345f78224f92f17e9a47
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8295
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12331
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/fs-src/fs.cpp

index de47fec95561fbfe56464a871b3a97e72547868e..07752f718845022fe395b30037a8dffe3c322e98 100644 (file)
@@ -588,10 +588,9 @@ static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
     int ret = 0;
     const char *basename;
     GError *error = NULL;
-    GDir *dir = NULL;
 
     /* Check each file in the path directory, except specific ones */
-    dir = g_dir_open(ctf_fs_trace->path.c_str(), 0, &error);
+    const bt2c::GDirUP dir {g_dir_open(ctf_fs_trace->path.c_str(), 0, &error)};
     if (!dir) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger,
                                      "Cannot open directory `{}`: {} (code {})", ctf_fs_trace->path,
@@ -599,7 +598,7 @@ static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
         goto error;
     }
 
-    while ((basename = g_dir_read_name(dir))) {
+    while ((basename = g_dir_read_name(dir.get()))) {
         if (strcmp(basename, CTF_FS_METADATA_FILENAME) == 0) {
             /* Ignore the metadata stream. */
             BT_CPPLOGI_SPEC(ctf_fs_trace->logger,
@@ -661,11 +660,6 @@ error:
     ret = -1;
 
 end:
-    if (dir) {
-        g_dir_close(dir);
-        dir = NULL;
-    }
-
     if (error) {
         g_error_free(error);
     }
This page took 0.025958 seconds and 4 git commands to generate.