From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,joe@perches.com,apw@canonical.com,
elsk@google.com,akpm@linux-foundation.org
Subject: + checkpatch-externalize-function-like-type-macros.patch added to mm-nonmm-unstable branch
Date: Wed, 02 Dec 2026 10:47:37 -0800 [thread overview]
Message-ID: <20261202184738.02CC01F000C1@smtp.kernel.org> (raw)
In-Reply-To: <20261118193921.683813-1-elsk@google.com>
The patch titled
Subject: checkpatch: externalize function-like type macros
has been added to the -mm mm-nonmm-unstable branch. Its filename is
checkpatch-externalize-function-like-type-macros.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/checkpatch-externalize-function-like-type-macros.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: HONG Yifan <elsk@google.com>
Subject: checkpatch: externalize function-like type macros
Date: Wed, 18 Nov 2026 19:39:19 +0000
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,
Following scripts/const_structs.checkpatch in commit bf1fa1dae68e
("checkpatch: externalize the structs that should be const"), read
additional function-like type macro names from a new companion file
scripts/type_macros.checkpatch into $type_macros (named to mirror
$const_structs/$conststructsfile and initialized with the built-in typeof
and __typeof__ keywords) and use $type_macros in $NonptrType and
$NonptrTypeWithAttr.
Seed scripts/type_macros.checkpatch with FIXTURE_DATA and FIXTURE_VARIANT,
and list scripts/*.checkpatch under CHECKPATCH in MAINTAINERS. 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. Keep typeof and
__typeof__ built-in as C/GCC language operators so $type_macros is never
empty and typeof() keeps working when scripts/type_macros.checkpatch is
missing or empty.
Link: https://patch.msgid.link/20261118193921.683813-1-elsk@google.com
Signed-off-by: HONG Yifan <elsk@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
MAINTAINERS | 1 +
scripts/checkpatch.pl | 9 +++++++--
scripts/type_macros.checkpatch | 6 ++++++
3 files changed, 14 insertions(+), 2 deletions(-)
--- a/MAINTAINERS~checkpatch-externalize-function-like-type-macros
+++ a/MAINTAINERS
@@ -6265,6 +6265,7 @@ CHECKPATCH
M: Andy Whitcroft <apw@canonical.com>
M: Joe Perches <joe@perches.com>
S: Maintained
+F: scripts/*.checkpatch
F: scripts/checkpatch.pl
CHECKPATCH DOCUMENTATION
--- a/scripts/checkpatch.pl~checkpatch-externalize-function-like-type-macros
+++ a/scripts/checkpatch.pl
@@ -71,6 +71,7 @@ my $codespell = 0;
my $codespellfile = "/usr/share/codespell/dictionary.txt";
my $user_codespellfile = "";
my $conststructsfile = "$D/const_structs.checkpatch";
+my $typemacrosfile = "$D/type_macros.checkpatch";
my $docsfile = "$D/../Documentation/dev-tools/checkpatch.rst";
my $typedefsfile;
my $color = "auto";
@@ -1053,6 +1054,10 @@ if (defined($typedefsfile)) {
$typeTypedefs .= '|' . $typeOtherTypedefs if (defined $typeOtherTypedefs);
}
+my $type_macros = "typeof|__typeof__";
+read_words(\$type_macros, $typemacrosfile)
+ or warn "No additional type macros will be considered - file '$typemacrosfile': $!\n";
+
sub build_types {
my $mods = "(?x: \n" . join("|\n ", (@modifierList, @modifierListFile)) . "\n)";
my $all = "(?x: \n" . join("|\n ", (@typeList, @typeListFile)) . "\n)";
@@ -1066,7 +1071,7 @@ sub build_types {
$NonptrType = qr{
(?:$Modifier\s+|const\s+)*
(?:
- (?:typeof|__typeof__)\s*\([^\)]*\)|
+ (?:$type_macros)\s*\([^\)]*\)|
(?:$typeTypedefs\b)|
(?:${all}\b)
)
@@ -1082,7 +1087,7 @@ sub build_types {
$NonptrTypeWithAttr = qr{
(?:$Modifier\s+|const\s+)*
(?:
- (?:typeof|__typeof__)\s*\([^\)]*\)|
+ (?:$type_macros)\s*\([^\)]*\)|
(?:$typeTypedefs\b)|
(?:${allWithAttr}\b)
)
diff --git a/scripts/type_macros.checkpatch a/scripts/type_macros.checkpatch
new file mode 100644
--- /dev/null
+++ a/scripts/type_macros.checkpatch
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Function-like macros that expand to type specifiers (for example,
+# struct types) and take parenthesized arguments.
+FIXTURE_DATA
+FIXTURE_VARIANT
_
Patches currently in -mm which might be from elsk@google.com are
checkpatch-externalize-function-like-type-macros.patch
prev parent reply other threads:[~2026-12-02 18:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 19:39 [PATCH v2] checkpatch: externalize function-like type macros HONG Yifan
2026-11-18 20:17 ` Joe Perches
2026-11-30 21:07 ` Hong, Yifan
2026-12-01 18:18 ` Joe Perches
2026-12-02 16:55 ` Joe Perches
2026-12-02 18:45 ` + checkpatch-externalize-function-like-type-macros.patch added to mm-nonmm-unstable branch Andrew Morton
2026-12-02 18:47 ` Andrew Morton [this message]
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=20261202184738.02CC01F000C1@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=elsk@google.com \
--cc=joe@perches.com \
--cc=mm-commits@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.