public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joe Simmons-Talbott <josimmon@redhat.com>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH] argp-parse: Get rid of alloca
Date: Mon, 28 Aug 2023 09:20:33 -0400	[thread overview]
Message-ID: <20230828132033.GT3849957@oak> (raw)
In-Reply-To: <20230815144912.GQ3849957@oak>

Ping.

On Tue, Aug 15, 2023 at 10:49:12AM -0400, Joe Simmons-Talbott via Libc-alpha wrote:
> On Thu, Aug 03, 2023 at 09:10:49AM -0400, Joe Simmons-Talbott via Libc-alpha wrote:
> > On Thu, Jul 13, 2023 at 08:48:13AM -0400, Joe Simmons-Talbott wrote:
> > > Even though the alloca usage is relatively small and fixed size the code
> > > can be written without using alloca.  Convert to local variables.
> > 
> > Ping.
> Ping.
> 
> Thanks,
> Joe
> > 
> > Thanks,
> > Joe
> > > 
> > > Checked on x86_64-linux-gnu.
> > > ---
> > >  argp/argp-parse.c | 20 +++++++++++---------
> > >  1 file changed, 11 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/argp/argp-parse.c b/argp/argp-parse.c
> > > index a44b50f8e4..40a5896d21 100644
> > > --- a/argp/argp-parse.c
> > > +++ b/argp/argp-parse.c
> > > @@ -884,6 +884,9 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
> > >    error_t err;
> > >    struct parser parser;
> > >  
> > > +  struct argp_child child[4];
> > > +  struct argp top_argp;
> > > +
> > >    /* If true, then err == EBADKEY is a result of a non-option argument failing
> > >       to be parsed (which in some cases isn't actually an error).  */
> > >    int arg_ebadkey = 0;
> > > @@ -891,24 +894,23 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
> > >    if (! (flags & ARGP_NO_HELP))
> > >      /* Add our own options.  */
> > >      {
> > > -      struct argp_child *child = alloca (4 * sizeof (struct argp_child));
> > > -      struct argp *top_argp = alloca (sizeof (struct argp));
> > > +      int child_index = 0;
> > >  
> > >        /* TOP_ARGP has no options, it just serves to group the user & default
> > >  	 argps.  */
> > > -      memset (top_argp, 0, sizeof (*top_argp));
> > > -      top_argp->children = child;
> > > +      memset (&top_argp, 0, sizeof (struct argp));
> > > +      top_argp.children = child;
> > >  
> > >        memset (child, 0, 4 * sizeof (struct argp_child));
> > >  
> > >        if (argp)
> > > -	(child++)->argp = argp;
> > > -      (child++)->argp = &argp_default_argp;
> > > +	child[child_index++].argp = argp;
> > > +      child[child_index++].argp = &argp_default_argp;
> > >        if (argp_program_version || argp_program_version_hook)
> > > -	(child++)->argp = &argp_version_argp;
> > > -      child->argp = 0;
> > > +	child[child_index++].argp = &argp_version_argp;
> > > +      child[child_index].argp = 0;
> > >  
> > > -      argp = top_argp;
> > > +      argp = &top_argp;
> > >      }
> > >  
> > >    /* Construct a parser for these arguments.  */
> > > -- 
> > > 2.39.2
> > > 
> > 
> 


  reply	other threads:[~2023-08-28 13:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13 12:48 Joe Simmons-Talbott
2023-08-03 13:10 ` Joe Simmons-Talbott
2023-08-15 14:49   ` Joe Simmons-Talbott
2023-08-28 13:20     ` Joe Simmons-Talbott [this message]
2023-08-28 16:44 ` Adhemerval Zanella Netto

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=20230828132033.GT3849957@oak \
    --to=josimmon@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).