From 6be5a99eddff403a941a1329add897a0f27ca509 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 7 Dec 2018 15:33:02 -0500 Subject: [PATCH] bt_value_copy(): put output parameter as last parameter To remain consistent, make the first parameter the main object on which we're working. Signed-off-by: Philippe Proulx --- cli/babeltrace-cfg-cli-args.c | 15 +++++++-------- include/babeltrace/values-const.h | 4 ++-- lib/values.c | 14 +++++++------- tests/lib/test-plugin-plugins/sfs.c | 2 +- tests/lib/test_bt_values.c | 3 +-- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/cli/babeltrace-cfg-cli-args.c b/cli/babeltrace-cfg-cli-args.c index 04f39414..6130947b 100644 --- a/cli/babeltrace-cfg-cli-args.c +++ b/cli/babeltrace-cfg-cli-args.c @@ -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; diff --git a/include/babeltrace/values-const.h b/include/babeltrace/values-const.h index f78915b7..6816d37d 100644 --- a/include/babeltrace/values-const.h +++ b/include/babeltrace/values-const.h @@ -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); diff --git a/lib/values.c b/lib/values.c index 0b8a8f2f..c9be2254 100644 --- a/lib/values.c +++ b/lib/values.c @@ -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; diff --git a/tests/lib/test-plugin-plugins/sfs.c b/tests/lib/test-plugin-plugins/sfs.c index 91066435..46e3eec0 100644 --- a/tests/lib/test-plugin-plugins/sfs.c +++ b/tests/lib/test-plugin-plugins/sfs.c @@ -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); diff --git a/tests/lib/test_bt_values.c b/tests/lib/test_bt_values.c index 96d53d1e..9b9cd3a4 100644 --- a/tests/lib/test_bt_values.c +++ b/tests/lib/test_bt_values.c @@ -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"); -- 2.34.1