[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <acacadd2c1112e31cccbe8db504ce30bd8587852.camel@perches.com>
Date: Sun, 27 Jul 2025 04:55:44 -0700
From: Joe Perches <joe@...ches.com>
To: Suchit Karunakaran <suchitkarunakaran@...il.com>, apw@...onical.com,
dwaipayanray1@...il.com, lukas.bulwahn@...il.com
Cc: skhan@...uxfoundation.org, linux-kernel-mentees@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] checkpatch: suppress strscpy warnings for userspace
tools
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 ?
Powered by blists - more mailing lists