diff mbox series

[v2,1/2] checkpatch: add hwaddr to @typeList

Message ID 150539847337.21523.1659017394355445790.stgit@bahia
State New
Headers show
Series spapr_pci: make index property mandatory | expand

Commit Message

Greg Kurz Sept. 14, 2017, 2:14 p.m. UTC
The script doesn't know about all possible types and learn them as
it parses the code. If it reaches a line with a type cast but the
type isn't known yet, it is misinterpreted as an identifier.

For example the following line:

    foo = (hwaddr) -1;

results in the following false-positive to be reported:

ERROR: spaces required around that '-' (ctx:VxV)

Let's add this standard QEMU type to the list of pre-known types.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 scripts/checkpatch.pl |    1 +
 1 file changed, 1 insertion(+)

Comments

David Gibson Sept. 15, 2017, 6:36 a.m. UTC | #1
On Thu, Sep 14, 2017 at 04:14:33PM +0200, Greg Kurz wrote:
> The script doesn't know about all possible types and learn them as
> it parses the code. If it reaches a line with a type cast but the
> type isn't known yet, it is misinterpreted as an identifier.
> 
> For example the following line:
> 
>     foo = (hwaddr) -1;
> 
> results in the following false-positive to be reported:
> 
> ERROR: spaces required around that '-' (ctx:VxV)
> 
> Let's add this standard QEMU type to the list of pre-known types.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

Not sure who should queue this, though.

> ---
>  scripts/checkpatch.pl |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index fa478074b88d..def5bc1cc0e1 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -213,6 +213,7 @@ our @typeList = (
>  	qr{${Ident}_handler},
>  	qr{${Ident}_handler_fn},
>  	qr{target_(?:u)?long},
> +	qr{hwaddr},
>  );
>  
>  # This can be modified by sub possible.  Since it can be empty, be careful
>
diff mbox series

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index fa478074b88d..def5bc1cc0e1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -213,6 +213,7 @@  our @typeList = (
 	qr{${Ident}_handler},
 	qr{${Ident}_handler_fn},
 	qr{target_(?:u)?long},
+	qr{hwaddr},
 );
 
 # This can be modified by sub possible.  Since it can be empty, be careful