2022-09-02 11:21:01

by Mickaël Salaün

[permalink] [raw]
Subject: [PATCH v2] checkpatch: Handle FILE pointer type

When using a "FILE *" type, checkpatch considers this an error:
ERROR: need consistent spacing around '*' (ctx:WxV)
#32: FILE: f.c:8:
+static void a(FILE *const b)
^

Fix this by explicitly defining "FILE" as a common type. This is useful for
user space patches.

With this patch, we now get:
<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 > ______________________________

Cc: Andy Whitcroft <[email protected]>
Cc: Dwaipayan Ray <[email protected]>
Cc: Joe Perches <[email protected]>
Cc: Lukas Bulwahn <[email protected]>
Signed-off-by: Mickaël Salaün <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---

Changes since v1:
https://lore.kernel.org/r/[email protected]
* Remove the FIXTURE_{DATA,VARIANT}() comments.
* Improve commit description.
---
scripts/checkpatch.pl | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 79e759aac543..e2175102a354 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -576,10 +576,14 @@ our $typeKernelTypedefs = qr{(?x:
(?:__)?(?:u|s|be|le)(?:8|16|32|64)|
atomic_t
)};
+our $typeStdioTypedefs = qr{(?x:
+ FILE
+)};
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


2022-09-02 12:02:02

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH v2] checkpatch: Handle FILE pointer type

On Fri, 2022-09-02 at 13:19 +0200, Micka?l Sala?n wrote:
> When using a "FILE *" type, checkpatch considers this an error:
> ERROR: need consistent spacing around '*' (ctx:WxV)
> #32: FILE: f.c:8:
> +static void a(FILE *const b)
[]
> Signed-off-by: Micka?l Sala?n <[email protected]>

Acked-by: Joe Perches <[email protected]>

> Link: https://lore.kernel.org/r/[email protected]
> ---
> Changes since v1:
> https://lore.kernel.org/r/[email protected]
> * Remove the FIXTURE_{DATA,VARIANT}() comments.
> * Improve commit description.
> ---
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -576,10 +576,14 @@ our $typeKernelTypedefs = qr{(?x:
> (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
> atomic_t
> )};
> +our $typeStdioTypedefs = qr{(?x:
> + FILE
> +)};
> 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