From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=216.40.44.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796230526; b=lNrIz3nop+5do5ulTk6Te2nl7U2CAQHE0jBud3KxGcSCkppdzZLV4KyGe7db3L6WJg3L tunwNDI8UPxsEuGu6rwCSum/QPnvSemIgunWWBqiWEPF93NdRRzk12lSlrkV7bsR89kFj z/V9HHNwhCHoQucmGLOIIpqtLhfpC7+7A0HNev7/Wemq2u80yvTWhdErFz/MUr69KGE+y 50g/UhoajMNXOVfW9T5222SF6ARcAvrBAAzBiBSFZnB00lVWMYS+UVY+blEOdT37sNnac q/1aeKGu6iBnN0L2VWJeF0g609Osc9k+fnwcP2cGRM4Y/KB5LW8v7Gjojf0uKAby8rg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796230526; h=DMARC-Filter:Received:Received:Message-ID:Subject:From:To:Cc:Date: In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version:X-Rspamd-Queue-Id:X-Spam-Status: X-Rspamd-Server:X-Stat-Signature:X-Session-Marker:X-Session-ID: X-HE-Tag:X-HE-Meta; bh=jXVn5GN348qzpvy2IKBKOJzqXP5eGEBoL1FYkPFQrTw=; b=iGiXTvfus2BCdFK7y1w2KRmc2q29jL2Mzq7OPpwIsIaX8aechQqCfppOAXBVywfF8Ttr YmbFpBTdPvbDBiJ2mb3KU1xwu+VJfEXl0v+nYct0b0b7Ffxp8p3hUjaATGehDiv/4wy6g fU57ALpgKnN1BeFs4YHKe0GIvo8i0r2JvvYiNNxlj1A4fqbgP+4j+QUnHUvd/nrCZAEGU XAylDFq3HisWemXVmpDD5NhBdsuLpmP8mWkgI7QFpsLs9tS0vMQtR5rhbB8NzDlpe0iIh xfge4juUq/l7afQiBccAPJ4DF6Tx6nAOUyWYIt5Vf8TBAYAVK3IBi/5Nwf1zWwSvA0Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=perches.com; spf=pass smtp.mailfrom=perches.com; arc=none smtp.remote-ip=216.40.44.11 Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DD69606A32F for ; Wed, 2 Dec 2026 16:55:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9DD69606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perches.com Received: from omf04.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0EB4B1602A6; Wed, 2 Dec 2026 16:55:23 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA id D1CD220024; Wed, 2 Dec 2026 16:55:21 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2] checkpatch: externalize function-like type macros From: Joe Perches To: HONG Yifan , Andrew Morton , Andy Whitcroft Cc: kernel-team@android.com, linux-kernel@vger.kernel.org Date: Wed, 02 Dec 2026 08:55:20 -0800 In-Reply-To: <20261118193921.683813-1-elsk@google.com> References: <20261118193921.683813-1-elsk@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-3.fc44) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Rspamd-Queue-Id: D1CD220024 X-Rspamd-Server: rspamout08 X-Stat-Signature: iubm4rsh7g5zgu68atme6x4y1qdw8ef6 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18FOg8fO/TKItjyCB4PWTO8SowGMsp7HKo= X-HE-Tag: 1796230521-86647 X-HE-Meta: U2FsdGVkX1+kEfEJxqy/Vnt5LGVSwRM3KQ91v/xrkIl1zWQFwRqWFBfvqzABNyeV4AVMyEppwAEVEZQty3kSiqo945rr/hYH/L0AC8mEm0vPNuWrGyfZ+Ybt1o7A1ZoO8b+PXkMQKgyHDVgVz8sLPQAoZhMTAjiH8U9Ei5giHsikqXDHR2h7y2BZ52ZolZpmNuXk2RhwPM3WAnUmi3yOgPAAclBfHE/YyrWcg7CVGMwuWK3iMvZYFCt/t6Rzaq0JysTnDLwtuprv2SzmtKtquCc7RYz8ke1eMxGVK0egw43vhQXureW+lSAzXpFmQEf12rHUZRQBAXh5lDXqREYfv2iCIkYNWnI8DtfyCgVAjVRfZ/NH20D5o8/8lygZwKgltTSbOXofk+riaqAjiAn08A4ybMiMfbILTnk2h2MZqnEQ8sMaKSHRmtKIOlWg41hESsT8dA769nVKHDF/QoH8634a5nxx/FavgjhEohXTF10= On Wed, 2026-11-18 at 19:39 +0000, HONG Yifan wrote: > 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"). Acked-by: Joe Perches =20 > 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"): >=20 > ERROR:SPACING: need consistent spacing around '*' (ctx:WxV) > #319: FILE: tools/testing/selftests/mm/gup.c:191: > + FIXTURE_DATA(gup_test) *self, >=20 > 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. >=20 > 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. >=20 > Signed-off-by: HONG Yifan > --- > Changes in v2: > - Externalize FIXTURE_DATA and FIXTURE_VARIANT into > scripts/type_macros.checkpatch instead of hardcoding them in > scripts/checkpatch.pl, matching scripts/const_structs.checkpatch from > commit bf1fa1dae68e ("checkpatch: externalize the structs that should > be const"). > - Add scripts/*.checkpatch under CHECKPATCH in MAINTAINERS. > - Link to v1: https://lore.kernel.org/r/20261117220522.904290-1-elsk@goog= le.com >=20 > MAINTAINERS | 1 + > scripts/checkpatch.pl | 9 +++++++-- > scripts/type_macros.checkpatch | 6 ++++++ > 3 files changed, 14 insertions(+), 2 deletions(-) > create mode 100644 scripts/type_macros.checkpatch >=20 > diff --git a/MAINTAINERS b/MAINTAINERS > index d738990161bd..b0dca8edb154 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -6264,6 +6264,7 @@ CHECKPATCH > M: Andy Whitcroft > M: Joe Perches > S: Maintained > +F: scripts/*.checkpatch > F: scripts/checkpatch.pl >=20 > CHECKPATCH DOCUMENTATION > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index b8b64f720191..7500e1cf447f 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -71,6 +71,7 @@ my $codespell =3D 0; > my $codespellfile =3D "/usr/share/codespell/dictionary.txt"; > my $user_codespellfile =3D ""; > my $conststructsfile =3D "$D/const_structs.checkpatch"; > +my $typemacrosfile =3D "$D/type_macros.checkpatch"; > my $docsfile =3D "$D/../Documentation/dev-tools/checkpatch.rst"; > my $typedefsfile; > my $color =3D "auto"; > @@ -1053,6 +1054,10 @@ if (defined($typedefsfile)) { > $typeTypedefs .=3D '|' . $typeOtherTypedefs if (defined $typeOtherTyped= efs); > } >=20 > +my $type_macros =3D "typeof|__typeof__"; > +read_words(\$type_macros, $typemacrosfile) > + or warn "No additional type macros will be considered - file '$typem= acrosfile': $!\n"; > + > sub build_types { > my $mods =3D "(?x: \n" . join("|\n ", (@modifierList, @modifierListFi= le)) . "\n)"; > my $all =3D "(?x: \n" . join("|\n ", (@typeList, @typeListFile)) . "\= n)"; > @@ -1066,7 +1071,7 @@ sub build_types { > $NonptrType =3D qr{ > (?:$Modifier\s+|const\s+)* > (?: > - (?:typeof|__typeof__)\s*\([^\)]*\)| > + (?:$type_macros)\s*\([^\)]*\)| > (?:$typeTypedefs\b)| > (?:${all}\b) > ) > @@ -1082,7 +1087,7 @@ sub build_types { > $NonptrTypeWithAttr =3D qr{ > (?:$Modifier\s+|const\s+)* > (?: > - (?:typeof|__typeof__)\s*\([^\)]*\)| > + (?:$type_macros)\s*\([^\)]*\)| > (?:$typeTypedefs\b)| > (?:${allWithAttr}\b) > ) > diff --git a/scripts/type_macros.checkpatch b/scripts/type_macros.checkpa= tch > new file mode 100644 > index 000000000000..c910a09e2ebc > --- /dev/null > +++ b/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 > -- > 2.56.1.708.g77570a6a1d-goog