Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp577228pxu; Fri, 4 Dec 2020 10:06:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyu+fsM5Zet7g0UJ1SUXh5NLs7Eus9KxjP7PwR4zNOQaWzBitFy7Ra7tX3jjX4SG5luASZn X-Received: by 2002:a50:9ea4:: with SMTP id a33mr5572793edf.70.1607105163637; Fri, 04 Dec 2020 10:06:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607105163; cv=none; d=google.com; s=arc-20160816; b=dYNn+P7KsL7FoJlwkb+qkmoG6t8i99AyZNwgXXB1fQsmXc729GxHveM5FbVfOKqg/J aD8QJUo6gVgQqdw17sIJYjfzvIgSvE2poeodGX9t5OUw0RZ3/nFUcJmrRR5lCQ20D1qe KzhYT939zXt+1QNlYuMSUomp6bwKSnarftHnTKtxrYrgY8nbElHXKfMfvezv/O/7boAH TH+TMj/CWrNTt+nONMSlyc10v7JHIdO6U76YkTm6MPDdcD3EILhoDBNsHAUe29FzZvcq FetJSbdCayTYcCSAG1wCdJWHtQlRDjrSiZaw32plaT4JXc4A+YwzE++5fc5Uclp3u/D0 E8NA== 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=w20feZuavcAuwMtgkJSiYo5yLPNcCzw1yCR9HiTRedM=; b=vWrjUhoedHaFKkp+MDIL6+8jikoc0A3scNwJpvONT3WN9Re4f/1Q/yUwWpH4kmrYTR 1i8jpiVEiRjezgzSngxt84Wi+YE8krqdGwNK9wRS/acRnDagOSd7Y5tkRG5Hp6SiLuYX 3WONXmH1uczCkgGaBTP6yGyqdtkKGf0nhCzChICnukIC4A8fpiqJGykp5aIRAqGWcgRB v/xv6FCLlbu9PT2GE/CBr0RldQe8HQamO6zn/Qlu5rQA6fftPavFvLwwoaJgK16k1v86 NRG0yZQ2IgvX1bXt+dwhrFgc2seFadxyz3m9D6SNQe6uhjs/2R++w7Vns6Wa9/NpShGG w07g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=SiyMTvRe; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=ii7hqO3w; 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 i24si1743020eja.372.2020.12.04.10.05.37; Fri, 04 Dec 2020 10:06:03 -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=SiyMTvRe; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=ii7hqO3w; 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 S1729031AbgLDSCv (ORCPT + 99 others); Fri, 4 Dec 2020 13:02:51 -0500 Received: from bedivere.hansenpartnership.com ([96.44.175.130]:58148 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727178AbgLDSCv (ORCPT ); Fri, 4 Dec 2020 13:02:51 -0500 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 30E731280B75; Fri, 4 Dec 2020 10:02:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1607104931; bh=kOups0pd4uEFpCdetzEgznZGlD3//AIfOfCED5b+e0I=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=SiyMTvReH4FFSnovORg1mgYJBXbQmz/EXo22Lk8D5z2wtCvENwSAtBEIHEiCXFl1t nljLJqzX8eXkbedHoO8YmiwVnuUQoA8j/Q/Zd/XBzlgqBx37g8ObxbAQZwhKyvm7PC +prnLWheDZKgb+CN/mZm5rHurR2QiODgOte/SiZs= 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 DX3AvhYmf693; Fri, 4 Dec 2020 10:02:11 -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 CEB241280B74; Fri, 4 Dec 2020 10:02:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1607104930; bh=kOups0pd4uEFpCdetzEgznZGlD3//AIfOfCED5b+e0I=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=ii7hqO3wVrD7YJMrWWfA626JSjOnYCNm/166zh3ZIrM1IFDN5xaeSbegcjY5SD7mu tX4mnvACJxDjafeBfIf2FcqzG+AKgxddsX4e+i1r2nXwrND5x68i65ou4gVGGQKVWK ejQ2qzALaSse6ukjejDyu3G9yo3wBVaEh7mAXvWI= Message-ID: Subject: Re: [RFC PATCH v1 07/12] efi: Replace strstarts() by str_has_prefix(). From: James Bottomley To: Ard Biesheuvel , laniel_francis@privacyrequired.com Cc: linux-efi , Linux Kernel Mailing List Date: Fri, 04 Dec 2020 10:02:09 -0800 In-Reply-To: References: <20201204170319.20383-1-laniel_francis@privacyrequired.com> <20201204170319.20383-8-laniel_francis@privacyrequired.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 Fri, 2020-12-04 at 18:07 +0100, Ard Biesheuvel wrote: > On Fri, 4 Dec 2020 at 18:06, > wrote: > > From: Francis Laniel > > > > The two functions indicates if a string begins with a given prefix. > > The only difference is that strstarts() returns a bool while > > str_has_prefix() > > returns the length of the prefix if the string begins with it or 0 > > otherwise. > > > > Why? I think I can answer that. If the conversion were done properly (which it's not) you could get rid of the double strings in the code which are error prone if you update one and forget another. This gives a good example: 3d739c1f6156 ("tracing: Use the return of str_has_prefix() to remove open coded numbers"). so in your code you'd replace things like if (strstarts(option, "rgb")) { option += strlen("rgb"); ... with len = str_has_prefix(option, "rgb"); if (len) { option += len ... Obviously you also have cases where strstart is used as a boolean with no need to know the length ... I think there's no value to converting those. James