* [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros
@ 2026-05-11 12:12 Petr Vorel
2026-05-11 13:37 ` Simon Glass
2026-05-11 18:54 ` Joe Perches
0 siblings, 2 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-11 12:12 UTC (permalink / raw)
To: linux-kernel
Cc: Petr Vorel, Joe Perches, Simon Glass, Dwaipayan Ray,
Lukas Bulwahn, Przemek Kitszel
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>
---
scripts/checkpatch.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3727156e4ccad..4c7a952a418c0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5940,6 +5940,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)
+ $var !~ /^(?:PRI|SCN)[dioux][A-Z0-9]+$/ &&
#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.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros
2026-05-11 12:12 [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros Petr Vorel
@ 2026-05-11 13:37 ` Simon Glass
2026-05-11 20:55 ` Petr Vorel
2026-05-11 18:54 ` Joe Perches
1 sibling, 1 reply; 7+ messages in thread
From: Simon Glass @ 2026-05-11 13:37 UTC (permalink / raw)
To: Petr Vorel
Cc: linux-kernel, Joe Perches, Dwaipayan Ray, Lukas Bulwahn,
Przemek Kitszel
Hi Petr,
On Mon, 11 May 2026 at 06:12, Petr Vorel <pvorel@suse.cz> wrote:
>
> 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>
> ---
> scripts/checkpatch.pl | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 3727156e4ccad..4c7a952a418c0 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5940,6 +5940,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)
> + $var !~ /^(?:PRI|SCN)[dioux][A-Z0-9]+$/ &&
> #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.53.0
>
Reviewed-by: Simon Glass <sjg@chromium.org>
How about adding X as well, since <inttypes.h> also defines
uppercase-hex variants like PRIX8
Regards,
Simon
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros
2026-05-11 13:37 ` Simon Glass
@ 2026-05-11 20:55 ` Petr Vorel
0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-11 20:55 UTC (permalink / raw)
To: Simon Glass
Cc: linux-kernel, Joe Perches, Dwaipayan Ray, Lukas Bulwahn,
Przemek Kitszel
> Hi Petr,
> On Mon, 11 May 2026 at 06:12, Petr Vorel <pvorel@suse.cz> wrote:
> > 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>
> > ---
> > scripts/checkpatch.pl | 2 ++
> > 1 file changed, 2 insertions(+)
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 3727156e4ccad..4c7a952a418c0 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -5940,6 +5940,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)
> > + $var !~ /^(?:PRI|SCN)[dioux][A-Z0-9]+$/ &&
> > #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.53.0
> Reviewed-by: Simon Glass <sjg@chromium.org>
Thanks for your review!
> How about adding X as well, since <inttypes.h> also defines
> uppercase-hex variants like PRIX8
Yes, but that would not be cought as CamelCase (no lower case character).
Kind regards,
Petr
> Regards,
> Simon
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros
2026-05-11 12:12 [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros Petr Vorel
2026-05-11 13:37 ` Simon Glass
@ 2026-05-11 18:54 ` Joe Perches
2026-05-11 21:57 ` Petr Vorel
1 sibling, 1 reply; 7+ messages in thread
From: Joe Perches @ 2026-05-11 18:54 UTC (permalink / raw)
To: Petr Vorel, linux-kernel
Cc: Simon Glass, Dwaipayan Ray, Lukas Bulwahn, Przemek Kitszel
On Mon, 2026-05-11 at 14:12 +0200, Petr Vorel wrote:
> ```
> 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](mailto:pvorel@suse.cz)>
Nack. This is userspace only and should be tested as such.
> ---
> scripts/checkpatch.pl | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 3727156e4ccad..4c7a952a418c0 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5940,6 +5940,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)
> + $var !~ /^(?:PRI|SCN)[dioux][A-Z0-9]+$/ &&
> #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) {
>
> ```
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros
2026-05-11 18:54 ` Joe Perches
@ 2026-05-11 21:57 ` Petr Vorel
2026-05-11 23:18 ` Joe Perches
0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2026-05-11 21:57 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, Simon Glass, Dwaipayan Ray, Lukas Bulwahn,
Przemek Kitszel
> On Mon, 2026-05-11 at 14:12 +0200, Petr Vorel wrote:
> > ```
> > 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](mailto:pvorel@suse.cz)>
> Nack. This is userspace only and should be tested as such.
Thanks for info.
Yes, warning is correct for kernel space code. Do I understand correctly that
false positives are ok for user space code in the Linux kernel tree?
Or is it just because checkpatch.pl has no idea which sources are for user
space?
Kind regards,
Petr
...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros
2026-05-11 21:57 ` Petr Vorel
@ 2026-05-11 23:18 ` Joe Perches
2026-05-12 18:20 ` Petr Vorel
0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2026-05-11 23:18 UTC (permalink / raw)
To: Petr Vorel
Cc: linux-kernel, Simon Glass, Dwaipayan Ray, Lukas Bulwahn,
Przemek Kitszel
On Mon, 2026-05-11 at 23:57 +0200, Petr Vorel wrote:
> On Mon, 2026-05-11 at 14:12 +0200, Petr Vorel wrote:
> > > 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>
> > Nack. This is userspace only and should be tested as such.
>
>
> Thanks for info.
>
> Yes, warning is correct for kernel space code. Do I understand correctly that
> false positives are ok for user space code in the Linux kernel tree?
>
> Or is it just because checkpatch.pl has no idea which sources are for user
> space?
Hello Petr.
I suppose another check could be added.
There is function 'is_userspace' available.
I don't know if userspace cares at all about camelcase anyway.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros
2026-05-11 23:18 ` Joe Perches
@ 2026-05-12 18:20 ` Petr Vorel
0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-12 18:20 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, Simon Glass, Dwaipayan Ray, Lukas Bulwahn,
Przemek Kitszel
Hi Joe, all,
> On Mon, 2026-05-11 at 23:57 +0200, Petr Vorel wrote:
> > On Mon, 2026-05-11 at 14:12 +0200, Petr Vorel wrote:
> > > > 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>
> > > Nack. This is userspace only and should be tested as such.
> > Thanks for info.
> > Yes, warning is correct for kernel space code. Do I understand correctly that
> > false positives are ok for user space code in the Linux kernel tree?
> > Or is it just because checkpatch.pl has no idea which sources are for user
> > space?
> Hello Petr.
> I suppose another check could be added.
> There is function 'is_userspace' available.
Thanks for pointing out is_userspace() (quite new, from v6.18-rc1, not even in
u-boot vendored checkpatch.pl).
> I don't know if userspace cares at all about camelcase anyway.
I'd say while there are some differences in kernel and user space code,
code style should be mostly the same => userspace should care. Doc [1]
does not mention anything specific about userspace either. Therefore I'd prefer
to send v2 with this change (to v1):
- $var !~ /^(?:PRI|SCN)[dioux][A-Z0-9]+$/ &&
+ (is_userspace($realfile) && $var !~ /^(?:PRI|SCN)[dioux][A-Z0-9]+$/) &&
Other thing, because we vendored checkpatch.pl in LTP which has only userspace
code, I'll have to modify is_userspace() to return always 1. It'd be great if
you acked patch to allow always return 1 based on certain variable (e.g.
CHECKPATCH_FORCE_USERSPACE=1) or even getopt switch (e.g. --userspace). But I
understand if you don't ack it (minimise number of patches on vendored
checkpatch.pl makes updating it easier and there are other user space projects
which suggest to use checkpatch.pl e.g. btrfs-progs, but there is a boundary
what is meaningful to upstream).
Kind regards,
Petr
[1] https://www.kernel.org/doc/html/latest/process/coding-style.html#naming
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-05-12 18:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 12:12 [PATCH 1/1] checkpatch: Ignore <inttypes.h> format macros Petr Vorel
2026-05-11 13:37 ` Simon Glass
2026-05-11 20:55 ` Petr Vorel
2026-05-11 18:54 ` Joe Perches
2026-05-11 21:57 ` Petr Vorel
2026-05-11 23:18 ` Joe Perches
2026-05-12 18:20 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox