[PATCH v2 1/1] checkpatch: Ignore <inttypes.h> format macros for userspace tools

From: Petr Vorel

Date: Tue May 19 2026 - 12:45:50 EST


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@xxxxxxx>
---
Changes v1->v2:
* use is_userspace() (Joe)

Link to v1:
https://lore.kernel.org/lkml/20260511121237.11030-1-pvorel@xxxxxxx/

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 939d2b9ecebd..92893152ed7e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5942,6 +5942,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]+$/) &&
#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