src.ctf.fs: fix error path of ctf_fs_init
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 30 Aug 2024 18:17:13 +0000 (14:17 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
If ctf_fs_create fails (returns nullptr), we don't want to call
bt_self_component_set_data.  Return early if that happens.

Change-Id: Ib5766c6795a841ee1c2abc30e1751f9f1930f985
Reviewed-on: https://review.lttng.org/c/babeltrace/+/13200
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/ctf/fs-src/fs.cpp

index e0b6468d5e326cd17a44e4a1f14d71646d915555..630a3513d05ae60cf6dbf6e0931537517f6d3ccb 100644 (file)
@@ -1510,17 +1510,14 @@ bt_component_class_initialize_method_status ctf_fs_init(bt_self_component_source
                                                         const bt_value *params, void *)
 {
     try {
-        bt_component_class_initialize_method_status ret =
-            BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
-
         ctf_fs_component::UP ctf_fs = ctf_fs_create(bt2::ConstMapValue {params}, self_comp_src);
         if (!ctf_fs) {
-            ret = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
+            return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
         }
 
         bt_self_component_set_data(bt_self_component_source_as_self_component(self_comp_src),
                                    ctf_fs.release());
-        return ret;
+        return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
     } catch (const std::bad_alloc&) {
         return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
     } catch (const bt2::Error&) {
This page took 0.025701 seconds and 4 git commands to generate.