bt_value_copy(): put output parameter as last parameter
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 7 Dec 2018 20:33:02 +0000 (15:33 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
To remain consistent, make the first parameter the main object on which
we're working.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
cli/babeltrace-cfg-cli-args.c
include/babeltrace/values-const.h
lib/values.c
tests/lib/test-plugin-plugins/sfs.c
tests/lib/test_bt_values.c

index 04f39414a2e37bf4c1cb4793d7d66f892a25f306..6130947b7cb02c5f2edbc6683a9e9a74ac033434 100644 (file)
@@ -1503,8 +1503,8 @@ struct bt_config *bt_config_base_create(enum bt_config_command command,
        if (initial_plugin_paths) {
                struct bt_value *initial_plugin_paths_copy;
 
-               (void) bt_value_copy(&initial_plugin_paths_copy,
-                       initial_plugin_paths);
+               (void) bt_value_copy(initial_plugin_paths,
+                       &initial_plugin_paths_copy);
                cfg->plugin_paths = initial_plugin_paths_copy;
        } else {
                cfg->plugin_paths = bt_value_array_create();
@@ -2504,9 +2504,8 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[],
 
                        BT_ASSERT(cur_base_params);
                        bt_object_put_ref(cur_cfg_comp->params);
-                       status = bt_value_copy(
-                               &cur_cfg_comp->params,
-                               cur_base_params);
+                       status = bt_value_copy(cur_base_params,
+                               &cur_cfg_comp->params);
                        if (status != BT_VALUE_STATUS_OK) {
                                print_err_oom();
                                goto error;
@@ -3543,8 +3542,8 @@ int fill_implicit_ctf_inputs_args(GPtrArray *implicit_ctf_inputs_args,
                 * this is where the unique path goes.
                 */
                BT_OBJECT_PUT_REF_AND_RESET(impl_args->extra_params);
-               status = bt_value_copy(&impl_args->extra_params,
-                               base_implicit_ctf_input_args->extra_params);
+               status = bt_value_copy(base_implicit_ctf_input_args->extra_params,
+                       &impl_args->extra_params);
                if (status != BT_VALUE_STATUS_OK) {
                        print_err_oom();
                        destroy_implicit_component_args(impl_args);
@@ -3621,7 +3620,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
        struct bt_common_lttng_live_url_parts lttng_live_url_parts = { 0 };
        char *output = NULL;
 
-       (void) bt_value_copy(&plugin_paths, initial_plugin_paths);
+       (void) bt_value_copy(initial_plugin_paths, &plugin_paths);
 
        *retcode = 0;
 
index f78915b7b8fecf4a0e64b113abf52e9ceed3cc98..6816d37d1f0a26c44d41dbbdc51b204f257b8a18 100644 (file)
@@ -114,8 +114,8 @@ bt_bool bt_value_is_map(const struct bt_value *object)
        return bt_value_get_type(object) == BT_VALUE_TYPE_MAP;
 }
 
-extern enum bt_value_status bt_value_copy(struct bt_value **copy,
-               const struct bt_value *object);
+extern enum bt_value_status bt_value_copy(const struct bt_value *object,
+               struct bt_value **copy);
 
 extern bt_bool bt_value_compare(const struct bt_value *object_a,
                const struct bt_value *object_b);
index 0b8a8f2f2a76f03e4bfa6ac7fe8564943e2cff1c..c9be2254b796a0bdbf2bf4d528cc85d1a148d340 100644 (file)
@@ -225,7 +225,7 @@ struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
                BT_ASSERT(element_obj);
                BT_LOGD("Copying array value's element: element-addr=%p, "
                        "index=%d", element_obj, i);
-               ret = bt_value_copy(&element_obj_copy, element_obj);
+               ret = bt_value_copy(element_obj, &element_obj_copy);
                if (ret) {
                        BT_LOGE("Cannot copy array value's element: "
                                "array-addr=%p, index=%d",
@@ -278,7 +278,7 @@ struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)
                BT_ASSERT(key_str);
                BT_LOGD("Copying map value's element: element-addr=%p, "
                        "key=\"%s\"", element_obj, key_str);
-               ret = bt_value_copy(&element_obj_copy, element_obj);
+               ret = bt_value_copy(element_obj, &element_obj_copy);
                if (ret) {
                        BT_LOGE("Cannot copy map value's element: "
                                "map-addr=%p, key=\"%s\"",
@@ -1162,8 +1162,8 @@ bt_bool extend_map_element(const char *key,
        struct bt_value *extension_obj_elem_copy = NULL;
 
        /* Copy object which is to replace the current one */
-       extend_data->status = bt_value_copy(&extension_obj_elem_copy,
-               extension_obj_elem);
+       extend_data->status = bt_value_copy(extension_obj_elem,
+                                           &extension_obj_elem_copy);
        if (extend_data->status) {
                BT_LOGE("Cannot copy map element: addr=%p",
                        extension_obj_elem);
@@ -1216,7 +1216,7 @@ enum bt_value_status bt_value_map_extend(
        *extended_map_obj = NULL;
 
        /* Create copy of base map object to start with */
-       extend_data.status = bt_value_copy(extended_map_obj, base_map_obj);
+       extend_data.status = bt_value_copy(base_map_obj, extended_map_obj);
        if (extend_data.status) {
                BT_LOGE("Cannot copy base value: base-value-addr=%p",
                        base_map_obj);
@@ -1256,8 +1256,8 @@ end:
        return extend_data.status;
 }
 
-enum bt_value_status bt_value_copy(struct bt_value **copy_obj,
-               const struct bt_value *object)
+enum bt_value_status bt_value_copy(const struct bt_value *object,
+               struct bt_value **copy_obj)
 {
        enum bt_value_status status = BT_VALUE_STATUS_OK;
 
index 91066435189ef58596cfa0a63e45a3358a93febe..46e3eec0be7dfaab5eb4fa6f03a46225ea43f096 100644 (file)
@@ -67,7 +67,7 @@ static enum bt_query_status flt_query_method(
        BT_ASSERT(*result);
        iret = bt_value_array_append_string_element(res, object);
        BT_ASSERT(iret == 0);
-       iret = bt_value_copy(&val, params);
+       iret = bt_value_copy(params, &val);
        BT_ASSERT(iret == 0);
        iret = bt_value_array_append_element(res, val);
        BT_ASSERT(iret == 0);
index 96d53d1e5ee059cbb4d853a3cbf6d0238eb1c072..9b9cd3a4a72649c471cad41b3042014144423545 100644 (file)
@@ -885,8 +885,7 @@ void test_copy(void)
                string_obj);
        BT_ASSERT(status == BT_VALUE_STATUS_OK);
 
-       status = bt_value_copy(&map_copy_obj,
-               map_obj);
+       status = bt_value_copy(map_obj, &map_copy_obj);
        ok(status == BT_VALUE_STATUS_OK && map_copy_obj,
                "bt_value_copy() succeeds");
 
This page took 0.029466 seconds and 4 git commands to generate.