cli: apply log levels (`--log-level` option) to leftovers
[babeltrace.git] / src / cli / babeltrace2-cfg-cli-args.c
index 13602d45f57ca58418e569912bdbc6b2fb749202..72ac4f14cef064e8fc87e586adee6570a8b8d38e 100644 (file)
@@ -3177,11 +3177,25 @@ end:
 /*
  * Create `struct implicit_component_args` structures for each of the source
  * components we identified.  Add them to `component_args`.
+ *
+ * `leftover_params` is an array where each element is an array of strings
+ * containing all the arguments to `--params` that apply to the leftover at the
+ * same index.  For example, if, for a leftover, the following `--params`
+ * options applied:
+ *
+ *     --params=a=2 --params=b=3,c=4
+ *
+ * its entry in `leftover_params` would contain
+ *
+ *     ["a=2", "b=3,c=4"]
  */
 
 static
-void create_implicit_component_args_from_auto_discovered_sources(
-               const struct auto_source_discovery *auto_disc, GPtrArray *component_args)
+int create_implicit_component_args_from_auto_discovered_sources(
+               const struct auto_source_discovery *auto_disc,
+               const bt_value *leftover_params,
+               const bt_value *leftover_loglevels,
+               GPtrArray *component_args)
 {
        gchar *cc_name = NULL;
        struct implicit_component_args *comp = NULL;
@@ -3193,34 +3207,104 @@ void create_implicit_component_args_from_auto_discovered_sources(
        for (i = 0; i < len; i++) {
                struct auto_source_discovery_result *res =
                        g_ptr_array_index(auto_disc->results, i);
+               uint64_t orig_indices_i, orig_indices_count;
 
                g_free(cc_name);
                cc_name = g_strdup_printf("source.%s.%s", res->plugin_name, res->source_cc_name);
                if (!cc_name) {
                        BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                       goto end;
+                       goto error;
                }
 
                comp = create_implicit_component_args(cc_name);
                if (!comp) {
-                       goto end;
+                       goto error;
+               }
+
+               /*
+                * Append parameters and log levels of all the leftovers that
+                * contributed to this component instance coming into existence.
+                */
+               orig_indices_count = bt_value_array_get_size(res->original_input_indices);
+               for (orig_indices_i = 0; orig_indices_i < orig_indices_count; orig_indices_i++) {
+                       const bt_value *orig_idx_value =
+                               bt_value_array_borrow_element_by_index(
+                                       res->original_input_indices, orig_indices_i);
+                       uint64_t orig_idx = bt_value_integer_unsigned_get(orig_idx_value);
+                       const bt_value *params_array =
+                               bt_value_array_borrow_element_by_index_const(
+                                       leftover_params, orig_idx);
+                       uint64_t params_i, params_count;
+                       const bt_value *loglevel_value;
+
+                       params_count = bt_value_array_get_size(params_array);
+                       for (params_i = 0; params_i < params_count; params_i++) {
+                               const bt_value *params_value =
+                                       bt_value_array_borrow_element_by_index_const(
+                                               params_array, params_i);
+                               const char *params = bt_value_string_get(params_value);
+                               bt_value_array_append_element_status append_status;
+
+                               append_status = bt_value_array_append_string_element(
+                                       comp->extra_params, "--params");
+                               if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
+                                       BT_CLI_LOGE_APPEND_CAUSE("Failed to append array element.");
+                                       goto error;
+                               }
+
+                               append_status = bt_value_array_append_string_element(
+                                       comp->extra_params, params);
+                               if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
+                                       BT_CLI_LOGE_APPEND_CAUSE("Failed to append array element.");
+                                       goto error;
+                               }
+                       }
+
+                       loglevel_value = bt_value_array_borrow_element_by_index_const(
+                               leftover_loglevels, orig_idx);
+                       if (bt_value_get_type(loglevel_value) == BT_VALUE_TYPE_STRING) {
+                               const char *loglevel = bt_value_string_get(loglevel_value);
+                               bt_value_array_append_element_status append_status;
+
+                               append_status = bt_value_array_append_string_element(
+                                       comp->extra_params, "--log-level");
+                               if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
+                                       BT_CLI_LOGE_APPEND_CAUSE("Failed to append array element.");
+                                       goto error;
+                               }
+
+                               append_status = bt_value_array_append_string_element(
+                                       comp->extra_params, loglevel);
+                               if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
+                                       BT_CLI_LOGE_APPEND_CAUSE("Failed to append array element.");
+                                       goto error;
+                               }
+                       }
                }
 
                status = append_parameter_to_args(comp->extra_params, "inputs", res->inputs);
                if (status != 0) {
-                       goto end;
+                       goto error;
                }
 
                g_ptr_array_add(component_args, comp);
                comp = NULL;
        }
 
+       status = 0;
+       goto end;
+
+error:
+       status = -1;
+
 end:
        g_free(cc_name);
 
        if (comp) {
                destroy_implicit_component_args(comp);
        }
+
+       return status;
 }
 
 /*
@@ -3234,6 +3318,9 @@ enum convert_current_item_type {
 
        /* Current item is a component. */
        CONVERT_CURRENT_ITEM_TYPE_COMPONENT,
+
+       /* Current item is a leftover. */
+       CONVERT_CURRENT_ITEM_TYPE_LEFTOVER,
 };
 
 /*
@@ -3266,6 +3353,8 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
        GList *filter_names = NULL;
        GList *sink_names = NULL;
        bt_value *leftovers = NULL;
+       bt_value *leftover_params = NULL;
+       bt_value *leftover_loglevels = NULL;
        struct implicit_component_args implicit_ctf_output_args = { 0 };
        struct implicit_component_args implicit_lttng_live_args = { 0 };
        struct implicit_component_args implicit_dummy_args = { 0 };
@@ -3374,6 +3463,18 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                goto error;
        }
 
+       leftover_params = bt_value_array_create();
+       if (!leftover_params) {
+               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+               goto error;
+       }
+
+       leftover_loglevels = bt_value_array_create();
+       if (!leftover_loglevels) {
+               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+               goto error;
+       }
+
        if (auto_source_discovery_init(&auto_disc) != 0) {
                goto error;
        }
@@ -3424,226 +3525,281 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                char *comp_cls_name = NULL;
                const char *arg;
 
-               if (argpar_item->type != BT_ARGPAR_ITEM_TYPE_OPT) {
-                       continue;
-               }
+               if (argpar_item->type == BT_ARGPAR_ITEM_TYPE_OPT) {
+                       argpar_item_opt = (struct bt_argpar_item_opt *) argpar_item;
+                       arg = argpar_item_opt->arg;
 
-               argpar_item_opt = (struct bt_argpar_item_opt *) argpar_item;
-               arg = argpar_item_opt->arg;
+                       switch (argpar_item_opt->descr->id) {
+                       case OPT_COMPONENT:
+                       {
+                               bt_component_class_type type;
 
-               switch (argpar_item_opt->descr->id) {
-               case OPT_COMPONENT:
-               {
-                       bt_component_class_type type;
+                               current_item_type = CONVERT_CURRENT_ITEM_TYPE_COMPONENT;
 
-                       current_item_type = CONVERT_CURRENT_ITEM_TYPE_COMPONENT;
+                               /* Parse the argument */
+                               plugin_comp_cls_names(arg, &name, &plugin_name,
+                                       &comp_cls_name, &type);
+                               if (!plugin_name || !comp_cls_name) {
+                                       BT_CLI_LOGE_APPEND_CAUSE(
+                                               "Invalid format for --component option's argument:\n    %s",
+                                               arg);
+                                       goto error;
+                               }
 
-                       /* Parse the argument */
-                       plugin_comp_cls_names(arg, &name, &plugin_name,
-                               &comp_cls_name, &type);
-                       if (!plugin_name || !comp_cls_name) {
-                               BT_CLI_LOGE_APPEND_CAUSE(
-                                       "Invalid format for --component option's argument:\n    %s",
-                                       arg);
-                               goto error;
-                       }
+                               if (name) {
+                                       /*
+                                        * Name was given by the user, verify it isn't
+                                        * taken.
+                                        */
+                                       if (bt_value_map_has_entry(all_names, name)) {
+                                               BT_CLI_LOGE_APPEND_CAUSE(
+                                                       "Duplicate component instance name:\n    %s",
+                                                       name);
+                                               goto error;
+                                       }
 
-                       if (name) {
-                               /*
-                                * Name was given by the user, verify it isn't
-                                * taken.
-                                */
-                               if (bt_value_map_has_entry(all_names, name)) {
-                                       BT_CLI_LOGE_APPEND_CAUSE(
-                                               "Duplicate component instance name:\n    %s",
-                                               name);
+                                       name_gstr = g_string_new(name);
+                                       if (!name_gstr) {
+                                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                               goto error;
+                                       }
+
+                                       g_string_assign(component_arg_for_run, arg);
+                               } else {
+                                       /* Name not given by user, generate one. */
+                                       name_gstr = get_component_auto_name(arg, all_names);
+                                       if (!name_gstr) {
+                                               goto error;
+                                       }
+
+                                       g_string_printf(component_arg_for_run, "%s:%s",
+                                               name_gstr->str, arg);
+                               }
+
+                               if (bt_value_array_append_string_element(run_args,
+                                               "--component")) {
+                                       BT_CLI_LOGE_APPEND_CAUSE_OOM();
                                        goto error;
                                }
 
-                               name_gstr = g_string_new(name);
-                               if (!name_gstr) {
+                               if (bt_value_array_append_string_element(run_args,
+                                               component_arg_for_run->str)) {
                                        BT_CLI_LOGE_APPEND_CAUSE_OOM();
                                        goto error;
                                }
 
-                               g_string_assign(component_arg_for_run, arg);
-                       } else {
-                               /* Name not given by user, generate one. */
-                               name_gstr = get_component_auto_name(arg, all_names);
-                               if (!name_gstr) {
+                               /*
+                                * Remember this name globally, for the uniqueness of
+                                * all component names.
+                                */
+                               if (bt_value_map_insert_entry(all_names,
+                                               name_gstr->str, bt_value_null)) {
+                                       BT_CLI_LOGE_APPEND_CAUSE_OOM();
                                        goto error;
                                }
 
-                               g_string_printf(component_arg_for_run, "%s:%s",
-                                       name_gstr->str, arg);
+                               /*
+                                * Remember this name specifically for the type of the
+                                * component. This is to create connection arguments.
+                                *
+                                * The list takes ownership of `name_gstr`.
+                                */
+                               switch (type) {
+                               case BT_COMPONENT_CLASS_TYPE_SOURCE:
+                                       source_names = g_list_append(source_names, name_gstr);
+                                       break;
+                               case BT_COMPONENT_CLASS_TYPE_FILTER:
+                                       filter_names = g_list_append(filter_names, name_gstr);
+                                       break;
+                               case BT_COMPONENT_CLASS_TYPE_SINK:
+                                       sink_names = g_list_append(sink_names, name_gstr);
+                                       break;
+                               default:
+                                       abort();
+                               }
+                               name_gstr = NULL;
+
+                               free(name);
+                               free(plugin_name);
+                               free(comp_cls_name);
+                               name = NULL;
+                               plugin_name = NULL;
+                               comp_cls_name = NULL;
+                               break;
                        }
+                       case OPT_PARAMS:
+                               if (current_item_type == CONVERT_CURRENT_ITEM_TYPE_COMPONENT) {
+                                       /*
+                                        * The current item is a component (--component option),
+                                        * pass it directly to the run args.
+                                        */
+                                       if (bt_value_array_append_string_element(run_args,
+                                                       "--params")) {
+                                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                               goto error;
+                                       }
 
-                       if (bt_value_array_append_string_element(run_args,
-                                       "--component")) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                               goto error;
-                       }
+                                       if (bt_value_array_append_string_element(run_args, arg)) {
+                                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                               goto error;
+                                       }
+                               } else if (current_item_type == CONVERT_CURRENT_ITEM_TYPE_LEFTOVER) {
+                                       /* The current item is a leftover, record it in `leftover_params`. */
+                                       bt_value *array;
+                                       uint64_t idx = bt_value_array_get_size(leftover_params) - 1;
 
-                       if (bt_value_array_append_string_element(run_args,
-                                       component_arg_for_run->str)) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                               goto error;
-                       }
+                                       array = bt_value_array_borrow_element_by_index(leftover_params, idx);
+                                       bt_value_array_append_string_element(array, arg);
+                               } else {
+                                       BT_CLI_LOGE_APPEND_CAUSE(
+                                               "No current component (--component option) or non-option argument of which to set parameters:\n    %s",
+                                               arg);
+                                       goto error;
+                               }
+                               break;
+                       case OPT_LOG_LEVEL:
+                               if (current_item_type == CONVERT_CURRENT_ITEM_TYPE_COMPONENT) {
+                                       if (bt_value_array_append_string_element(run_args, "--log-level")) {
+                                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                               goto error;
+                                       }
 
-                       /*
-                        * Remember this name globally, for the uniqueness of
-                        * all component names.
-                        */
-                       if (bt_value_map_insert_entry(all_names,
-                                       name_gstr->str, bt_value_null)) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                               goto error;
-                       }
+                                       if (bt_value_array_append_string_element(run_args, arg)) {
+                                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                               goto error;
+                                       }
+                               } else if (current_item_type == CONVERT_CURRENT_ITEM_TYPE_LEFTOVER) {
+                                       uint64_t idx = bt_value_array_get_size(leftover_loglevels) - 1;
+                                       bt_value *log_level_str_value;
+
+                                       log_level_str_value = bt_value_string_create_init(arg);
+                                       if (!log_level_str_value) {
+                                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                               goto error;
+                                       }
+
+                                       if (bt_value_array_set_element_by_index(leftover_loglevels, idx,
+                                                       log_level_str_value)) {
+                                               bt_value_put_ref(log_level_str_value);
+                                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                               goto error;
+                                       }
+                               } else {
+                                       BT_CLI_LOGE_APPEND_CAUSE(
+                                               "No current component (--component option) or non-option argument to assign a log level to:\n    %s",
+                                               arg);
+                                       goto error;
+                               }
 
-                       /*
-                        * Remember this name specifically for the type of the
-                        * component. This is to create connection arguments.
-                        *
-                        * The list takes ownership of `name_gstr`.
-                        */
-                       switch (type) {
-                       case BT_COMPONENT_CLASS_TYPE_SOURCE:
-                               source_names = g_list_append(source_names, name_gstr);
-                               break;
-                       case BT_COMPONENT_CLASS_TYPE_FILTER:
-                               filter_names = g_list_append(filter_names, name_gstr);
                                break;
-                       case BT_COMPONENT_CLASS_TYPE_SINK:
-                               sink_names = g_list_append(sink_names, name_gstr);
+                       case OPT_OMIT_HOME_PLUGIN_PATH:
+                               force_omit_home_plugin_path = true;
+
+                               if (bt_value_array_append_string_element(run_args,
+                                               "--omit-home-plugin-path")) {
+                                       BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                       goto error;
+                               }
                                break;
-                       default:
-                               abort();
-                       }
-                       name_gstr = NULL;
-
-                       free(name);
-                       free(plugin_name);
-                       free(comp_cls_name);
-                       name = NULL;
-                       plugin_name = NULL;
-                       comp_cls_name = NULL;
-                       break;
-               }
-               case OPT_PARAMS:
-                       if (current_item_type != CONVERT_CURRENT_ITEM_TYPE_COMPONENT) {
-                               BT_CLI_LOGE_APPEND_CAUSE("No current component of which to set parameters:\n    %s",
-                                       arg);
-                               goto error;
-                       }
+                       case OPT_RETRY_DURATION:
+                               if (bt_value_array_append_string_element(run_args,
+                                               "--retry-duration")) {
+                                       BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                       goto error;
+                               }
 
-                       if (bt_value_array_append_string_element(run_args,
-                                       "--params")) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                               goto error;
-                       }
+                               if (bt_value_array_append_string_element(run_args, arg)) {
+                                       BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                       goto error;
+                               }
+                               break;
+                       case OPT_OMIT_SYSTEM_PLUGIN_PATH:
+                               force_omit_system_plugin_path = true;
 
-                       if (bt_value_array_append_string_element(run_args, arg)) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                               goto error;
-                       }
-                       break;
-               case OPT_LOG_LEVEL:
-                       if (current_item_type != CONVERT_CURRENT_ITEM_TYPE_COMPONENT) {
-                               BT_CLI_LOGE_APPEND_CAUSE("No current component to assign a log level to:\n    %s",
-                                       arg);
-                               goto error;
-                       }
+                               if (bt_value_array_append_string_element(run_args,
+                                               "--omit-system-plugin-path")) {
+                                       BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                       goto error;
+                               }
+                               break;
+                       case OPT_PLUGIN_PATH:
+                               if (bt_config_append_plugin_paths_check_setuid_setgid(
+                                               plugin_paths, arg)) {
+                                       goto error;
+                               }
 
-                       if (bt_value_array_append_string_element(run_args, "--log-level")) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                               goto error;
-                       }
+                               if (bt_value_array_append_string_element(run_args,
+                                               "--plugin-path")) {
+                                       BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                       goto error;
+                               }
 
-                       if (bt_value_array_append_string_element(run_args, arg)) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                               if (bt_value_array_append_string_element(run_args, arg)) {
+                                       BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                       goto error;
+                               }
+                               break;
+                       case OPT_BEGIN:
+                       case OPT_CLOCK_CYCLES:
+                       case OPT_CLOCK_DATE:
+                       case OPT_CLOCK_FORCE_CORRELATE:
+                       case OPT_CLOCK_GMT:
+                       case OPT_CLOCK_OFFSET:
+                       case OPT_CLOCK_OFFSET_NS:
+                       case OPT_CLOCK_SECONDS:
+                       case OPT_COLOR:
+                       case OPT_DEBUG:
+                       case OPT_DEBUG_INFO:
+                       case OPT_DEBUG_INFO_DIR:
+                       case OPT_DEBUG_INFO_FULL_PATH:
+                       case OPT_DEBUG_INFO_TARGET_PREFIX:
+                       case OPT_END:
+                       case OPT_FIELDS:
+                       case OPT_INPUT_FORMAT:
+                       case OPT_NAMES:
+                       case OPT_NO_DELTA:
+                       case OPT_OUTPUT_FORMAT:
+                       case OPT_OUTPUT:
+                       case OPT_RUN_ARGS:
+                       case OPT_RUN_ARGS_0:
+                       case OPT_STREAM_INTERSECTION:
+                       case OPT_TIMERANGE:
+                       case OPT_VERBOSE:
+                               /* Ignore in this pass */
+                               break;
+                       default:
+                               BT_CLI_LOGE_APPEND_CAUSE("Unknown command-line option specified (option code %d).",
+                                       argpar_item_opt->descr->id);
                                goto error;
                        }
+               } else if (argpar_item->type == BT_ARGPAR_ITEM_TYPE_NON_OPT) {
+                       struct bt_argpar_item_non_opt *argpar_item_non_opt;
+                       bt_value_array_append_element_status append_status;
 
-                       break;
-               case OPT_OMIT_HOME_PLUGIN_PATH:
-                       force_omit_home_plugin_path = true;
-
-                       if (bt_value_array_append_string_element(run_args,
-                                       "--omit-home-plugin-path")) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                               goto error;
-                       }
-                       break;
-               case OPT_RETRY_DURATION:
-                       if (bt_value_array_append_string_element(run_args,
-                                       "--retry-duration")) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                               goto error;
-                       }
+                       current_item_type = CONVERT_CURRENT_ITEM_TYPE_LEFTOVER;
 
-                       if (bt_value_array_append_string_element(run_args, arg)) {
-                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                               goto error;
-                       }
-                       break;
-               case OPT_OMIT_SYSTEM_PLUGIN_PATH:
-                       force_omit_system_plugin_path = true;
+                       argpar_item_non_opt = (struct bt_argpar_item_non_opt *) argpar_item;
 
-                       if (bt_value_array_append_string_element(run_args,
-                                       "--omit-system-plugin-path")) {
+                       append_status = bt_value_array_append_string_element(leftovers,
+                               argpar_item_non_opt->arg);
+                       if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
                                BT_CLI_LOGE_APPEND_CAUSE_OOM();
                                goto error;
                        }
-                       break;
-               case OPT_PLUGIN_PATH:
-                       if (bt_config_append_plugin_paths_check_setuid_setgid(
-                                       plugin_paths, arg)) {
-                               goto error;
-                       }
 
-                       if (bt_value_array_append_string_element(run_args,
-                                       "--plugin-path")) {
+                       append_status = bt_value_array_append_empty_array_element(leftover_params);
+                       if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
                                BT_CLI_LOGE_APPEND_CAUSE_OOM();
                                goto error;
                        }
 
-                       if (bt_value_array_append_string_element(run_args, arg)) {
+                       append_status = bt_value_array_append_element(leftover_loglevels, bt_value_null);
+                       if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
                                BT_CLI_LOGE_APPEND_CAUSE_OOM();
                                goto error;
                        }
-                       break;
-               case OPT_BEGIN:
-               case OPT_CLOCK_CYCLES:
-               case OPT_CLOCK_DATE:
-               case OPT_CLOCK_FORCE_CORRELATE:
-               case OPT_CLOCK_GMT:
-               case OPT_CLOCK_OFFSET:
-               case OPT_CLOCK_OFFSET_NS:
-               case OPT_CLOCK_SECONDS:
-               case OPT_COLOR:
-               case OPT_DEBUG:
-               case OPT_DEBUG_INFO:
-               case OPT_DEBUG_INFO_DIR:
-               case OPT_DEBUG_INFO_FULL_PATH:
-               case OPT_DEBUG_INFO_TARGET_PREFIX:
-               case OPT_END:
-               case OPT_FIELDS:
-               case OPT_INPUT_FORMAT:
-               case OPT_NAMES:
-               case OPT_NO_DELTA:
-               case OPT_OUTPUT_FORMAT:
-               case OPT_OUTPUT:
-               case OPT_RUN_ARGS:
-               case OPT_RUN_ARGS_0:
-               case OPT_STREAM_INTERSECTION:
-               case OPT_TIMERANGE:
-               case OPT_VERBOSE:
-                       /* Ignore in this pass */
-                       break;
-               default:
-                       BT_CLI_LOGE_APPEND_CAUSE("Unknown command-line option specified (option code %d).",
-                               argpar_item_opt->descr->id);
-                       goto error;
+               } else {
+                       abort();
                }
        }
 
@@ -3964,25 +4120,6 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                goto error;
        }
 
-       /* Consume and keep leftover arguments */
-       for (i = 0; i < argpar_parse_ret.items->len; i++) {
-               struct bt_argpar_item *argpar_item =
-                       g_ptr_array_index(argpar_parse_ret.items, i);
-               struct bt_argpar_item_non_opt *argpar_item_non_opt;
-
-               if (argpar_item->type != BT_ARGPAR_ITEM_TYPE_NON_OPT) {
-                       continue;
-               }
-
-               argpar_item_non_opt = (struct bt_argpar_item_non_opt *) argpar_item;
-
-               if (bt_value_array_append_string_element(leftovers, argpar_item_non_opt->arg) !=
-                               BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
-                       BT_CLI_LOGE_APPEND_CAUSE_OOM();
-                       goto error;
-               }
-       }
-
        /* Print CTF metadata or print LTTng live sessions */
        if (print_ctf_metadata) {
                const bt_value *bt_val_leftover;
@@ -4135,8 +4272,12 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                                goto error;
                        }
 
-                       create_implicit_component_args_from_auto_discovered_sources(
-                               &auto_disc, discovered_source_args);
+                       status = create_implicit_component_args_from_auto_discovered_sources(
+                               &auto_disc, leftover_params, leftover_loglevels,
+                               discovered_source_args);
+                       if (status != 0) {
+                               goto error;
+                       }
                }
        }
 
This page took 0.03113 seconds and 4 git commands to generate.