From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45125 invoked by alias); 25 Apr 2016 14:56:48 -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 45106 invoked by uid 89); 25 Apr 2016 14:56:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*MI:sk:2016042 X-HELO: mail-pa0-f45.google.com Received: from mail-pa0-f45.google.com (HELO mail-pa0-f45.google.com) (209.85.220.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 25 Apr 2016 14:56:37 +0000 Received: by mail-pa0-f45.google.com with SMTP id r5so59423957pag.1 for ; Mon, 25 Apr 2016 07:56:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=o1D2uouyd9kbJ6QyzaJr0hwrvkI5sBoHLXOQ6LWLZpU=; b=kZpAq7TbnLdOuKwOSYJ1wvPACZ8pJo86CxKmnfoy1wVmanNsTfE7453K4L71yBRpfM KsIDBnu7+9wfKhEMHifBL8/mv+FT1CNoRn1zebSS1m2gMgnb8Gw2u6PtZ1VhZ/pnb5My HZ4IuOA9JJ7P8sF4WSkiD+D0EwNvNJG7qRDzW1gdkVz/w+RKhXrGwfXOTIMEpXEULg7y m2hmn0EJFWdBvKDCAhVpLwwyqtm68ZsDdjew6UezUYtmcwiYW6iz7cIN449cX91F4dgE hcqqnEdaEOQk1CEZZ8PxhM3FCLnYx75bYpuRhLIAhTKVGwO+P1lBYRzgW4E0uULs52/n tUsw== X-Gm-Message-State: AOPr4FWoxD5I+Wt90VdbO1hTqFXhrJ8/iWNCrHJHNRXaZIFm/WfFY/VMtQ59AaEjhy1dgA== X-Received: by 10.66.15.106 with SMTP id w10mr6547325pac.32.1461596195486; Mon, 25 Apr 2016 07:56:35 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-146-233.sa.bigpond.net.au. [58.160.146.233]) by smtp.gmail.com with ESMTPSA id ve11sm25313751pab.21.2016.04.25.07.56.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Apr 2016 07:56:34 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id A0F3DEA0157; Tue, 26 Apr 2016 00:26:29 +0930 (ACST) Date: Mon, 25 Apr 2016 14:56:00 -0000 From: Alan Modra To: Trevor Saunders Cc: tbsaunde+binutils@tbsaunde.org, binutils@sourceware.org Subject: Re: [PATCH] use xstrdup and concat more Message-ID: <20160425145629.GJ27353@bubble.grove.modra.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160425135550.GE25520@tsaunders-iceball.corp.tor1.mozilla.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00415.txt.bz2 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. -- Alan Modra Australia Development Lab, IBM