[PATCH] checkpatch: recognize FIXTURE_DATA() and FIXTURE_VARIANT() as types

From: HONG Yifan

Date: Tue Nov 17 2026 - 17:05:33 EST


tools/testing/selftests/kselftest_harness.h defines FIXTURE_DATA() and
FIXTURE_VARIANT() to expand to struct type specifiers
("struct _test_data_##datatype_name" and
"struct _fixture_variant_##fixture_name").

Because checkpatch.pl does not recognize these function-like macros in
$NonptrType or $NonptrTypeWithAttr, annotate_values() parses them as
function calls and tags a following '*' as a binary multiplication
operator instead of a pointer declarator. This triggers false-positive
errors across kselftests whenever helper functions take pointers to
fixture data or variants (over 150 sites in tools/testing/selftests/),
for example on commit d2b82fa39fda ("selftests/mm: add a GUP selftest"):

ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#319: FILE: tools/testing/selftests/mm/gup.c:191:
+ FIXTURE_DATA(gup_test) *self,

Add FIXTURE_DATA(...) and FIXTURE_VARIANT(...) to $NonptrType and
$NonptrTypeWithAttr in build_types(), alongside typeof() and
__typeof__(). Valid pointer declarations and casts no longer emit false
SPACING errors, while malformed pointer placement (such as
"FIXTURE_DATA(foo)* p" or "(FIXTURE_DATA(foo)*)p") is flagged by
POINTER_LOCATION.

Signed-off-by: HONG Yifan <elsk@xxxxxxxxxx>
---
scripts/checkpatch.pl | 2 ++
1 file changed, 2 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b8b64f720191..f1695f20a7d2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1067,6 +1067,7 @@ sub build_types {
(?:$Modifier\s+|const\s+)*
(?:
(?:typeof|__typeof__)\s*\([^\)]*\)|
+ (?:FIXTURE_DATA|FIXTURE_VARIANT)\s*\([^\)]*\)|
(?:$typeTypedefs\b)|
(?:${all}\b)
)
@@ -1083,6 +1084,7 @@ sub build_types {
(?:$Modifier\s+|const\s+)*
(?:
(?:typeof|__typeof__)\s*\([^\)]*\)|
+ (?:FIXTURE_DATA|FIXTURE_VARIANT)\s*\([^\)]*\)|
(?:$typeTypedefs\b)|
(?:${allWithAttr}\b)
)
--
2.56.1.703.gf848ed807c-goog