From 5884774451806c2d513196c1d96fc0675beda264 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 5 Dec 2023 05:28:25 +0000 Subject: [PATCH] src.ctf.fs: use GDirUp in create_ds_file_groups Change-Id: I0d0ca566d8123e8419a9345f78224f92f17e9a47 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8295 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/12331 Tested-by: jenkins --- src/plugins/ctf/fs-src/fs.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/plugins/ctf/fs-src/fs.cpp b/src/plugins/ctf/fs-src/fs.cpp index de47fec9..07752f71 100644 --- a/src/plugins/ctf/fs-src/fs.cpp +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -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); } -- 2.34.1