From 2ca337f1fa1555ad7753e93950240bd07d4b4659 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 4 Dec 2023 19:24:52 +0000 Subject: [PATCH] src.ctf.fs: make ctf_fs_trace_create return ctf_fs_trace::UP Change-Id: I342285ece6b6d68c2375658cb0aff2b363b4b156 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8241 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/12280 --- src/plugins/ctf/fs-src/fs.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/plugins/ctf/fs-src/fs.cpp b/src/plugins/ctf/fs-src/fs.cpp index 21e61e37..3a93eb12 100644 --- a/src/plugins/ctf/fs-src/fs.cpp +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -961,14 +961,14 @@ end: return ret; } -static struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *name, - const ctf::src::ClkClsCfg& clkClsCfg, - bt_self_component *selfComp, - const bt2c::Logger& parentLogger) +static ctf_fs_trace::UP ctf_fs_trace_create(const char *path, const char *name, + const ctf::src::ClkClsCfg& clkClsCfg, + bt_self_component *selfComp, + const bt2c::Logger& parentLogger) { int ret; - ctf_fs_trace *ctf_fs_trace = new struct ctf_fs_trace(parentLogger); + ctf_fs_trace::UP ctf_fs_trace {new struct ctf_fs_trace(parentLogger)}; ctf_fs_trace->path = g_string_new(path); if (!ctf_fs_trace->path) { goto error; @@ -982,7 +982,7 @@ static struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *na goto error; } - ret = ctf_fs_metadata_set_trace_class(selfComp, ctf_fs_trace, clkClsCfg); + ret = ctf_fs_metadata_set_trace_class(selfComp, ctf_fs_trace.get(), clkClsCfg); if (ret) { goto error; } @@ -1006,7 +1006,7 @@ static struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *na } } - ret = create_ds_file_groups(ctf_fs_trace); + ret = create_ds_file_groups(ctf_fs_trace.get()); if (ret) { goto error; } @@ -1014,8 +1014,7 @@ static struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *na goto end; error: - ctf_fs_trace_destroy(ctf_fs_trace); - ctf_fs_trace = NULL; + ctf_fs_trace.reset(); end: return ctf_fs_trace; @@ -1050,7 +1049,7 @@ static int ctf_fs_component_create_ctf_fs_trace_one_path(struct ctf_fs_component const char *trace_name, GPtrArray *traces, bt_self_component *selfComp) { - struct ctf_fs_trace *ctf_fs_trace; + ctf_fs_trace::UP ctf_fs_trace; int ret; GString *norm_path; @@ -1087,8 +1086,7 @@ static int ctf_fs_component_create_ctf_fs_trace_one_path(struct ctf_fs_component goto error; } - g_ptr_array_add(traces, ctf_fs_trace); - ctf_fs_trace = NULL; + g_ptr_array_add(traces, ctf_fs_trace.release()); ret = 0; goto end; -- 2.34.1