Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1364652pxu; Sat, 5 Dec 2020 13:21:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwY7ePvSQYcSJOOVR9ZKc9tU8Mjb7fJ3C8DI/vOIleVMhgSRwWKZvQ0grde2TN4/k7ylYDl X-Received: by 2002:a17:907:d01:: with SMTP id gn1mr13174418ejc.357.1607203283380; Sat, 05 Dec 2020 13:21:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607203283; cv=none; d=google.com; s=arc-20160816; b=wGW3xvq2SfBSRZ1WBT4SWuAeNJdI4f6ygKdgct+J2+gFkNGG/xgvaBmP+ivDj/82Pk B/eGKxMkfk57iGG+hdoBeQY210f+j1bnqtNP5zZuE3Yywr7ZRJ0TbXL6cVwZ4aHieL+s 3f+omuoZgqTqn2qbRkRV6VdFBEBTmnY9UCutIwHKk0O34nkqR2BpULBdj1FrsOZ7Nj9K 8g7ALEoc8i/PjUBJgK5RezJ8IuVr+I1KX61a7FGXgFHwS0nYLelcUxv+ApohnFo8b2gL Wn+nAWphZZwvHEiQmVahkt0sQjfTNWRW/brKd0fhXU6UdfO9GEgP63/igLQlcUNJ6awI KApw== 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=7x6+Y/oKQdg49B7wYKEg/MOgwqovFPW8Ci5qMMT2/ZY=; b=EUY7p00cssTNC1kOwEUfXEky0zSqWimNMXdS9afUGEx5OHjBWiKC5Q0PeRoaNhBxSj KQcug+qGymwA0ucb7kSe9d+Ir9NjWeU1PYBvwCwzj86qIaYjwuAN9Q/WkC37O6glOSPF cJzCt/oRfJLPlwQYOynnLkc7RW01OCqtlv3CEdGvLM7VlFg+AFQRJeYTSKgWBbs43KWY qszfF3/z438Pj5MeuI0SBFDwxifpfbrFbMvi601syLPXBJHt31ya9gncQ49cTTjfYy+8 9C45m/ysMtD2o3jz4sA8SAuYV4qz4zY0BvjCttrs7EMdCjERtYJ14l/0eUe9LGk9YGkR B9cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=hcmBlNls; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=hcmBlNls; 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 v4si6858873edj.57.2020.12.05.13.20.58; Sat, 05 Dec 2020 13:21:23 -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=hcmBlNls; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=hcmBlNls; 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 S1727436AbgLEVQc (ORCPT + 99 others); Sat, 5 Dec 2020 16:16:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725379AbgLEVQc (ORCPT ); Sat, 5 Dec 2020 16:16:32 -0500 Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [IPv6:2607:fcd0:100:8a00::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D24FEC0613CF; Sat, 5 Dec 2020 13:15:51 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 90E4A12804A3; Sat, 5 Dec 2020 13:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1607202951; bh=OckBqgE0BaUlnIbRshFb8j9AGvCdApdXfSoQejQkmtU=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=hcmBlNlsGENkWstMLc2EmWRbCXwty/p7UWTBMcfsrOin6O2EtnFm48Rtt/p0v54Nt RANgVRSMW/CGCh2CRKfVWnvN0djWXQO0mhvwERrfFcnc7krMouoMB5hVx7hcSIG48b xUYfqkZOOHauQxcew8LQZ/J/9A5EJE2BJDFGigOU= 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 IyJdAlYja8mM; Sat, 5 Dec 2020 13:15:51 -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 215D7128048D; Sat, 5 Dec 2020 13:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1607202951; bh=OckBqgE0BaUlnIbRshFb8j9AGvCdApdXfSoQejQkmtU=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=hcmBlNlsGENkWstMLc2EmWRbCXwty/p7UWTBMcfsrOin6O2EtnFm48Rtt/p0v54Nt RANgVRSMW/CGCh2CRKfVWnvN0djWXQO0mhvwERrfFcnc7krMouoMB5hVx7hcSIG48b xUYfqkZOOHauQxcew8LQZ/J/9A5EJE2BJDFGigOU= Message-ID: <043040d9c092cedcab8bf88b0ec805616d3be44d.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 13:15:50 -0800 In-Reply-To: References: <20201204170319.20383-1-laniel_francis@privacyrequired.com> <20201204170319.20383-8-laniel_francis@privacyrequired.com> <3161fc13d69c388b1f51f59c6ecea48dcd0a7856.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 [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 horse. James