Fix: uninitialized destination component on unknown args
[babeltrace.git] / cli / babeltrace-cfg-cli-args.c
index f717f90b0c535338510a33596d975613331543f8..195c891c0b514ebca801dfd93a276bd2a5fec156 100644 (file)
@@ -405,7 +405,7 @@ int ini_handle_state(struct ini_parsing_state *state)
                state->expecting = INI_EXPECT_MAP_KEY;
                goto success;
        default:
-               assert(false);
+               abort();
        }
 
 error:
@@ -889,7 +889,7 @@ void bt_config_destroy(struct bt_object *obj)
                }
                break;
        default:
-               assert(false);
+               abort();
        }
 
        g_free(cfg);
@@ -1309,6 +1309,7 @@ enum {
 };
 
 enum bt_config_component_dest {
+       BT_CONFIG_COMPONENT_DEST_UNKNOWN = -1,
        BT_CONFIG_COMPONENT_DEST_SOURCE,
        BT_CONFIG_COMPONENT_DEST_FILTER,
        BT_CONFIG_COMPONENT_DEST_SINK,
@@ -1336,7 +1337,7 @@ void add_run_cfg_comp(struct bt_config *cfg,
                g_ptr_array_add(cfg->cmd_data.run.sinks, cfg_comp);
                break;
        default:
-               assert(false);
+               abort();
        }
 }
 
@@ -1855,7 +1856,7 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[],
                                        BT_COMPONENT_CLASS_TYPE_SINK;
                                break;
                        default:
-                               assert(false);
+                               abort();
                        }
                        plug_comp_cls_names = strdup(arg);
                        if (!plug_comp_cls_names) {
@@ -2068,7 +2069,7 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[],
                                type = BT_COMPONENT_CLASS_TYPE_SINK;
                                break;
                        default:
-                               assert(false);
+                               abort();
                        }
 
                        cfg->cmd_data.query.cfg_component =
@@ -2413,7 +2414,8 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[],
        poptContext pc = NULL;
        char *arg = NULL;
        struct bt_config_component *cur_cfg_comp = NULL;
-       enum bt_config_component_dest cur_cfg_comp_dest;
+       enum bt_config_component_dest cur_cfg_comp_dest =
+                       BT_CONFIG_COMPONENT_DEST_UNKNOWN;
        struct bt_value *cur_base_params = NULL;
        int opt, ret = 0;
        struct bt_config *cfg = NULL;
@@ -2536,7 +2538,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[],
                                opt_name = "--sink";
                                break;
                        default:
-                               assert(false);
+                               abort();
                        }
 
                        if (cur_cfg_comp) {
@@ -3085,7 +3087,7 @@ int append_run_args_for_implicit_component(
                }
                break;
        default:
-               assert(false);
+               abort();
        }
 
        if (bt_value_array_append_string(run_args,
@@ -3322,7 +3324,7 @@ int convert_append_name_param(enum bt_config_component_dest dest,
                        *sink_names = g_list_append(*sink_names, name);
                        break;
                default:
-                       assert(false);
+                       abort();
                }
 
                g_string_assign(cur_name_prefix, "");
@@ -3567,7 +3569,8 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
 {
        poptContext pc = NULL;
        char *arg = NULL;
-       enum bt_config_component_dest cur_comp_dest;
+       enum bt_config_component_dest cur_comp_dest =
+                       BT_CONFIG_COMPONENT_DEST_UNKNOWN;
        int opt, ret = 0;
        struct bt_config *cfg = NULL;
        bool got_verbose_opt = false;
@@ -3754,7 +3757,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                                }
                                break;
                        default:
-                               assert(false);
+                               abort();
                        }
 
                        if (bt_value_array_append_string(run_args, arg)) {
@@ -4063,7 +4066,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                        break;
                case OPT_CLOCK_FORCE_CORRELATE:
                        append_implicit_component_param(
-                               &implicit_muxer_args, "force-correlate", "yes");
+                               &implicit_muxer_args, "ignore-absolute", "yes");
                        break;
                case OPT_CLOCK_GMT:
                        append_implicit_component_param(
@@ -4305,7 +4308,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                if (implicit_lttng_live_args.exists) {
                        lttng_live_url_parts =
                                bt_common_parse_lttng_live_url(leftover,
-                                       error_buf, 256);
+                                       error_buf, sizeof(error_buf));
                        if (!lttng_live_url_parts.proto) {
                                printf_err("Invalid LTTng live URL format: %s\n",
                                        error_buf);
@@ -4759,7 +4762,7 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[],
                        force_omit_home_plugin_path, initial_plugin_paths);
                break;
        default:
-               assert(false);
+               abort();
        }
 
        if (config) {
This page took 0.025326 seconds and 4 git commands to generate.