All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mickaël Salaün" <mic@digikod.net>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>
Cc: "Mickaël Salaün" <mic@digikod.net>,
	"Dwaipayan Ray" <dwaipayanray1@gmail.com>,
	"Lukas Bulwahn" <lukas.bulwahn@gmail.com>,
	"Shuah Khan" <shuah@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [RFC PATCH v1] checkpatch: Handle FILE pointer type
Date: Thu,  1 Sep 2022 16:59:48 +0200	[thread overview]
Message-ID: <20220901145948.1456353-1-mic@digikod.net> (raw)

When using a "FILE *" type, checkpatch considers this an error.  Fix
this by explicitly defining "FILE" as a common type.

This is useful for user space patches.

With this patch, we now get:
 static void a(FILE *const b)

 <E> <E> <_>WS( )
 <E> <E> <_>IDENT(static)
 <E> <V> <_>WS( )
 <E> <V> <_>DECLARE(void )
 <E> <T> <_>FUNC(a)
 <E> <V> <V>PAREN('(')
 <EV> <N> <_>DECLARE(FILE *const )
 <EV> <T> <_>IDENT(b)
 <EV> <V> <_>PAREN(')') -> V
 <E> <V> <_>WS(
)
32 > . static void a(FILE *const b)
32 > EEVVVVVVVTTTTTVNTTTTTTTTTTTTVVV
32 >  ______________________________

Another error may be throw when we use FIXTURE_{DATA,VARIANT}() structs,
as defined in kselftest_harness.h .  The commented
$typeKselftestHarnessTypedefs should fix it but such definition is
considered as a function instead, because of the closing parenthesis.
I'd like some help to fix this as well.

With $typeKselftestHarnessTypedefs added to $typeTypedefs, we get:
 static void c(const FIXTURE_VARIANT(d) *const e)

 <E> <E> <_>WS( )
 <E> <E> <_>IDENT(static)
 <E> <V> <_>WS( )
 <E> <V> <_>DECLARE(void )
 <E> <T> <_>FUNC(c)
 <E> <V> <V>PAREN('(')
 <EV> <N> <_>MODIFIER(const)
 <EV> <T> <_>WS( )
 <EV> <T> <_>FUNC(FIXTURE_VARIANT)
 <EV> <V> <V>PAREN('(')
 <EVV> <N> <_>IDENT(d)
 <EVV> <V> <_>PAREN(')') -> V
 <EV> <V> <_>WS( )
 <EV> <V> <_>OPV(*)
 <EV> <N> <_>MODIFIER(const)
 <EV> <T> <_>WS( )
 <EV> <T> <_>IDENT(e)
 <EV> <V> <_>PAREN(')') -> V
 <E> <V> <_>WS(
)
30 > . static void c(const FIXTURE_VARIANT(d) *const e)
30 > EEVVVVVVVTTTTTVNTTTTTTVVVVVVVVVVVVVVVNVVVNTTTTTTVVV
30 >  ________________________________________B_________

Cc: Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Joe Perches <joe@perches.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Link: https://lore.kernel.org/r/20220901145948.1456353-1-mic@digikod.net
---
 scripts/checkpatch.pl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 79e759aac543..016b47c35742 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -576,10 +576,17 @@ our $typeKernelTypedefs = qr{(?x:
 	(?:__)?(?:u|s|be|le)(?:8|16|32|64)|
 	atomic_t
 )};
+our $typeStdioTypedefs = qr{(?x:
+	FILE
+)};
+# our $typeKselftestHarnessTypedefs = qr{(?x:
+# 	FIXTURE_(?:DATA|VARIANT)\($Ident\)
+# )};
 our $typeTypedefs = qr{(?x:
 	$typeC99Typedefs\b|
 	$typeOtherOSTypedefs\b|
-	$typeKernelTypedefs\b
+	$typeKernelTypedefs\b|
+	$typeStdioTypedefs\b
 )};
 
 our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b};

base-commit: b90cb1053190353cc30f0fef0ef1f378ccc063c5
-- 
2.37.2


             reply	other threads:[~2022-09-01 15:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-01 14:59 Mickaël Salaün [this message]
2022-09-01 15:49 ` [RFC PATCH v1] checkpatch: Handle FILE pointer type Joe Perches
2022-09-01 15:53   ` Mickaël Salaün
2022-09-01 18:22   ` Joe Perches
2022-09-02  9:04     ` Mickaël Salaün
2022-09-02 10:39       ` Joe Perches
2022-09-02 11:04         ` Mickaël Salaün

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=20220901145948.1456353-1-mic@digikod.net \
    --to=mic@digikod.net \
    --cc=apw@canonical.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=shuah@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.