[PATCH] cli: flush stdin before enabling cli

Gregor Herburger gregor.herburger at linutronix.de
Wed Apr 1 07:32:55 CEST 2026


Hi Tom,

> Conceptually, good idea, thanks for doing it.

> > 
> > ---
> > 
> >  cmd/Kconfig  | 7 +++++++
> >  common/cli.c | 6 ++++++
> >  2 files changed, 13 insertions(+)
> > 
> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > index 322ebe600c5..e08fbf27358 100644
> > --- a/cmd/Kconfig
> > +++ b/cmd/Kconfig
> > @@ -47,6 +47,13 @@ config HUSH_SELECTABLE
> >  	default y if HUSH_OLD_PARSER && HUSH_MODERN_PARSER
> >  endmenu
> >  
> > +config CMDLINE_FLUSH_STDIN
> > +	bool "Enable flushing input before starting cli"
> > +	default n
> 
> We don't need default n as that's the default.
> > +	if (IS_ENABLED(CONFIG_CMDLINE_FLUSH_STDIN)) {
> > +		while (tstc())
> > +			(void)getchar();
> > +	}
> > +
> >  #if CONFIG_IS_ENABLED(HUSH_PARSER)
> >  	if (gd->flags & GD_FLG_HUSH_MODERN_PARSER)
> >  		parse_and_run_file();
> 
> This is flush_stdin() from common/autoboot.c, but that's a static
> function. We should find a better spot for that perhaps and then call it
> when required.


Thanks for the review. I will send a v2 to change this.
Gregor


More information about the U-Boot mailing list