Message ID | 20230723044041.1089804-14-bmeng@tinylab.org |
---|---|
State | Accepted |
Commit | f30fd55e82ae82b720649cc67744308a8356a874 |
Delegated to: | Andes |
Headers | show |
Series | video: bochs: Remove the x86 limitation | expand |
On 7/23/23 06:40, Bin Meng wrote: > In preparation to future changes, refactor this routine a little bit. > > Signed-off-by: Bin Meng <bmeng@tinylab.org> > --- > > 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!"; This string will never be printed as you have no output device. Best regards Heinrich > + 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)
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)
In preparation to future changes, refactor this routine a little bit. Signed-off-by: Bin Meng <bmeng@tinylab.org> --- common/console.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)