]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
console: Refactor stdio_print_current_devices() a little bit
authorBin Meng <bmeng@tinylab.org>
Sun, 23 Jul 2023 04:40:36 +0000 (12:40 +0800)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Wed, 2 Aug 2023 08:32:26 +0000 (16:32 +0800)
In preparation to future changes, refactor this routine a little bit.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
common/console.c

index d0640ba05a9ce4d1d217cd73744ede0bf8ac44ec..af52897ec38a645b1e29e656b8cf9c883881fac8 100644 (file)
@@ -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)