Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1401190pxu; Sat, 5 Dec 2020 15:09:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxO7ntgkP3SE1GEXiwUgWZROQCQ0VCGMKFgx2BTshZwLU9Pq56YzxgGvT3cNSgJJNf2z3OE X-Received: by 2002:a17:906:d0c2:: with SMTP id bq2mr7736154ejb.1.1607209751521; Sat, 05 Dec 2020 15:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607209751; cv=none; d=google.com; s=arc-20160816; b=mGy4FYGm2twUoJIqgeNRXaCeHUUCzPYoXNrdMOKjQYpdc2GcTCCvUwNxIGonich/C2 hrwWeHS5Hb9lYkPnMtHOIHJfSbnCqfBfQ6ccdDsXJog1fVfSLAiCWWSB6P6QaYRYc5Yr GiSOV6EbAAtLrUmTP5+f5rkDWAjtf70oL17xAQSjXHO8ZQGg41dzWVoudgVJCP2N4WSQ ZCK8MjWrFsPWYGO8srzZiwDnAcg7CoKQPkj9rmQh0z+oAgpQ1g1yaETuFLhXfsulpod8 mfc0suUOV+lG5pwXCDsSDpGVDVneoZfm0eNCQMJFBcgQt5difulx2FvJGZ+88JO+NH7Z p0vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature:dkim-signature; bh=Dz6gZmUMz0PrZ+Kno3op05d+U37ajtPL/UaHnbNSr10=; b=Q2qeI0n7Ffg6WtICtW3XTCk0arXR6Kdoz15tcTOKDSCLu74cbXY+bkRH+MUzeuPdHI 6OJjWEc050OQ0DBLLhKewzpgvrYAmK8jDOb2Pe+Ipl1Q4uLRaxnmw1W9v7HG6r66GnPA mpZYkqC1hUcF4nRBNCzoWvSxxo1RckattobWeao6BIiew80rU75pNtsll6zuH6A7YD5s hBuXYtNp8Ljeae3Li/9Vl/YpJrO4ep0FHhM4741vxFzBEzNyGSmNB0X4nrqf4gIe5CJL QjhNRVzIvMWb0dAYPKE8QdCJKVwQpVmhnSNPjjMj+/aPFEzHhjRGEi8AKlS0UluAYtAN /1tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=Eq+EiKxG; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=Eq+EiKxG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v16si3886469eja.188.2020.12.05.15.08.48; Sat, 05 Dec 2020 15:09:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=Eq+EiKxG; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=Eq+EiKxG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726515AbgLEXFO (ORCPT + 99 others); Sat, 5 Dec 2020 18:05:14 -0500 Received: from bedivere.hansenpartnership.com ([96.44.175.130]:47534 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbgLEXFN (ORCPT ); Sat, 5 Dec 2020 18:05:13 -0500 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 38BA412803B8; Sat, 5 Dec 2020 15:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1607209473; bh=OHgDzHQ4UVZtoQc0+c8rR/RVimSRVd9Ac21GYuD8peA=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=Eq+EiKxG9EjW7mlOdt08xkKc534CrovgkHN6oAqEbvKSK9K9dpjlyf5EtklYPVy+/ CcR6dJjhtW7bsPbWln4KTuKEADODYZYN0jfSIE8i1fnKlnX+hehYP7xyABK/b6eGAo YfZ3FsIX1tSUaR8o92BGXwgbT5DQtboHC7dj+yUc= Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FDIwrjWU5y9O; Sat, 5 Dec 2020 15:04:33 -0800 (PST) Received: from jarvis.int.hansenpartnership.com (unknown [IPv6:2601:600:8280:66d1::527]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id BDAE31280319; Sat, 5 Dec 2020 15:04:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1607209473; bh=OHgDzHQ4UVZtoQc0+c8rR/RVimSRVd9Ac21GYuD8peA=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=Eq+EiKxG9EjW7mlOdt08xkKc534CrovgkHN6oAqEbvKSK9K9dpjlyf5EtklYPVy+/ CcR6dJjhtW7bsPbWln4KTuKEADODYZYN0jfSIE8i1fnKlnX+hehYP7xyABK/b6eGAo YfZ3FsIX1tSUaR8o92BGXwgbT5DQtboHC7dj+yUc= Message-ID: <8a169362defed5af16be78c5a11f4ff9f58da2a8.camel@HansenPartnership.com> Subject: Re: [RFC PATCH v1 07/12] efi: Replace strstarts() by str_has_prefix(). From: James Bottomley To: Ard Biesheuvel Cc: laniel_francis@privacyrequired.com, linux-efi , Linux Kernel Mailing List , Steven Rostedt Date: Sat, 05 Dec 2020 15:04:31 -0800 In-Reply-To: References: <20201204170319.20383-1-laniel_francis@privacyrequired.com> <20201204170319.20383-8-laniel_francis@privacyrequired.com> <3161fc13d69c388b1f51f59c6ecea48dcd0a7856.camel@HansenPartnership.com> <043040d9c092cedcab8bf88b0ec805616d3be44d.camel@HansenPartnership.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2020-12-05 at 22:20 +0100, Ard Biesheuvel wrote: > On Sat, 5 Dec 2020 at 22:15, James Bottomley > wrote: > > [Rostedt added because this is all his fault] > > On Sat, 2020-12-05 at 21:57 +0100, Ard Biesheuvel wrote: > > > On Sat, 5 Dec 2020 at 21:24, James Bottomley > > > wrote: > > [...] > > > > > So I don't object to using str_has_prefix() in new code in > > > > > this way, but I really don't see the point of touching > > > > > existing code. > > > > > > > > That's your prerogative as a Maintainer ... I was just > > > > explaining what the original author had in mind when > > > > str_has_prefix() was created. > > > > > > > > > > Sure, I fully understand you are not the one proposing these > > > changes. > > > > > > But if the pattern in question is so common, couldn't we go one > > > step further and define something like > > > > > > static inline const u8 *skip_prefix_or_null(const u8 *str, const > > > u8 *prefix) > > > { > > > } > > > > > > which returns a pointer into the original string, or NULL if the > > > prefix is not present. > > > > > > The current patch as proposed has no benefit whatsoever, but even > > > the meaningful alternative you are proposing is not actually an > > > improvement, given that it is not self-explanatory from the name > > > 'str_has_prefix' what it returns, and so the code becomes more > > > difficult to understand. > > > > Ah, so this is the kernel maintainer's syndrome: you see an API > > which isn't quite right for your use case, so you update or change > > it. Then you see other use cases for it and suddenly to you it > > becomes the best thing since sliced bread and with a one ring to > > rule them all mentality you exhort everyone to use this new API > > everywhere. See this comment in the merge commit (495d714ad1400) > > which comes from the merge cover letter: > > > > > - Addition of str_has_prefix() and a few use cases. There > > > currently is a similar function strstart() that is used in > > > a > > > few places, but only returns a bool and not a length. These > > > instances will be removed in the future to use > > > str_has_prefix() instead. > > > > Then you forget about it until someone else acts on your somewhat > > ill considered instruction and actually tries the > > replacement. Once someone takes up your cause, the API shows up in > > dozens of emails and the actual debate about whether or not this is > > such a good API really begins, with the poor person who picked it > > up caught in the crossfire. > > > > As maintainers we really should learn to put the cart before the s/to put/not to put/ > > horse. > > > > I am not disagreeing with any of this, but I simply don't see a point > in merging patches that apparently result in the exact same machine > code to be generated, and don't substantially make the code itself > any better. Well, I think the pattern if (strstarts(option, )) { ... option += strlen(); is a bad one because one day may get updated but not . And if is too far away in the code it might not even show up in the diff, leading to reviewers not noticing either. So I think eliminating the pattern is a definite improvement. Now whether the improvement is enough that we should churn the code base to fix it is another question. James