Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3F1CC001B0 for ; Sun, 23 Jul 2023 04:44:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4441886826; Sun, 23 Jul 2023 06:42:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinylab.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id DFA6786824; Sun, 23 Jul 2023 06:42:11 +0200 (CEST) Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D8824867D9 for ; Sun, 23 Jul 2023 06:42:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinylab.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng@tinylab.org X-QQ-mid: bizesmtp84t1690087284tjxivlw2 Received: from ubuntu.. ( [111.196.130.174]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 23 Jul 2023 12:41:23 +0800 (CST) X-QQ-SSF: 01200000000000F0H000000A0000000 X-QQ-FEAT: swyrzWPvyR3RSJF4evPd0Ce8lSupUlxOhpqNg80WI8/WrVpLXf01j8OuwlwtF O6SqI3k5rE7oJxOrOO4MAe7z0CyFmNBmeiuUpwdM+q/WqajCPuaKfUzteou5gu4/VbiSXbv 9go5y3ChDmK74j3UghkwEBIfeYST4rWM82bCrYbWXlBD1i1e30MB0LfAIyUiML47z9xHJjz MuPEdgr+qKwlMukYi+dQqhR9jiYHUDDAKtlN+rv71gFio5X+hgPHVp3yrvGBmMRSkn8uFH4 DZE+GhOzsFw9VrIWGdMcKtN7mLFcDXJdEJ/5odQB4eZ4EshV7UWxq4Cw4e/s35OVqZhS6qI fYWHZABLOIcwdEipyMvc5ZAn7WEgQ0tFtisjLDd X-QQ-GoodBg: 0 X-BIZMAIL-ID: 5140705047873892188 From: Bin Meng To: Simon Glass , u-boot@lists.denx.de Cc: Harald Seiler , Heinrich Schuchardt , Marek Vasut , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Rasmus Villemoes , Stefan Roese Subject: [PATCH 13/18] console: Refactor stdio_print_current_devices() a little bit Date: Sun, 23 Jul 2023 12:40:36 +0800 Message-Id: <20230723044041.1089804-14-bmeng@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230723044041.1089804-1-bmeng@tinylab.org> References: <20230723044041.1089804-1-bmeng@tinylab.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz7a-0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean In preparation to future changes, refactor this routine a little bit. Signed-off-by: Bin Meng --- common/console.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/common/console.c b/common/console.c index d0640ba05a..af52897ec3 100644 --- a/common/console.c +++ b/common/console.c @@ -1012,27 +1012,27 @@ int console_init_f(void) static void stdio_print_current_devices(void) { + char *stdinname, *stdoutname, *stderrname; + + stdinname = stdio_devices[stdin] ? + stdio_devices[stdin]->name : + "No input devices available!"; + stdoutname = stdio_devices[stdout] ? + stdio_devices[stdout]->name : + "No output devices available!"; + stderrname = stdio_devices[stderr] ? + stdio_devices[stderr]->name : + "No error devices available!"; + /* Print information */ puts("In: "); - if (stdio_devices[stdin] == NULL) { - puts("No input devices available!\n"); - } else { - printf ("%s\n", stdio_devices[stdin]->name); - } + printf("%s\n", stdinname); puts("Out: "); - if (stdio_devices[stdout] == NULL) { - puts("No output devices available!\n"); - } else { - printf ("%s\n", stdio_devices[stdout]->name); - } + printf("%s\n", stdoutname); puts("Err: "); - if (stdio_devices[stderr] == NULL) { - puts("No error devices available!\n"); - } else { - printf ("%s\n", stdio_devices[stderr]->name); - } + printf("%s\n", stderrname); } #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) -- 2.34.1