[PATCH v2] common: add custom autoboot_abort_key

SCHNEIDER Johannes johannes.schneider at leica-geosystems.com
Mon Nov 4 04:55:30 PST 2024


> Subject: Re: [PATCH v2] common: add custom autoboot_abort_key
> 
> This email is not from Hexagon’s Office 365 instance. Please be careful while clicking links, opening attachments, or replying to this email.
> 
> 
> On Sat, Nov 02, 2024 at 03:43:42PM +0100, Johannes Schneider wrote:
> > Extend the autoboot_abort_key handling to alow custom
> > abort keys.
> >
> > Allowed values to set in the env/nv/autoboot_abort_key
> > are any single ascii charater corresponding to the desired keyboard
> > key, or the strings 'any' or 'ctrl-c'
> >
> > Signed-off-by: Johannes Schneider <johannes.schneider at leica-geosystems.com>
> > ---
> >  common/startup.c | 53 ++++++++++++++++++++++++++++--------------------
> >  1 file changed, 31 insertions(+), 22 deletions(-)
> >
> > diff --git a/common/startup.c b/common/startup.c
> > index 47b70a7..125bcf1 100644
> > --- a/common/startup.c
> > +++ b/common/startup.c
> > @@ -93,11 +93,7 @@ static int load_environment(void)
> >  }
> >  environment_initcall(load_environment);
> >
> > -static int global_autoboot_abort_key;
> > -static const char * const global_autoboot_abort_keys[] = {
> > -     "any",
> > -     "ctrl-c",
> > -};
> > +static char *global_autoboot_abort_key;
> >  static int global_autoboot_timeout = 3;
> >
> >  static const char * const global_autoboot_states[] = {
> > @@ -187,24 +183,22 @@ enum autoboot_state do_autoboot_countdown(void)
> >       menu_exists = stat(MENUFILE, &s) == 0;
> >
> >       if (menu_exists) {
> > -             printf("\nHit m for menu or %s to stop autoboot: ",
> > -                    global_autoboot_abort_keys[global_autoboot_abort_key]);
> >               abortkeys = "m";
> > -     } else {
> > -             printf("\nHit %s to stop autoboot: ",
> > -                    global_autoboot_abort_keys[global_autoboot_abort_key]);
> >       }
> >
> > -     switch (global_autoboot_abort_key) {
> > -     case 0:
> > +     if (!global_autoboot_abort_key ||
> > +         !strcmp(global_autoboot_abort_key, "any"))
> >               flags |= CONSOLE_COUNTDOWN_ANYKEY;
> > -             break;
> > -     case 1:
> > +     else if (!strcmp(global_autoboot_abort_key, "ctrl-c"))
> >               flags |= CONSOLE_COUNTDOWN_CTRLC;
> > -             break;
> > -     default:
> > -             break;
> > -     }
> > +     else
> > +             abortkeys = xasprintf("%s%s",
> > +                                   (abortkeys)?abortkeys:"",
> > +                                   global_autoboot_abort_key);
> 
> This memory is never freed. I converted it into a static array while
> applying.
> 
> Sascha
> 

ups :-S
thanks! :-)


gruß
Johannes



More information about the barebox mailing list