diff options
author | Paul Kocialkowski <paul.kocialkowski@linux.intel.com> | 2017-07-20 17:11:27 +0300 |
---|---|---|
committer | Lyude <lyude@redhat.com> | 2017-07-20 13:23:06 -0400 |
commit | 493151b0768aa4ca535cef49cb7efa174a9c3a77 (patch) | |
tree | 42e65db717a26e127dca394ac2cbd17d561012df /lib | |
parent | f39be72d8c5d001981ef95bddc5e8ecd09d54b84 (diff) |
lib/igt_core: Split out env-related handling to common_init_env
This moves the parts of the code doing env-related handling from
common_init to a new dedicated common_init_env function, making
common_init a bit more readable.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@linux.intel.com>
Reviewed-by: Lyude <lyude@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/igt_core.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c index e25276fc..c0488e94 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -652,8 +652,6 @@ static void common_init_config(void) g_clear_error(&error); - frame_dump_path = getenv("IGT_FRAME_DUMP_PATH"); - if (!frame_dump_path) frame_dump_path = g_key_file_get_string(igt_key_file, "Common", "FrameDumpPath", @@ -676,6 +674,31 @@ out: } #endif +static void common_init_env(void) +{ + const char *env; + + if (!isatty(STDOUT_FILENO) || getenv("IGT_PLAIN_OUTPUT")) + __igt_plain_output = true; + + if (!__igt_plain_output) + setlocale(LC_ALL, ""); + + env = getenv("IGT_LOG_LEVEL"); + if (env) { + if (strcmp(env, "debug") == 0) + igt_log_level = IGT_LOG_DEBUG; + else if (strcmp(env, "info") == 0) + igt_log_level = IGT_LOG_INFO; + else if (strcmp(env, "warn") == 0) + igt_log_level = IGT_LOG_WARN; + else if (strcmp(env, "none") == 0) + igt_log_level = IGT_LOG_NONE; + } + + frame_dump_path = getenv("IGT_FRAME_DUMP_PATH"); +} + static int common_init(int *argc, char **argv, const char *extra_short_opts, const struct option *extra_long_opts, @@ -699,25 +722,8 @@ static int common_init(int *argc, char **argv, int extra_opt_count; int all_opt_count; int ret = 0; - const char *env; - - if (!isatty(STDOUT_FILENO) || getenv("IGT_PLAIN_OUTPUT")) - __igt_plain_output = true; - - if (!__igt_plain_output) - setlocale(LC_ALL, ""); - env = getenv("IGT_LOG_LEVEL"); - if (env) { - if (strcmp(env, "debug") == 0) - igt_log_level = IGT_LOG_DEBUG; - else if (strcmp(env, "info") == 0) - igt_log_level = IGT_LOG_INFO; - else if (strcmp(env, "warn") == 0) - igt_log_level = IGT_LOG_WARN; - else if (strcmp(env, "none") == 0) - igt_log_level = IGT_LOG_NONE; - } + common_init_env(); command_str = argv[0]; if (strrchr(command_str, '/')) |