From: Alan Modra <amodra@gmail.com>
To: tbsaunde+binutils@tbsaunde.org
Cc: binutils@sourceware.org
Subject: Re: [PATCH] use xstrdup and concat more
Date: Mon, 25 Apr 2016 13:01:00 -0000 [thread overview]
Message-ID: <20160425130136.GH27353@bubble.grove.modra.org> (raw)
In-Reply-To: <1461483896-3190-1-git-send-email-tbsaunde+binutils@tbsaunde.org>
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.
Hmm, maybe use xmemdup? Mind you, the xmemdup implementation isn't
ideal due to zeroing with xcalloc, but that could be fixed.
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2016-04-25 13:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-24 7:38 tbsaunde+binutils
2016-04-25 8:40 ` Nick Clifton
2016-04-25 13:01 ` Alan Modra [this message]
2016-04-25 13:56 ` Trevor Saunders
2016-04-25 14:56 ` Alan Modra
2016-04-26 23:52 ` Trevor Saunders
2016-04-27 6:19 ` Alan Modra
2016-04-27 10:21 ` Trevor Saunders
2016-04-27 11:59 ` Alan Modra
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=20160425130136.GH27353@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=tbsaunde+binutils@tbsaunde.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).