* [PATCH] checkpatch: recognize FIXTURE_DATA() and FIXTURE_VARIANT() as types
@ 2026-11-17 22:05 HONG Yifan
0 siblings, 0 replies; only message in thread
From: HONG Yifan @ 2026-11-17 22:05 UTC (permalink / raw)
To: Andy Whitcroft, Joe Perches, Andrew Morton
Cc: linux-kernel, HONG Yifan, kernel-team
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@google.com>
---
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-17 22:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 22:05 [PATCH] checkpatch: recognize FIXTURE_DATA() and FIXTURE_VARIANT() as types HONG Yifan
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®