From: Joe Perches <joe@perches.com>
To: Suchit Karunakaran <suchitkarunakaran@gmail.com>,
apw@canonical.com, dwaipayanray1@gmail.com,
lukas.bulwahn@gmail.com
Cc: skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: suppress strscpy warnings for userspace tools
Date: Sun, 27 Jul 2025 04:55:44 -0700 [thread overview]
Message-ID: <acacadd2c1112e31cccbe8db504ce30bd8587852.camel@perches.com> (raw)
In-Reply-To: <20250726185432.162632-1-suchitkarunakaran@gmail.com>
On Sun, 2025-07-27 at 00:24 +0530, Suchit Karunakaran wrote:
> The checkpatch.pl script currently warns against the use of strcpy,
> strlcpy, and strncpy, recommending strscpy as a safer alternative.
> However, these warnings are also triggered for code under tools/ and
> scripts/, which are userspace code where strscpy is not available.
> This patch suppresses these warnings for files in tools/ and scripts/.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -7020,19 +7020,19 @@ sub process {
> # }
>
> # strcpy uses that should likely be strscpy
> - if ($line =~ /\bstrcpy\s*\(/) {
> + if ($line =~ /\bstrcpy\s*\(/ && $realfile !~ m@\btools/@ && $realfile !~ m@\bscripts/@) {
Maybe instead create a is_kernel or is_userspace function
and use that instead of the test
if (!is_userspace($realfile) &&
$line =~ etc...
and
are all <any_subdirectory>tools/ always userspace ?
next prev parent reply other threads:[~2025-07-27 11:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-26 18:54 [PATCH] checkpatch: suppress strscpy warnings for userspace tools Suchit Karunakaran
2025-07-27 11:55 ` Joe Perches [this message]
2025-07-27 12:31 ` Suchit K
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=acacadd2c1112e31cccbe8db504ce30bd8587852.camel@perches.com \
--to=joe@perches.com \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=suchitkarunakaran@gmail.com \
/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