From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48142 invoked by alias); 26 Apr 2016 23:52:51 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 48109 invoked by uid 89); 26 Apr 2016 23:52:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*MI:sk:2016042 X-HELO: paperclip.tbsaunde.org Received: from tbsaunde.org (HELO paperclip.tbsaunde.org) (66.228.47.254) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Apr 2016 23:52:40 +0000 Received: from ball (unknown [IPv6:2607:f0c8:8000:80e0:56ee:75ff:fe52:afb9]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id 0FFC0C0CB; Tue, 26 Apr 2016 23:52:39 +0000 (UTC) Date: Tue, 26 Apr 2016 23:52:00 -0000 From: Trevor Saunders To: Alan Modra Cc: tbsaunde+binutils@tbsaunde.org, binutils@sourceware.org Subject: Re: [PATCH] use xstrdup and concat more Message-ID: <20160426235843.GC9731@ball> References: <1461483896-3190-1-git-send-email-tbsaunde+binutils@tbsaunde.org> <20160425130136.GH27353@bubble.grove.modra.org> <20160425135550.GE25520@tsaunders-iceball.corp.tor1.mozilla.com> <20160425145629.GJ27353@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160425145629.GJ27353@bubble.grove.modra.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2016-04/txt/msg00424.txt.bz2 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