mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: SCHNEIDER Johannes <johannes.schneider@leica-geosystems.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: [PATCH v2] common: add custom autoboot_abort_key
Date: Mon, 4 Nov 2024 12:55:30 +0000	[thread overview]
Message-ID: <AM8PR06MB7521281D18381AC470D2B8ACBC512@AM8PR06MB7521.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <Zyi2JpuQYAb_yHCW@pengutronix.de>


> 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@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



      reply	other threads:[~2024-11-04 12:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-02 14:43 Johannes Schneider
2024-11-04 11:54 ` Sascha Hauer
2024-11-04 11:55 ` Sascha Hauer
2024-11-04 12:55   ` SCHNEIDER Johannes [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM8PR06MB7521281D18381AC470D2B8ACBC512@AM8PR06MB7521.eurprd06.prod.outlook.com \
    --to=johannes.schneider@leica-geosystems.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox