Skip to contentSkip to conversation

checkpatch: add target_ulong to typelist

PATCH In review Cédric Le Goater 3 participants 3 messages Apr 1, 2016 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: add target_ulong to typelist

In some occasions, a patch [1] can start with a hunk containing a simple type cast. At the time annotate_values() is run, the type is unknown and the cast type is misinterpreted as a identifier, resulting in an error if it is followed with a negative value:

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

It seems complex to catch all possible types in a cast expression. So, as a fallback solution, let's add some common qemu types to the typeList array.

[1] http://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg06741.html

---
 scripts/checkpatch.pl |    1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
Index: qemu-dgibson-for-2.6.git/scripts/checkpatch.pl
===================================================================
@@ -212,6 +212,7 @@ our @typeList = (
 	qr{${Ident}_t},
 	qr{${Ident}_handler},
 	qr{${Ident}_handler_fn},
+	qr{target_(?:u)?long},
 );
 
 # This can be modified by sub possible.  Since it can be empty, be careful
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Fri, 1 Apr 2016 11:40:06 +0200 Cédric Le Goater <[email protected]> wrote:

In some occasions, a patch [1] can start with a hunk containing a simple type cast. At the time annotate_values() is run, the type is unknown and the cast type is misinterpreted as a identifier, resulting in an error if it is followed with a negative value:

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

Quoted 8 lines

It seems complex to catch all possible types in a cast expression. So, as a fallback solution, let's add some common qemu types to the typeList array.

[1] http://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg06741.html

---

Indeed, with this patch, the checkpatch script stops complaining when it sees:

+ if (prefix == (target_ulong) -1ULL) {

And I tend to agree with Cedric... unless Paolo has a bright idea of course. :)

Quoted 15 lines
 scripts/checkpatch.pl |    1 +
 1 file changed, 1 insertion(+)

Index: qemu-dgibson-for-2.6.git/scripts/checkpatch.pl
===================================================================

scripts/checkpatch.pl +1 -0
@@ -212,6 +212,7 @@ our @typeList = (
 	qr{${Ident}_t},
 	qr{${Ident}_handler},
 	qr{${Ident}_handler_fn},
+	qr{target_(?:u)?long},
 );
 
 # This can be modified by sub possible.  Since it can be empty, be careful