Note that with this commit it's possible to have multiple `--params`
options for the same query object. Before, that the last `--params`
would overwrite any previous ones.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Id63354024a4464cc65ddab2e2e0a168c36dc377d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2164
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
struct bt_config *cfg = NULL;
const char *component_class_spec = NULL;
const char *query_object = NULL;
struct bt_config *cfg = NULL;
const char *component_class_spec = NULL;
const char *query_object = NULL;
GString *error_str = NULL;
struct bt_argpar_parse_ret argpar_parse_ret = { 0 };
GString *error_str = NULL;
struct bt_argpar_parse_ret argpar_parse_ret = { 0 };
- params = bt_value_null;
- bt_value_get_ref(bt_value_null);
+ bt_value *params = bt_value_map_create();
+ if (!params) {
+ BT_CLI_LOGE_APPEND_CAUSE_OOM();
+ goto error;
+ }
*retcode = 0;
cfg = bt_config_query_create(plugin_paths);
*retcode = 0;
cfg = bt_config_query_create(plugin_paths);
switch (argpar_item_opt->descr->id) {
case OPT_PARAMS:
{
switch (argpar_item_opt->descr->id) {
case OPT_PARAMS:
{
- bt_value_put_ref(params);
- params = bt_param_parse(arg, error_str);
- if (!params) {
+ bt_value *parsed_params = bt_param_parse(arg, error_str);
+ bt_value_map_extend_status extend_status;
+ if (!parsed_params) {
BT_CLI_LOGE_APPEND_CAUSE("Invalid format for --params option's argument:\n %s",
error_str->str);
goto error;
}
BT_CLI_LOGE_APPEND_CAUSE("Invalid format for --params option's argument:\n %s",
error_str->str);
goto error;
}
+
+ extend_status = bt_value_map_extend(params, parsed_params);
+ BT_VALUE_PUT_REF_AND_RESET(parsed_params);
+ if (extend_status) {
+ BT_CLI_LOGE_APPEND_CAUSE("Cannot extend current parameters with --params option's argument:\n %s",
+ arg);
+ goto error;
+ }