lib: strictly type function return status enumerations
[babeltrace.git] / src / cli / babeltrace2-cfg-cli-args.c
index cad2b4aa4f37da40e6870d072e0f2a11f1172411..3b76322f40c39f2d9a4b76500a09f368589a41dd 100644 (file)
@@ -269,7 +269,7 @@ bt_value *ini_parse_array(struct ini_parsing_state *state)
        while (!(token_type == G_TOKEN_CHAR && g_scanner_cur_value(state->scanner).v_char == ']')) {
                /* Parse the item... */
                bt_value *item_value;
-               bt_value_status status;
+               bt_value_array_append_element_status append_status;
 
                item_value = ini_parse_value(state);
                if (!item_value) {
@@ -277,10 +277,10 @@ bt_value *ini_parse_array(struct ini_parsing_state *state)
                }
 
                /* ... and add it to the result array. */
-               status = bt_value_array_append_element(array_value, item_value);
+               append_status = bt_value_array_append_element(array_value,
+                       item_value);
                BT_VALUE_PUT_REF_AND_RESET(item_value);
-
-               if (status != BT_VALUE_STATUS_OK) {
+               if (append_status < 0) {
                        goto error;
                }
 
@@ -1553,8 +1553,8 @@ int append_home_and_system_plugin_paths(bt_value *plugin_paths,
                if (bt_common_is_setuid_setgid()) {
                        BT_LOGI_STR("Skipping non-system plugin paths for setuid/setgid binary.");
                } else {
-                       char *home_plugin_dir =
-                               bt_common_get_home_plugin_path();
+                       char *home_plugin_dir = bt_common_get_home_plugin_path(
+                               BT_LOG_OUTPUT_LEVEL);
 
                        if (home_plugin_dir) {
                                ret = bt_config_append_plugin_paths(
@@ -2490,7 +2490,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[],
        bt_value *connection_args = NULL;
        char error_buf[256] = { 0 };
        long retry_duration = -1;
-       bt_value_status status;
+       bt_value_map_extend_status extend_status;
        struct poptOption run_long_options[] = {
                { "base-params", 'b', POPT_ARG_STRING, NULL, OPT_BASE_PARAMS, NULL, NULL },
                { "component", 'c', POPT_ARG_STRING, NULL, OPT_COMPONENT, NULL, NULL },
@@ -2610,9 +2610,8 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[],
 
                        BT_ASSERT(cur_base_params);
                        bt_value_put_ref(cur_cfg_comp->params);
-                       status = bt_value_copy(cur_base_params,
-                               &cur_cfg_comp->params);
-                       if (status != BT_VALUE_STATUS_OK) {
+                       if (bt_value_copy(cur_base_params,
+                                       &cur_cfg_comp->params) < 0) {
                                print_err_oom();
                                goto error;
                        }
@@ -2638,10 +2637,10 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[],
                                goto error;
                        }
 
-                       status = bt_value_map_extend(cur_cfg_comp->params,
-                               params, &params_to_set);
+                       extend_status = bt_value_map_extend(
+                               cur_cfg_comp->params, params, &params_to_set);
                        BT_VALUE_PUT_REF_AND_RESET(params);
-                       if (status != BT_VALUE_STATUS_OK) {
+                       if (extend_status != BT_VALUE_MAP_EXTEND_STATUS_OK) {
                                printf_err("Cannot extend current component parameters with --params option's argument:\n    %s\n",
                                        arg);
                                goto error;
@@ -2868,6 +2867,7 @@ void print_convert_usage(FILE *fp)
        fprintf(fp, "  -P, --path=PATH                   Set the `path` string parameter of the\n");
        fprintf(fp, "                                    current component to PATH\n");
        fprintf(fp, "      --plugin-path=PATH[:PATH]...  Add PATH to the list of paths from which\n");
+       fprintf(fp, "                                    dynamic plugins can be loaded\n");
        fprintf(fp, "      --retry-duration=DUR          When babeltrace2(1) needs to retry to run\n");
        fprintf(fp, "                                    the graph later, retry in DUR µs\n");
        fprintf(fp, "                                    (default: 100000)\n");
@@ -4421,13 +4421,13 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                        stream_intersection_mode = true;
                        break;
                case OPT_VERBOSE:
-                       if (*default_log_level != BT_LOG_VERBOSE &&
+                       if (*default_log_level != BT_LOG_TRACE &&
                                        *default_log_level != BT_LOG_DEBUG) {
                                *default_log_level = BT_LOG_INFO;
                        }
                        break;
                case OPT_DEBUG:
-                       *default_log_level = BT_LOG_VERBOSE;
+                       *default_log_level = BT_LOG_TRACE;
                        break;
                default:
                        break;
@@ -4467,8 +4467,8 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
 
        /* Consume and keep leftover arguments */
        while ((leftover = poptGetArg(pc))) {
-               bt_value_status status = bt_value_array_append_string_element(leftovers, leftover);
-               if (status != BT_VALUE_STATUS_OK) {
+               if (bt_value_array_append_string_element(leftovers, leftover) !=
+                               BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
                        print_err_oom();
                        goto error;
                }
@@ -4878,6 +4878,14 @@ error:
        BT_OBJECT_PUT_REF_AND_RESET(cfg);
 
 end:
+       /*
+        * If the log level is still unset at this point, set it to
+        * the program's default.
+        */
+       if (*default_log_level < 0) {
+               *default_log_level = cli_default_log_level;
+       }
+
        if (pc) {
                poptFreeContext(pc);
        }
@@ -4986,17 +4994,17 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[],
 
                if (strcmp(cur_arg, "-d") == 0 ||
                                strcmp(cur_arg, "--debug") == 0) {
-                       default_log_level = BT_LOG_VERBOSE;
+                       default_log_level = BT_LOG_TRACE;
                } else if (strcmp(cur_arg, "-v") == 0 ||
                                strcmp(cur_arg, "--verbose") == 0) {
-                       if (default_log_level != BT_LOG_VERBOSE &&
+                       if (default_log_level != BT_LOG_TRACE &&
                                        default_log_level != BT_LOG_DEBUG) {
                                /*
                                 * Legacy: do not override a previous
                                 * --debug because --verbose and --debug
                                 * can be specified together (in this
                                 * case we want the lowest log level to
-                                * apply, VERBOSE).
+                                * apply, TRACE).
                                 */
                                default_log_level = BT_LOG_INFO;
                        }
@@ -5138,7 +5146,7 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[],
        }
 
        if (config) {
-               BT_ASSERT(default_log_level >= BT_LOG_VERBOSE);
+               BT_ASSERT(default_log_level >= BT_LOG_TRACE);
                config->log_level = default_log_level;
                config->command_name = command_name;
        }
This page took 0.026226 seconds and 4 git commands to generate.