Received: by 10.223.185.116 with SMTP id b49csp916962wrg; Sat, 3 Mar 2018 10:24:13 -0800 (PST) X-Google-Smtp-Source: AG47ELvRjqnkwksixFL2mDDHMm7lOlTQje690bRB/12Ge/5j6+qCKbFRrPhgNqxwDbH4o8FT6iLT X-Received: by 10.98.189.24 with SMTP id a24mr4750938pff.125.1520101452996; Sat, 03 Mar 2018 10:24:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520101452; cv=none; d=google.com; s=arc-20160816; b=F7uhsmq1fborcaJYW/f5f2wmCGjYPnapsMT8ovRYO0TmZNCydQ8IjFS1FWTpg/W8/E pKKlhz4Fhvvuof8wlIOOtNpT+YsEmUnHHiEKI28pfb1HpOCqYvremJ8F2N7Lu4wDkGWt RxKyETCWnk3VyV191+GwOvbjGt8AIQZTDRQjKepBaPxPTT6q0Y2urZHXWi+ODI/3Ki+a Ykyw41Zk1cMiY0MudcJGc/N/QY39DqS7RR5te+MuTWb8mQunqUeddssaROkrQZZyeiFC daanYUxqnLCYa9/5r+6hbKYNk22wqS9JwPwM02ljyNCGdA9TkaMDsJcu9C4NOkMyWPFX Q/nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=c2/V43cHQ+RMvTc3oilOumGlR3tOb8WnimlatmKT3QY=; b=Bq0b9NKWA9Yfm5C/z0oj9GhfAkE2NQypVajpFvPJd4jzPjJDiYZ/il8aSxSsWmD5IO sar5BJUvD1Hdi+BdfDtmst3Enyn3uyk6u7hv4cPZR97tuh4E2x2WYY6Xvul2aeqHhCqF 4HXQ2xj7OGMQSREFlazv9lGSekD2yvUWdvVfaT9eBOPduzdD++miyV+Bb6qdyLZljc4h UmW8eOgNpOKPLpli6LymNVTmnORt8N6DAk/K8JtU7WUdahHNhxB/DoTaFeX4uXV/kmCI lcuQmT0+aHf9FQ48Ac20pklHJPfnnUJLKah4/qdGwYHoIUxDs4WUmKa3oSe0ls9nwOWN DYBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TpbM2FOm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l19si5849943pgo.629.2018.03.03.10.23.58; Sat, 03 Mar 2018 10:24:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TpbM2FOm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752281AbeCCSXD (ORCPT + 99 others); Sat, 3 Mar 2018 13:23:03 -0500 Received: from mail-vk0-f50.google.com ([209.85.213.50]:42706 "EHLO mail-vk0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751827AbeCCSXB (ORCPT ); Sat, 3 Mar 2018 13:23:01 -0500 Received: by mail-vk0-f50.google.com with SMTP id y127so7581672vky.9; Sat, 03 Mar 2018 10:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=c2/V43cHQ+RMvTc3oilOumGlR3tOb8WnimlatmKT3QY=; b=TpbM2FOmqwAtu9GhTO3lLtTfY2BU5iTRGiKiAXo4+yVBKXCnxGdwoZSvIxDa2Awxf8 QkpgO0lloSAmGxSLvZmNFmE03Wf6lUG4okgQ1W+a6Qs0SEEJU1sQfS3F58lOtc0XWg3I LwVUz+JfU1nrxBvXcOoks6VBteoQQdIzx7F7vjyPeA69ksLJtNso9gYFiun7VINFKwAc WwIqi7m0FNMzOmI9Ug0Xg6cx+QqTrk34aF3lQwC9T5mP2uMOwo3RKOgSY69lhFrQaYFd lBNNURX0VgfT53dxAG4NUB3kU8hgg2EH9pjcoKhheYPb6eNJ+Z5JU7ORp2lPYsJHbMH/ GTcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=c2/V43cHQ+RMvTc3oilOumGlR3tOb8WnimlatmKT3QY=; b=I6ZPjZtgXOsAn/d4mUyVy7lxLtF1t7Nyfatp52xg5nV+xeFyMqi+jNf+W2ezek9a0P kznAVz7vWJlLUcyiAAoKV6mRan25g5Xla7UWXLxwMdc8oI/91EW2bFSgVI0nP81ehtbd v2zncUViev1hUORfvAMGniQVQecfCwVwySLE8TOkjEvp5KZsxX1oRxJyp/SRgIBiTRd0 ZaSUhVPaECY8s0KxxmeryEJ2wFK1CgiRbOcC79gwLMZ8VrwTPrKkaVE7d5qsFAuwJyDd LRSNXwyOc2pjBmklIu5spod4i048Unq3YZ0PkkwMgHv78hLJcC2ql3NnJ5GR/ZmRcNaA wpkQ== X-Gm-Message-State: APf1xPBkIRv/dXRfrvzN4zAx/6jM7vjMfo95s52NOkBrJqaBlqNEdwkW piEt699hdEJ1f4dKM+Rz2i3fgCsDjaNwB1GxfpI= X-Received: by 10.31.201.70 with SMTP id z67mr6433964vkf.154.1520101381041; Sat, 03 Mar 2018 10:23:01 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.220.145 with HTTP; Sat, 3 Mar 2018 10:23:00 -0800 (PST) In-Reply-To: References: <20180302074424.2myh3zhxnbpaohjq@gmail.com> <20180302134453.mtd4uepeiviicyef@huvuddator> <20180302231256.4aevdu2b5ylyrzkr@gmail.com> From: Ulf Magnusson Date: Sat, 3 Mar 2018 19:23:00 +0100 Message-ID: Subject: Re: [PATCH] scripts/kconfig: replace single character strcat() appends To: Joey Pabalinas Cc: Linux Kbuild mailing list , Arnaud Lacombe , Masahiro Yamada , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 3, 2018 at 7:14 PM, Ulf Magnusson wrote: > On Sat, Mar 3, 2018 at 12:12 AM, Joey Pabalinas wrote: >> On Fri, Mar 02, 2018 at 02:44:53PM +0100, Ulf Magnusson wrote: >>> Not sure this is an improvement. Zeroing the bytes after the initial >>> null terminator is redundant, and the explicit '\0' makes it clearer to >>> me what's going on. >> >> Yes, I agree with you, that is definitely quite true. This along with >> the other comments you made me want to rethink this a little bit. >> >> On Fri, Mar 02, 2018 at 02:44:53PM +0100, Ulf Magnusson wrote: >>> I like the approach, but I wonder if we can take it a bit further. >>> Here's what I'd do: >>> >>> 1. Rename the 'in' parameter to 's'. >>> 2. Rename 'p' to 'in'. >>> 3. Rename 'end' to 'out' >>> >>> At that point, you're reading from 'in' and writing to 'out', which >>> seems pretty nice and readable. >>> >>> This code is pretty cold by the way, so it wouldn't matter for >>> performance. GCC knows how functions like strcat() work too, and uses >>> that to optimize (see >>> https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html). >>> >>> I'm all for trying to make Kconfig's code neater though. >> >> Since this code is pretty cold (completely agree with you there), I >> think it would actually be much more useful to rework my patch to >> have a more style-centric approach rather than an optimization-centric >> one; this code would definitely benefit from being neater. > > I actually prefer the memcpy() version for style reasons, even though > it might've looked like an optimization: > > With strncat(), the result string is written via both 'res' and 'end'. > With memcpy(), it's only written via the 'end'. That seems less > twisty. > > Maybe this is outside the scope of the original patch, but while we're here. :) > >> >> Some useful changes would be to rename of the _atrociously_ short >> identifiers like p and l. > > Yeah, 'l' in particular isn't the best name, IMO ('len' is both short > and explicit, and won't be confused for 1). 'p' can be fine if it's > obvious in context (bit dubious here), but 'in' and 'out' (for 'end') > would be more informative. Another alternative: src/dst > > 's' is clear from convention to me. In general, I fully agree that you > should avoid hard-to-guess names though. > >> >> Anyway I'll give that link a read over and try and make a V2 later >> on today. >> >> Appreciate the feedback, thanks for the comments! >> >> -- >> Cheers, >> Joey Pabalinas > > Cheers, > Ulf Cheers, Ulf