linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Corbet <corbet@lwn.net>
To: Chuhong Yuan <hslester96@gmail.com>
Cc: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Documentation/checkpatch: Prefer str_has_prefix over strncmp
Date: Fri, 2 Aug 2019 07:38:58 -0600	[thread overview]
Message-ID: <20190802073858.19a86f82@lwn.net> (raw)
In-Reply-To: <20190802062537.11510-1-hslester96@gmail.com>

On Fri,  2 Aug 2019 14:25:37 +0800
Chuhong Yuan <hslester96@gmail.com> 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 <hslester96@gmail.com>
> ---
>  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

  reply	other threads:[~2019-08-02 13:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02  6:25 [PATCH] Documentation/checkpatch: Prefer str_has_prefix over strncmp Chuhong Yuan
2019-08-02 13:38 ` Jonathan Corbet [this message]
2019-08-02 15:21   ` Chuhong Yuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190802073858.19a86f82@lwn.net \
    --to=corbet@lwn.net \
    --cc=apw@canonical.com \
    --cc=hslester96@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).