This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] use xstrdup and concat more
- From: Trevor Saunders <tbsaunde at tbsaunde dot org>
- To: Alan Modra <amodra at gmail dot com>
- Cc: tbsaunde+binutils at tbsaunde dot org, binutils at sourceware dot org
- Date: Tue, 26 Apr 2016 19:58:43 -0400
- Subject: Re: [PATCH] use xstrdup and concat more
- Authentication-results: sourceware.org; auth=none
- References: <1461483896-3190-1-git-send-email-tbsaunde+binutils at tbsaunde dot org> <20160425130136 dot GH27353 at bubble dot grove dot modra dot org> <20160425135550 dot GE25520 at tsaunders-iceball dot corp dot tor1 dot mozilla dot com> <20160425145629 dot GJ27353 at bubble dot grove dot modra dot org>
On Tue, Apr 26, 2016 at 12:26:29AM +0930, Alan Modra wrote:
> On Mon, Apr 25, 2016 at 09:55:50AM -0400, Trevor Saunders wrote:
> > On Mon, Apr 25, 2016 at 10:31:36PM +0930, Alan Modra wrote:
> > > On Sun, Apr 24, 2016 at 03:44:56AM -0400, tbsaunde+binutils@tbsaunde.org wrote:
> > > > --- a/gas/config/obj-elf.c
> > > > +++ b/gas/config/obj-elf.c
> > > > @@ -949,9 +949,7 @@ obj_elf_section_name (void)
> > > > return NULL;
> > > > }
> > > >
> > > > - name = (char *) xmalloc (end - input_line_pointer + 1);
> > > > - memcpy (name, input_line_pointer, end - input_line_pointer);
> > > > - name[end - input_line_pointer] = '\0';
> > > > + name = xstrndup (input_line_pointer, end - input_line_pointer);
> > > >
> > > > while (flag_sectname_subst)
> > > > {
> > >
> > > Is this a good idea, here, and in other places where the original uses
> > > memcpy and strlen was not called to find the string length? I'm
> > > thinking that xstrndup will be needlessly calling strlen.
> >
> > I guess that's true, I'm not sure if that really matters though?
>
> Quite possibly not. I wasn't rejecting the patch and didn't see
> anything in the patch that raised a red flag. It was more a case
> of asking you to think about possible performance effects when tidying
> code. Fewer lines of code is not always better.
Of course ;) I think most of it is around section names which I imagine
isn't very hot. What would you like to do here?
Trev
>
> --
> Alan Modra
> Australia Development Lab, IBM