* [PATCH v3 0/3] checkpatch: userspace improvements
@ 2026-05-20 10:08 Petr Vorel
2026-05-20 10:08 ` [PATCH v3 1/3] checkpatch: Add more user space directories to is_userspace() Petr Vorel
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-20 10:08 UTC (permalink / raw)
To: linux-kernel
Cc: Petr Vorel, Joe Perches, Simon Glass, Dwaipayan Ray,
Lukas Bulwahn
Changes v2->v3:
* Fix unintentional disablement of CamelCase warnings on non-userspace
sources (sashiko).
* 2 new commits.
Link to v2:
https://lore.kernel.org/lkml/20260519162004.81665-1-pvorel@suse.cz/
https://sashiko.dev/#/patchset/20260519162004.81665-1-pvorel%40suse.cz
Petr Vorel (3):
checkpatch: Add more user space directories to is_userspace()
checkpatch: Ignore <inttypes.h> format macros for userspace tools
checkpatch: Add new option to force userspace
scripts/checkpatch.pl | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--
2.54.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/3] checkpatch: Add more user space directories to is_userspace()
2026-05-20 10:08 [PATCH v3 0/3] checkpatch: userspace improvements Petr Vorel
@ 2026-05-20 10:08 ` Petr Vorel
2026-05-20 15:13 ` Joe Perches
2026-05-20 10:08 ` [PATCH v3 2/3] checkpatch: Ignore <inttypes.h> format macros for userspace tools Petr Vorel
2026-05-20 10:08 ` [PATCH v3 3/3] checkpatch: Add new option to force userspace Petr Vorel
2 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2026-05-20 10:08 UTC (permalink / raw)
To: linux-kernel
Cc: Petr Vorel, Joe Perches, Simon Glass, Dwaipayan Ray,
Lukas Bulwahn
arch/*/tools/ and arch/*/boot/tools/ are directories containing user
space tools. This helps not only to strscpy checks but also to CamelCase
checks in the next commit to be more precise.
Follow-up: 99b70ece33d8 ("checkpatch: suppress strscpy warnings for userspace tools")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
New in v3.
scripts/checkpatch.pl | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 939d2b9ecebd..663064f32dae 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2669,7 +2669,10 @@ sub exclude_global_initialisers {
sub is_userspace {
my ($realfile) = @_;
- return ($realfile =~ m@^tools/@ || $realfile =~ m@^scripts/@);
+ return ($realfile =~ m@^tools/@ ||
+ $realfile =~ m@^scripts/@ ||
+ $realfile =~ m@^arch/[^/]+/tools/@ ||
+ $realfile =~ m@^arch/[^/]+/boot/tools/@);
}
sub process {
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/3] checkpatch: Ignore <inttypes.h> format macros for userspace tools
2026-05-20 10:08 [PATCH v3 0/3] checkpatch: userspace improvements Petr Vorel
2026-05-20 10:08 ` [PATCH v3 1/3] checkpatch: Add more user space directories to is_userspace() Petr Vorel
@ 2026-05-20 10:08 ` Petr Vorel
2026-05-20 10:08 ` [PATCH v3 3/3] checkpatch: Add new option to force userspace Petr Vorel
2 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-20 10:08 UTC (permalink / raw)
To: linux-kernel
Cc: Petr Vorel, Joe Perches, Simon Glass, Dwaipayan Ray,
Lukas Bulwahn
Constants from <inttypes.h> are used only in userspace tools, they are
from ISO C99, let's don't report it:
arch/mips/boot/tools/relocs.c:572: CHECK: Avoid CamelCase: <PRIx32>
arch/s390/tools/relocs.c:52: CHECK: Avoid CamelCase: <PRIu64>
tools/testing/selftests/mm/vm_util.c:244: CHECK: Avoid CamelCase: <SCNu64>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v2->v3:
* Fix unintentional disablement of CamelCase warnings on non-userspace
sources (sashiko).
Link to v2:
https://lore.kernel.org/lkml/20260519162004.81665-1-pvorel@suse.cz/
https://sashiko.dev/#/patchset/20260519162004.81665-1-pvorel%40suse.cz
scripts/checkpatch.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 663064f32dae..60da43b00d55 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5945,6 +5945,8 @@ sub process {
#Ignore SI style variants like nS, mV and dB
#(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE)
$var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ &&
+#Ignore <inttypes.h> format macros (e.g. PRIu64, SCNu64)
+ (is_userspace($realfile) ? $var !~ /^(?:PRI|SCN)[dioux][A-Z0-9]+$/ : 1) &&
#Ignore some three character SI units explicitly, like MiB and KHz
$var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
while ($var =~ m{\b($Ident)}g) {
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/3] checkpatch: Add new option to force userspace
2026-05-20 10:08 [PATCH v3 0/3] checkpatch: userspace improvements Petr Vorel
2026-05-20 10:08 ` [PATCH v3 1/3] checkpatch: Add more user space directories to is_userspace() Petr Vorel
2026-05-20 10:08 ` [PATCH v3 2/3] checkpatch: Ignore <inttypes.h> format macros for userspace tools Petr Vorel
@ 2026-05-20 10:08 ` Petr Vorel
2026-05-20 20:37 ` Petr Vorel
2 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2026-05-20 10:08 UTC (permalink / raw)
To: linux-kernel
Cc: Petr Vorel, Joe Perches, Simon Glass, Dwaipayan Ray,
Lukas Bulwahn
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
New in v3.
scripts/checkpatch.pl | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 60da43b00d55..205ce64d06bf 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -63,6 +63,7 @@ my $env_config_dir = 'CHECKPATCH_CONFIG_DIR';
my $max_line_length = 100;
my $ignore_perl_version = 0;
my $spdx_cxx_comments = 0;
+my $userspace = 0;
my $minimum_perl_version = 5.10.0;
my $min_conf_desc_length = 4;
my $spelling_file = "$D/spelling.txt";
@@ -143,6 +144,7 @@ Options:
(required by old toolchains), allow also C++
comments (//).
NOTE: it should *not* be used for Linux mainline.
+ --userspace Force rules specific for userspace.
--codespell Use the codespell dictionary for spelling/typos
(default:$codespellfile)
--codespellfile Use this codespell dictionary
@@ -358,6 +360,7 @@ GetOptions(
'codespell!' => \$codespell,
'codespellfile=s' => \$user_codespellfile,
'typedefsfile=s' => \$typedefsfile,
+ 'userspace' => \$userspace,
'color=s' => \$color,
'no-color' => \$color, #keep old behaviors of -nocolor
'nocolor' => \$color, #keep old behaviors of -nocolor
@@ -2669,7 +2672,8 @@ sub exclude_global_initialisers {
sub is_userspace {
my ($realfile) = @_;
- return ($realfile =~ m@^tools/@ ||
+ return ($userspace ||
+ $realfile =~ m@^tools/@ ||
$realfile =~ m@^scripts/@ ||
$realfile =~ m@^arch/[^/]+/tools/@ ||
$realfile =~ m@^arch/[^/]+/boot/tools/@);
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/3] checkpatch: Add more user space directories to is_userspace()
2026-05-20 10:08 ` [PATCH v3 1/3] checkpatch: Add more user space directories to is_userspace() Petr Vorel
@ 2026-05-20 15:13 ` Joe Perches
2026-05-20 20:35 ` Petr Vorel
0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2026-05-20 15:13 UTC (permalink / raw)
To: Petr Vorel, linux-kernel; +Cc: Simon Glass, Dwaipayan Ray, Lukas Bulwahn
On Wed, 2026-05-20 at 12:08 +0200, Petr Vorel wrote:
> arch/*/tools/ and arch/*/boot/tools/ are directories containing user
> space tools. This helps not only to strscpy checks but also to CamelCase
> checks in the next commit to be more precise.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2669,7 +2669,10 @@ sub exclude_global_initialisers {
>
> sub is_userspace {
> my ($realfile) = @_;
> - return ($realfile =~ m@^tools/@ || $realfile =~ m@^scripts/@);
> + return ($realfile =~ m@^tools/@ ||
> + $realfile =~ m@^scripts/@ ||
> + $realfile =~ m@^arch/[^/]+/tools/@ ||
> + $realfile =~ m@^arch/[^/]+/boot/tools/@);
Perhaps a more generic test like
m@^arch/.*\btools\b@
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/3] checkpatch: Add more user space directories to is_userspace()
2026-05-20 15:13 ` Joe Perches
@ 2026-05-20 20:35 ` Petr Vorel
0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-20 20:35 UTC (permalink / raw)
To: Joe Perches; +Cc: linux-kernel, Simon Glass, Dwaipayan Ray, Lukas Bulwahn
> On Wed, 2026-05-20 at 12:08 +0200, Petr Vorel wrote:
> > arch/*/tools/ and arch/*/boot/tools/ are directories containing user
> > space tools. This helps not only to strscpy checks but also to CamelCase
> > checks in the next commit to be more precise.
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > @@ -2669,7 +2669,10 @@ sub exclude_global_initialisers {
> > sub is_userspace {
> > my ($realfile) = @_;
> > - return ($realfile =~ m@^tools/@ || $realfile =~ m@^scripts/@);
> > + return ($realfile =~ m@^tools/@ ||
> > + $realfile =~ m@^scripts/@ ||
> > + $realfile =~ m@^arch/[^/]+/tools/@ ||
> > + $realfile =~ m@^arch/[^/]+/boot/tools/@);
> Perhaps a more generic test like
> m@^arch/.*\btools\b@
Sure, I'll add it in the next version.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 3/3] checkpatch: Add new option to force userspace
2026-05-20 10:08 ` [PATCH v3 3/3] checkpatch: Add new option to force userspace Petr Vorel
@ 2026-05-20 20:37 ` Petr Vorel
0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-20 20:37 UTC (permalink / raw)
To: linux-kernel; +Cc: Joe Perches, Simon Glass, Dwaipayan Ray, Lukas Bulwahn
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> New in v3.
> scripts/checkpatch.pl | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 60da43b00d55..205ce64d06bf 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -63,6 +63,7 @@ my $env_config_dir = 'CHECKPATCH_CONFIG_DIR';
> my $max_line_length = 100;
> my $ignore_perl_version = 0;
> my $spdx_cxx_comments = 0;
> +my $userspace = 0;
> my $minimum_perl_version = 5.10.0;
> my $min_conf_desc_length = 4;
> my $spelling_file = "$D/spelling.txt";
> @@ -143,6 +144,7 @@ Options:
> (required by old toolchains), allow also C++
> comments (//).
> NOTE: it should *not* be used for Linux mainline.
> + --userspace Force rules specific for userspace.
> --codespell Use the codespell dictionary for spelling/typos
> (default:$codespellfile)
> --codespellfile Use this codespell dictionary
> @@ -358,6 +360,7 @@ GetOptions(
> 'codespell!' => \$codespell,
> 'codespellfile=s' => \$user_codespellfile,
> 'typedefsfile=s' => \$typedefsfile,
> + 'userspace' => \$userspace,
sashiko suggest to use "!" to allow --no-userspace. I don't see a point in
having it because it's off by default, but as most of options without parameters
use it, I can add it for consistency.
Kind regards,
Petr
> 'color=s' => \$color,
> 'no-color' => \$color, #keep old behaviors of -nocolor
> 'nocolor' => \$color, #keep old behaviors of -nocolor
> @@ -2669,7 +2672,8 @@ sub exclude_global_initialisers {
> sub is_userspace {
> my ($realfile) = @_;
> - return ($realfile =~ m@^tools/@ ||
> + return ($userspace ||
> + $realfile =~ m@^tools/@ ||
> $realfile =~ m@^scripts/@ ||
> $realfile =~ m@^arch/[^/]+/tools/@ ||
> $realfile =~ m@^arch/[^/]+/boot/tools/@);
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-05-20 20:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 10:08 [PATCH v3 0/3] checkpatch: userspace improvements Petr Vorel
2026-05-20 10:08 ` [PATCH v3 1/3] checkpatch: Add more user space directories to is_userspace() Petr Vorel
2026-05-20 15:13 ` Joe Perches
2026-05-20 20:35 ` Petr Vorel
2026-05-20 10:08 ` [PATCH v3 2/3] checkpatch: Ignore <inttypes.h> format macros for userspace tools Petr Vorel
2026-05-20 10:08 ` [PATCH v3 3/3] checkpatch: Add new option to force userspace Petr Vorel
2026-05-20 20:37 ` Petr Vorel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.