From patchwork Thu Jul 20 14:11:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowki X-Patchwork-Id: 9855047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D18FD600F5 for ; Thu, 20 Jul 2017 14:12:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C305028571 for ; Thu, 20 Jul 2017 14:12:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7DB8286B8; Thu, 20 Jul 2017 14:12:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 77F9128571 for ; Thu, 20 Jul 2017 14:12:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 761766E6B2; Thu, 20 Jul 2017 14:12:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 061A86E6A5 for ; Thu, 20 Jul 2017 14:12:19 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jul 2017 07:12:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.40,384,1496127600"; d="scan'208"; a="1174752853" Received: from linux.intel.com ([10.54.29.200]) by fmsmga001.fm.intel.com with ESMTP; 20 Jul 2017 07:11:47 -0700 Received: from workstation.fi.intel.com (workstation.fi.intel.com [10.237.68.144]) by linux.intel.com (Postfix) with ESMTP id D187D5808F0; Thu, 20 Jul 2017 07:11:43 -0700 (PDT) From: Paul Kocialkowski To: intel-gfx@lists.freedesktop.org Date: Thu, 20 Jul 2017 17:11:27 +0300 Message-Id: <20170720141127.14974-2-paul.kocialkowski@linux.intel.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170720141127.14974-1-paul.kocialkowski@linux.intel.com> References: <20170720141127.14974-1-paul.kocialkowski@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/2] lib/igt_core: Split out env-related handling to common_init_env X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- lib/igt_core.c | 46 ++++++++++++++++++++++++++-------------------- 1 file 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, '/'))