From: HONG Yifan <elsk@google.com>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, HONG Yifan <elsk@google.com>,
kernel-team@android.com
Subject: [PATCH] checkpatch: recognize FIXTURE_DATA() and FIXTURE_VARIANT() as types
Date: Tue, 17 Nov 2026 22:05:20 +0000 [thread overview]
Message-ID: <20261117220522.904290-1-elsk@google.com> (raw)
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
reply other threads:[~2026-11-17 22:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117220522.904290-1-elsk@google.com \
--to=elsk@google.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®