Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp627925ybh; Sat, 3 Aug 2019 06:31:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSiGnADMOpFSlOLP5xs1c7ssbBaJQmIcuIJW/ilkwb0rej980n3SwjWQSG5a9SmmHCVfYO X-Received: by 2002:a17:902:9a95:: with SMTP id w21mr52639414plp.126.1564839085897; Sat, 03 Aug 2019 06:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564839085; cv=none; d=google.com; s=arc-20160816; b=VbOhKqnMJ/E0SO5wj1Ps9XU9IIGvk15bEtDtVmiVAsCCIleShQBxFb6kXooP8MIOQq nKE8+lqPDBNNoRJTJnGnKGD0yFot73o6kmQO9zrpAihcqbk6Dk0UxmCg4PAhu3D73QQV j9ig75RzC690ezRS1OaGIb+vb7yhoC5frg0dA0epcI46RHrxUA4zomuhyPj0/te7ewO4 nKq00w82b25N1EmpCeH5Euggazr6jT0O0cOMAfggcxP9Vr23dt8V+yXggzkRthq8+YrR 8YZwSDVCrip344Gc0rJDLJPcuFKp4FXmjSgBNrxJ0i15i0j8rvWF29LD6x9B+hAgJGzT kKYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=KLv5BCwaAQTEzyZULPCUk3x5dpPy8Op31fcfei6pfhQ=; b=prPm0KDe2hkcM8m27mpmnJiuSzXG4Ayx9r/wxy6gwjc05Gbp18Rvbl0OTMN17zItPA FaJUS3eDnVXS7WpQ2q19w1KC9M8VPU8K6Z9PJBq2FrVb4MxZU5O+jMdByZpGROfDUQhO Oe6v6vPRK91zVkgnYcXSRp42XoJ8QRP5hkLiFt/CbCncpK46sLY3cEu2jeBuYOkurQec 4/IT6VcKL+9P12a6IcwtxN+WPURkurN1iiK+7UNYAR996Kl5k6QHWXDYZH2g5U82KXAk SjpZemp4RuyM7I5iKvozy+4ChQatYlE7DO0PQsaJlvHtapRjkoqPz1ODWIOU+kaCuKkm YBbw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si38599177pgc.75.2019.08.03.06.31.10; Sat, 03 Aug 2019 06:31:25 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391642AbfHBNi7 (ORCPT + 99 others); Fri, 2 Aug 2019 09:38:59 -0400 Received: from ms.lwn.net ([45.79.88.28]:49608 "EHLO ms.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbfHBNi7 (ORCPT ); Fri, 2 Aug 2019 09:38:59 -0400 Received: from lwn.net (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ms.lwn.net (Postfix) with ESMTPSA id 0B9BC7DA; Fri, 2 Aug 2019 13:38:59 +0000 (UTC) Date: Fri, 2 Aug 2019 07:38:58 -0600 From: Jonathan Corbet To: Chuhong Yuan Cc: Andy Whitcroft , Joe Perches , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Documentation/checkpatch: Prefer str_has_prefix over strncmp Message-ID: <20190802073858.19a86f82@lwn.net> In-Reply-To: <20190802062537.11510-1-hslester96@gmail.com> References: <20190802062537.11510-1-hslester96@gmail.com> Organization: LWN.net MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2 Aug 2019 14:25:37 +0800 Chuhong Yuan wrote: > Add strncmp() to Documentation/process/deprecated.rst since > using strncmp() to check whether a string starts with a > prefix is error-prone. > The safe replacement is str_has_prefix(). Is that the *only* use of strncmp()? > Also add check to the newly introduced deprecated_string_apis > in checkpatch.pl. > > This patch depends on patch: > "Documentation/checkpatch: Prefer stracpy/strscpy over > strcpy/strlcpy/strncpy." > > Signed-off-by: Chuhong Yuan > --- > Documentation/process/deprecated.rst | 8 ++++++++ > scripts/checkpatch.pl | 1 + > 2 files changed, 9 insertions(+) > > diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst > index 56280e108d5a..22d3f0dbcf61 100644 > --- a/Documentation/process/deprecated.rst > +++ b/Documentation/process/deprecated.rst > @@ -109,6 +109,14 @@ the given limit of bytes to copy. This is inefficient and can lead to > linear read overflows if a source string is not NUL-terminated. The > safe replacement is stracpy() or strscpy(). > > +strncmp() > +--------- > +:c:func:`strncmp` is often used to test if a string starts with a prefix Please don't use :c:func: anymore; just say strncmp() and the right things will happen. Thanks, jon