src.ctf.fs: make ctf_fs_trace_create return ctf_fs_trace::UP
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Dec 2023 19:24:52 +0000 (19:24 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Change-Id: I342285ece6b6d68c2375658cb0aff2b363b4b156
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8241
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12280

src/plugins/ctf/fs-src/fs.cpp

index 21e61e3783948f93536507e0f8bca68ef95a06f3..3a93eb1244a27ac7590a3a4fcecd32dd7f1d7839 100644 (file)
@@ -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;
This page took 0.025496 seconds and 4 git commands to generate.