Received: by 10.223.185.116 with SMTP id b49csp912349wrg; Sat, 3 Mar 2018 10:17:33 -0800 (PST) X-Google-Smtp-Source: AG47ELsl8ilw4Et5jqdzu5tNetduWOCImbZmxCa+BOxBYvjpzjsU6P37jhGKkEzsnVEtg2W34mLY X-Received: by 10.101.75.70 with SMTP id k6mr8102863pgt.335.1520101053646; Sat, 03 Mar 2018 10:17:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520101053; cv=none; d=google.com; s=arc-20160816; b=h+f9B9TSyjNmi+Jvl+kCPEOFAVw4XKDT2nKnt7Ek5ipWEXmLl65G3QPX4WfIvvFeoC R/vQBp5nj/qSkQ2Lq0mMrDyfzl3+31j8m1tL7ihkj2HeuX7KwNgss32MvYB7NNTKUT8P trScRZuV8STYbLRwkXz9fvvOMb0rex2hgBt91GQp2A47bvLb/7EtNWBLVgUFUoySPMkh xIIgeuRm9tVkYbn7inZfKi/wF5KG95jRTbaQzHseJGP3XEZ/K8FbVy4NwhthDq4K1Cs9 cTdA/+1ZZWvW0W9YBEe+oxK784uOClvT2OOycFZrn4i8xlBDWaES9xT/4nEKrZ1uFVuG m0Yg== 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=TqaodjeVljcposgxVfezgt/dLS/Q39uE8GWy4H09vGA=; b=bNxPssNrGr+JGIAybwJ8dvIVRJ8+DmEBEj+Qd+EmkSEozC/nt0rWN70YQrgUDDo1IS WMK872RUKwTY8rLr7e5cIdY+Gfy7Gn4cYoH5fyr31L2fFeQYleVl997CLqrJe8j2d1Cy 1xbi6ci1ceRz77CXabJ2FBX3gxHkpDX731byEnZ/tfCmY48gE9C6I9WDBQGYE8Nj05eD T/mowLS77ccZUI7Km0nvTuk1ewF1H5S54KUvcRoEaLXID5n2uUsEBM7EIDWLWitW0opU kvY8sMZOotCnFgYmvyh5oBP2Mc8RUo+/kFxIONDTH8V5jUUl0PS18nEfLxVpvEhjnK16 FbpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rgTSd3qJ; 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 e33-v6si6623127pld.493.2018.03.03.10.16.47; Sat, 03 Mar 2018 10:17:33 -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=rgTSd3qJ; 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 S1752231AbeCCSPB (ORCPT + 99 others); Sat, 3 Mar 2018 13:15:01 -0500 Received: from mail-ua0-f196.google.com ([209.85.217.196]:32783 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752116AbeCCSO7 (ORCPT ); Sat, 3 Mar 2018 13:14:59 -0500 Received: by mail-ua0-f196.google.com with SMTP id f6so2739253ual.0; Sat, 03 Mar 2018 10:14:59 -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=TqaodjeVljcposgxVfezgt/dLS/Q39uE8GWy4H09vGA=; b=rgTSd3qJfrKJD436FRkR5EqAQQSBNR8cQP1XS1B8iQVKp6IBRLOQGrA8i6gXz9aGcc JJLRN3mpJSQFChqJvg+RVYExie9DZL2EiX/x77syqo0dNHzrXIXhE9lM+7XyuLwcy2KU NzSlDpdrcXAEPtpkxtSwT9lxrPVfBPlAxVJXwm554LmE5i9MSCmPsdksIpWhsuExhcXg dsytUdRdqSflZrgNkpaG6GNU62KxrB+w55CK1ocYEM5MHA/6N+lJpRM/zyvHCX1KQHVe N4p+bMJXOIAO3etnvwF20Tz9hfcL8Jq4o1u1jgmctEzRskw4chV+0cYfv8P1wHtLXiuV UpiA== 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=TqaodjeVljcposgxVfezgt/dLS/Q39uE8GWy4H09vGA=; b=lYrf3m77wXjKq+82Sk9y96JXCa9u17ACbiINK2jW1Et7YktPeZa6sj+pfdyOGIiSIh cfb3kMGaFDzBIE20FtiaNFLoQ84RDmfYssrDlsEDHlUv7rAFqVRoxS3MhdYMNa+yEQKE qZVDY8s1T8RKixbRWMr17EfJ7TXeDB2vAjOTFBJ3gll/Z38HPo/raxpr7QaI7hNralnB Ggbua5kL+ky7sqlNiJrXCY8AKtxhFiz0MyWNImipF4SSjox04FKTh8h+e010eJc/5d21 sCnfk/7o5RNvL/+JqIifI4cMkLuvniyrHrVYMJFQHiisR6DJ50vEOkYwT0ud2kqg1ID4 kPAg== X-Gm-Message-State: APf1xPDfLa9/HR9J6/mULbQx9ALYDnggg+5jRJJapocAkGKDJZuLCZnv UV5Ou6/2eH5xHJkDI1lLP2YZ/3W8VDNvJj3aqfM= X-Received: by 10.176.9.100 with SMTP id c36mr7249063uah.118.1520100897455; Sat, 03 Mar 2018 10:14:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.220.145 with HTTP; Sat, 3 Mar 2018 10:14:57 -0800 (PST) In-Reply-To: <20180302231256.4aevdu2b5ylyrzkr@gmail.com> References: <20180302074424.2myh3zhxnbpaohjq@gmail.com> <20180302134453.mtd4uepeiviicyef@huvuddator> <20180302231256.4aevdu2b5ylyrzkr@gmail.com> From: Ulf Magnusson Date: Sat, 3 Mar 2018 19:14:57 +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 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. '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