mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v5 0/5] checkpatch: userspace improvements
@ 2026-09-01 10:56 Petr Vorel
  2026-09-01 10:56 ` [PATCH v5 1/5] checkpatch: Add more userspace directories to is_userspace() Petr Vorel
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Petr Vorel @ 2026-09-01 10:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Petr Vorel, Andrew Morton, Andy Whitcroft, Joe Perches,
	Dwaipayan Ray, Lukas Bulwahn, Cryolitia PukNgae

Changes v4->v5 (all by sashiko):
* Explicitly match the directory separator in new entries for
  is_userspace()
* Allow --no-userspace to override setup in the config (using undef
  instead of 0, separate checks in is_userspace())
* 2 new commits:
  - checkpatch: Factor out the check for UAPI files
  - checkpatch: Skip kernel specific checks for userspace

Link to v4:
https://lore.kernel.org/lkml/20260810164552.1049483-1-pvorel@suse.cz/

Petr Vorel (5):
  checkpatch: Add more userspace directories to is_userspace()
  checkpatch: Ignore <inttypes.h> format macros for userspace tools
  checkpatch: Add --userspace to force userspace rules
  checkpatch: Factor out the check for UAPI files
  checkpatch: Skip kernel specific checks for userspace

 scripts/checkpatch.pl | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v5 1/5] checkpatch: Add more userspace directories to is_userspace()
  2026-09-01 10:56 [PATCH v5 0/5] checkpatch: userspace improvements Petr Vorel
@ 2026-09-01 10:56 ` Petr Vorel
  2026-09-01 10:56 ` [PATCH v5 2/5] checkpatch: Ignore <inttypes.h> format macros for userspace tools Petr Vorel
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2026-09-01 10:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Petr Vorel, Andrew Morton, Andy Whitcroft, Joe Perches,
	Dwaipayan Ray, Lukas Bulwahn, Cryolitia PukNgae

arch/ directory contains subdirectories with userspace tools (at least
arch/*/tools/ and arch/*/boot/tools/). Add check to consider any
arch/.*/tools/ subdirectory as userspace tools directory.

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>
---
Changes v4->v5 (all by sashiko):
* Explicitly match the directory separator in new entries for
  is_userspace()

 scripts/checkpatch.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f424dafce5bc..b8702f6bc9b5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2667,7 +2667,9 @@ 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/@);
 }
 
 sub process {
-- 
2.55.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v5 2/5] checkpatch: Ignore <inttypes.h> format macros for userspace tools
  2026-09-01 10:56 [PATCH v5 0/5] checkpatch: userspace improvements Petr Vorel
  2026-09-01 10:56 ` [PATCH v5 1/5] checkpatch: Add more userspace directories to is_userspace() Petr Vorel
@ 2026-09-01 10:56 ` Petr Vorel
  2026-09-01 10:56 ` [PATCH v5 3/5] checkpatch: Add --userspace to force userspace rules Petr Vorel
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2026-09-01 10:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Petr Vorel, Andrew Morton, Andy Whitcroft, Joe Perches,
	Dwaipayan Ray, Lukas Bulwahn, Cryolitia PukNgae

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>
---
The same as in v4.

 scripts/checkpatch.pl | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b8702f6bc9b5..b458c7f22684 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5950,6 +5950,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.55.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v5 3/5] checkpatch: Add --userspace to force userspace rules
  2026-09-01 10:56 [PATCH v5 0/5] checkpatch: userspace improvements Petr Vorel
  2026-09-01 10:56 ` [PATCH v5 1/5] checkpatch: Add more userspace directories to is_userspace() Petr Vorel
  2026-09-01 10:56 ` [PATCH v5 2/5] checkpatch: Ignore <inttypes.h> format macros for userspace tools Petr Vorel
@ 2026-09-01 10:56 ` Petr Vorel
  2026-09-01 10:56 ` [PATCH v5 4/5] checkpatch: Factor out the check for UAPI files Petr Vorel
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2026-09-01 10:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Petr Vorel, Andrew Morton, Andy Whitcroft, Joe Perches,
	Dwaipayan Ray, Lukas Bulwahn, Cryolitia PukNgae

Also allow to use --no-userspace for userspace projects which vendored
checkpatch.pl and use --userspace globally to be able switch it off for
files with kernel code.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v4->v5 (all by sashiko):
* Allow --no-userspace to override setup in the config (using undef
  instead of 0, separate checks in is_userspace())

 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b458c7f22684..ead35e6abba7 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;
 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
@@ -2667,6 +2670,9 @@ sub exclude_global_initialisers {
 
 sub is_userspace {
     my ($realfile) = @_;
+
+    return $userspace if (defined $userspace);
+
     return ($realfile =~ m@^tools/@ ||
 		$realfile =~ m@^scripts/@ ||
 		$realfile =~ m@^arch/.*/tools/@);
-- 
2.55.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v5 4/5] checkpatch: Factor out the check for UAPI files
  2026-09-01 10:56 [PATCH v5 0/5] checkpatch: userspace improvements Petr Vorel
                   ` (2 preceding siblings ...)
  2026-09-01 10:56 ` [PATCH v5 3/5] checkpatch: Add --userspace to force userspace rules Petr Vorel
@ 2026-09-01 10:56 ` Petr Vorel
  2026-09-02  6:09   ` Petr Vorel
  2026-09-01 10:56 ` [PATCH v5 5/5] checkpatch: Skip kernel specific checks for userspace Petr Vorel
  2026-09-01 17:44 ` [PATCH v5 0/5] checkpatch: userspace improvements Andrew Morton
  5 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2026-09-01 10:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Petr Vorel, Andrew Morton, Andy Whitcroft, Joe Perches,
	Dwaipayan Ray, Lukas Bulwahn, Cryolitia PukNgae

DRY.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
New in v5.

 scripts/checkpatch.pl | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ead35e6abba7..97bf952b0fbc 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2678,6 +2678,11 @@ sub is_userspace {
 		$realfile =~ m@^arch/.*/tools/@);
 }
 
+sub is_uapi {
+    my ($realfile) = @_;
+    return $realfile =~ m@^include/uapi/@;
+}
+
 sub process {
 	my $filename = shift;
 
@@ -4673,7 +4678,7 @@ sub process {
 				ERROR("MALFORMED_INCLUDE",
 				      "malformed #include filename\n" . $herecurr);
 			}
-			if ($path =~ "^uapi/" && $realfile =~ m@\binclude/uapi/@) {
+			if ($path =~ "^uapi/" && is_uapi($realfile)) {
 				ERROR("UAPI_INCLUDE",
 				      "No #include in ...include/uapi/... should use a uapi/ path prefix\n" . $herecurr);
 			}
@@ -6683,7 +6688,7 @@ sub process {
 		}
 
 # don't use __constant_<foo> functions outside of include/uapi/
-		if ($realfile !~ m@^include/uapi/@ &&
+		if (!is_uapi($realfile) &&
 		    $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {
 			my $constant_func = $1;
 			my $func = $constant_func;
@@ -6846,7 +6851,7 @@ sub process {
 		}
 
 # Check for __inline__ and __inline, prefer inline
-		if ($realfile !~ m@\binclude/uapi/@ &&
+		if (!is_uapi($realfile) &&
 		    $line =~ /\b(__inline__|__inline)\b/) {
 			if (WARN("INLINE",
 				 "plain inline is preferred over $1\n" . $herecurr) &&
@@ -6857,7 +6862,7 @@ sub process {
 		}
 
 # Check for compiler attributes
-		if ($realfile !~ m@\binclude/uapi/@ &&
+		if (!is_uapi($realfile) &&
 		    $rawline =~ /\b__attribute__\s*\(\s*($balanced_parens)\s*\)/) {
 			my $attr = $1;
 			$attr =~ s/\s*\(\s*(.*)\)\s*/$1/;
@@ -6931,7 +6936,7 @@ sub process {
 		}
 
 # check for c99 types like uint8_t used outside of uapi/ and tools/
-		if ($realfile !~ m@\binclude/uapi/@ &&
+		if (!is_uapi($realfile) &&
 		    $realfile !~ m@\btools/@ &&
 		    $line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) {
 			my $type = $1;
@@ -7424,7 +7429,7 @@ sub process {
 		}
 
 # check for #defines like: 1 << <digit> that could be BIT(digit), it is not exported to uapi
-		if ($realfile !~ m@^include/uapi/@ &&
+		if (!is_uapi($realfile) &&
 		    $line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) {
 			my $ull = "";
 			$ull = "_ULL" if (defined($1) && $1 =~ /ll/i);
-- 
2.55.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v5 5/5] checkpatch: Skip kernel specific checks for userspace
  2026-09-01 10:56 [PATCH v5 0/5] checkpatch: userspace improvements Petr Vorel
                   ` (3 preceding siblings ...)
  2026-09-01 10:56 ` [PATCH v5 4/5] checkpatch: Factor out the check for UAPI files Petr Vorel
@ 2026-09-01 10:56 ` Petr Vorel
  2026-09-02  6:18   ` Petr Vorel
  2026-09-01 17:44 ` [PATCH v5 0/5] checkpatch: userspace improvements Andrew Morton
  5 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2026-09-01 10:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Petr Vorel, Andrew Morton, Andy Whitcroft, Joe Perches,
	Dwaipayan Ray, Lukas Bulwahn, Cryolitia PukNgae

These check are kernel specific, do not warn about it when testing
userspace code:

* BIT_MACRO
* LONG_UDELAY
* MSLEEP
* PREFER_KERNEL_TYPES
* USLEEP_RANGE

Follow-up: 99b70ece33d8 ("checkpatch: suppress strscpy warnings for userspace tools")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
New in v5.

 scripts/checkpatch.pl | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 97bf952b0fbc..0dac0ffa009b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6701,7 +6701,7 @@ sub process {
 		}
 
 # prefer usleep_range over udelay
-		if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
+		if (!is_uapi($realfile) && $line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
 			my $delay = $1;
 			# ignore udelay's < 10, however
 			if (! ($delay < 10) ) {
@@ -6715,7 +6715,7 @@ sub process {
 		}
 
 # warn about unexpectedly long msleep's
-		if ($line =~ /\bmsleep\s*\((\d+)\);/) {
+		if (!is_uapi($realfile) && $line =~ /\bmsleep\s*\((\d+)\);/) {
 			if ($1 < 20) {
 				WARN("MSLEEP",
 				     "msleep < 20ms can sleep for up to 20ms; see function description of msleep().\n" . $herecurr);
@@ -6936,8 +6936,7 @@ sub process {
 		}
 
 # check for c99 types like uint8_t used outside of uapi/ and tools/
-		if (!is_uapi($realfile) &&
-		    $realfile !~ m@\btools/@ &&
+		if (!is_uapi($realfile) && !is_userspace($realfile) &&
 		    $line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) {
 			my $type = $1;
 			if ($type =~ /\b($typeC99Typedefs)\b/) {
@@ -7429,7 +7428,7 @@ sub process {
 		}
 
 # check for #defines like: 1 << <digit> that could be BIT(digit), it is not exported to uapi
-		if (!is_uapi($realfile) &&
+		if (!is_uapi($realfile) && !is_userspace($realfile) &&
 		    $line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) {
 			my $ull = "";
 			$ull = "_ULL" if (defined($1) && $1 =~ /ll/i);
-- 
2.55.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v5 0/5] checkpatch: userspace improvements
  2026-09-01 10:56 [PATCH v5 0/5] checkpatch: userspace improvements Petr Vorel
                   ` (4 preceding siblings ...)
  2026-09-01 10:56 ` [PATCH v5 5/5] checkpatch: Skip kernel specific checks for userspace Petr Vorel
@ 2026-09-01 17:44 ` Andrew Morton
  2026-09-02  6:04   ` Petr Vorel
  5 siblings, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2026-09-01 17:44 UTC (permalink / raw)
  To: Petr Vorel
  Cc: linux-kernel, Andy Whitcroft, Joe Perches, Dwaipayan Ray,
	Lukas Bulwahn, Cryolitia PukNgae

On Tue,  1 Sep 2026 12:56:37 +0200 Petr Vorel <pvorel@suse.cz> wrote:

> Changes v4->v5 (all by sashiko):
> * Explicitly match the directory separator in new entries for
>   is_userspace()
> * Allow --no-userspace to override setup in the config (using undef
>   instead of 0, separate checks in is_userspace())
> * 2 new commits:
>   - checkpatch: Factor out the check for UAPI files
>   - checkpatch: Skip kernel specific checks for userspace

Please prepare a proper [0/N] overview for the series.

Sashiko still has much to say:
	https://lore.kernel.org/lkml/20260810164552.1049483-1-pvorel@suse.cz/

In [4/5] changelog.  What does "DRY" mean?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v5 0/5] checkpatch: userspace improvements
  2026-09-01 17:44 ` [PATCH v5 0/5] checkpatch: userspace improvements Andrew Morton
@ 2026-09-02  6:04   ` Petr Vorel
  0 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2026-09-02  6:04 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, Andy Whitcroft, Joe Perches, Dwaipayan Ray,
	Lukas Bulwahn, Cryolitia PukNgae

Hi Andrew,

> On Tue,  1 Sep 2026 12:56:37 +0200 Petr Vorel <pvorel@suse.cz> wrote:

> > Changes v4->v5 (all by sashiko):
> > * Explicitly match the directory separator in new entries for
> >   is_userspace()
> > * Allow --no-userspace to override setup in the config (using undef
> >   instead of 0, separate checks in is_userspace())
> > * 2 new commits:
> >   - checkpatch: Factor out the check for UAPI files
> >   - checkpatch: Skip kernel specific checks for userspace

> Please prepare a proper [0/N] overview for the series.

I'm sorry, what exactly is missing or wrong? (to do it correctly in v6)

> Sashiko still has much to say:
> 	https://lore.kernel.org/lkml/20260810164552.1049483-1-pvorel@suse.cz/

This is a link to v4, but I suppose you don't refer to v4 but to v5, right?

> In [4/5] changelog.  What does "DRY" mean?

https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
Using single abbreviation was probably not a good idea.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v5 4/5] checkpatch: Factor out the check for UAPI files
  2026-09-01 10:56 ` [PATCH v5 4/5] checkpatch: Factor out the check for UAPI files Petr Vorel
@ 2026-09-02  6:09   ` Petr Vorel
  0 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2026-09-02  6:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Andy Whitcroft, Joe Perches, Dwaipayan Ray,
	Lukas Bulwahn, Cryolitia PukNgae

Hi all,

> DRY.

https://en.wikipedia.org/wiki/Don%27t_repeat_yourself

Maybe I should have written that I wanted to follow the same approach as
is_userspace().

> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> New in v5.

FYI I tend to drop commit this from v6. Function would make more sense if all
cases were just matching any uapi header via @\binclude/uapi/@.

>  scripts/checkpatch.pl | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index ead35e6abba7..97bf952b0fbc 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2678,6 +2678,11 @@ sub is_userspace {
>  		$realfile =~ m@^arch/.*/tools/@);
>  }

> +sub is_uapi {
> +    my ($realfile) = @_;
> +    return $realfile =~ m@^include/uapi/@;

As sashiko found this was wrong, it should have been using '\b' not '^'.

> +}
> +
>  sub process {
>  	my $filename = shift;

> @@ -4673,7 +4678,7 @@ sub process {
>  				ERROR("MALFORMED_INCLUDE",
>  				      "malformed #include filename\n" . $herecurr);
>  			}
> -			if ($path =~ "^uapi/" && $realfile =~ m@\binclude/uapi/@) {
> +			if ($path =~ "^uapi/" && is_uapi($realfile)) {
>  				ERROR("UAPI_INCLUDE",
>  				      "No #include in ...include/uapi/... should use a uapi/ path prefix\n" . $herecurr);
>  			}
> @@ -6683,7 +6688,7 @@ sub process {
>  		}

>  # don't use __constant_<foo> functions outside of include/uapi/
> -		if ($realfile !~ m@^include/uapi/@ &&
> +		if (!is_uapi($realfile) &&
>  		    $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {
>  			my $constant_func = $1;
>  			my $func = $constant_func;
> @@ -6846,7 +6851,7 @@ sub process {
>  		}

>  # Check for __inline__ and __inline, prefer inline
> -		if ($realfile !~ m@\binclude/uapi/@ &&
> +		if (!is_uapi($realfile) &&
>  		    $line =~ /\b(__inline__|__inline)\b/) {
>  			if (WARN("INLINE",
>  				 "plain inline is preferred over $1\n" . $herecurr) &&
> @@ -6857,7 +6862,7 @@ sub process {
>  		}

>  # Check for compiler attributes
> -		if ($realfile !~ m@\binclude/uapi/@ &&
> +		if (!is_uapi($realfile) &&
>  		    $rawline =~ /\b__attribute__\s*\(\s*($balanced_parens)\s*\)/) {
>  			my $attr = $1;
>  			$attr =~ s/\s*\(\s*(.*)\)\s*/$1/;
> @@ -6931,7 +6936,7 @@ sub process {
>  		}

>  # check for c99 types like uint8_t used outside of uapi/ and tools/
> -		if ($realfile !~ m@\binclude/uapi/@ &&
> +		if (!is_uapi($realfile) &&
>  		    $realfile !~ m@\btools/@ &&
>  		    $line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) {
>  			my $type = $1;
> @@ -7424,7 +7429,7 @@ sub process {
>  		}

>  # check for #defines like: 1 << <digit> that could be BIT(digit), it is not exported to uapi
> -		if ($realfile !~ m@^include/uapi/@ &&
> +		if (!is_uapi($realfile) &&

I overlook that regex on BIT() macro is different from the others, matching only
^include/uapi/.  It's a bit surprising for me (shouldn't be all headers checked,
also the arch specific ones and these mirrored into tools/?), but I suppose it's
just me missing something.

Kind regards,
Petr

>  		    $line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) {
>  			my $ull = "";
>  			$ull = "_ULL" if (defined($1) && $1 =~ /ll/i);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v5 5/5] checkpatch: Skip kernel specific checks for userspace
  2026-09-01 10:56 ` [PATCH v5 5/5] checkpatch: Skip kernel specific checks for userspace Petr Vorel
@ 2026-09-02  6:18   ` Petr Vorel
  0 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2026-09-02  6:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Andy Whitcroft, Joe Perches, Dwaipayan Ray,
	Lukas Bulwahn, Cryolitia PukNgae

Hi all,

[ snip ]
>  # prefer usleep_range over udelay
> -		if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
> +		if (!is_uapi($realfile) && $line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {

>  			my $delay = $1;
>  			# ignore udelay's < 10, however
>  			if (! ($delay < 10) ) {
> @@ -6715,7 +6715,7 @@ sub process {
>  		}

>  # warn about unexpectedly long msleep's
> -		if ($line =~ /\bmsleep\s*\((\d+)\);/) {
> +		if (!is_uapi($realfile) && $line =~ /\bmsleep\s*\((\d+)\);/) {

I'm sorry for silly error to use 2x wrong function name (I need to pay more
attention what autocomplete actually fills when typing just is_u<Ctrl-N>).

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-09-02  6:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-01 10:56 [PATCH v5 0/5] checkpatch: userspace improvements Petr Vorel
2026-09-01 10:56 ` [PATCH v5 1/5] checkpatch: Add more userspace directories to is_userspace() Petr Vorel
2026-09-01 10:56 ` [PATCH v5 2/5] checkpatch: Ignore <inttypes.h> format macros for userspace tools Petr Vorel
2026-09-01 10:56 ` [PATCH v5 3/5] checkpatch: Add --userspace to force userspace rules Petr Vorel
2026-09-01 10:56 ` [PATCH v5 4/5] checkpatch: Factor out the check for UAPI files Petr Vorel
2026-09-02  6:09   ` Petr Vorel
2026-09-01 10:56 ` [PATCH v5 5/5] checkpatch: Skip kernel specific checks for userspace Petr Vorel
2026-09-02  6:18   ` Petr Vorel
2026-09-01 17:44 ` [PATCH v5 0/5] checkpatch: userspace improvements Andrew Morton
2026-09-02  6:04   ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®