[PATCH] cmd: bootmenu: permit to select bootmenu entry with a shortcut

Christian Marangi ansuelsmth at gmail.com
Sun May 25 15:34:11 CEST 2025


On Sun, May 25, 2025 at 01:02:13PM +0000, Petr Štetiar wrote:
> Christian Marangi <ansuelsmth at gmail.com> [2025-05-25 00:12:52]:
> 
> Hi,
> 
> thanks a lot for your upstreaming efforts!
> 
> > Permit to select a bootmenu entry with a key shortcut. This is
> > especially useful in production or testing scenario to aitomate flashing
> 
> aitomate -> automate
> 
> > 0 is always reserved for Exit to console.
> 
> BTW this is the only shortcut key which currently doesn't work :-) See below.
>

Eh last time bugfix and I forgot to test the 0 case... feel stupid
ahhaha

> > +		case BKEY_SHORTCUT:
> > +			/* invalid shortcut, regenerate menu */
> > +			if (cch->shortcut_key >= menu->count - 1)
> 
> IMO it should be:
> 
> 			if (cch->shortcut_key >= menu->count)
> 
> Considering menu with 4 items and user presses '0':
> 
>  * bootmenu_conv_shortcut_key() returns 3 (menu->count - 1), so shortcut_key = 3
> 
>  * With the original condition
>      if (cch->shortcut_key >= menu->count - 1)
>      if (3 >= 3) → true, so it returns NULL (bug)
> 
>  * With the fixed condition
>      if (cch->shortcut_key >= menu->count):
>      if (3 >= 4) → false, so it correctly proceeds
> 

This is also problematic since pressing 'b' will act as exit. I have a
simple fix for this, sending v2.

> > +				return NULL;
> > +			menu->active = cch->shortcut_key;
> > +			fallthrough;
> 
> Cheers,
> 
> Petr

-- 
	Ansuel


More information about the U-Boot mailing list