[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250726185432.162632-1-suchitkarunakaran@gmail.com>
Date: Sun, 27 Jul 2025 00:24:32 +0530
From: Suchit Karunakaran <suchitkarunakaran@...il.com>
To: apw@...onical.com,
joe@...ches.com,
dwaipayanray1@...il.com,
lukas.bulwahn@...il.com
Cc: skhan@...uxfoundation.org,
linux-kernel-mentees@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Suchit Karunakaran <suchitkarunakaran@...il.com>
Subject: [PATCH] checkpatch: suppress strscpy warnings for userspace tools
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/.
Signed-off-by: Suchit Karunakaran <suchitkarunakaran@...il.com>
---
scripts/checkpatch.pl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e722dd6fa8ef..1533cfbc8305 100755
--- 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/@) {
WARN("STRCPY",
"Prefer strscpy over strcpy - see: https://github.com/KSPP/linux/issues/88\n" . $herecurr);
}
# strlcpy uses that should likely be strscpy
- if ($line =~ /\bstrlcpy\s*\(/) {
+ if ($line =~ /\bstrlcpy\s*\(/ && $realfile !~ m@\btools/@ && $realfile !~ m@\bscripts/@) {
WARN("STRLCPY",
"Prefer strscpy over strlcpy - see: https://github.com/KSPP/linux/issues/89\n" . $herecurr);
}
# strncpy uses that should likely be strscpy or strscpy_pad
- if ($line =~ /\bstrncpy\s*\(/) {
+ if ($line =~ /\bstrncpy\s*\(/ && $realfile !~ m@\btools/@ && $realfile !~ m@\bscripts/@) {
WARN("STRNCPY",
"Prefer strscpy, strscpy_pad, or __nonstring over strncpy - see: https://github.com/KSPP/linux/issues/90\n" . $herecurr);
}
--
2.50.1
Powered by blists - more mailing lists