[RFC PATCH] checkpatch: add regex to match decodetree structs in typeList

matheus.ferst@eldorado.org.br posted 1 patch 1 year, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220530120750.1016067-1-matheus.ferst@eldorado.org.br
scripts/checkpatch.pl | 1 +
1 file changed, 1 insertion(+)
[RFC PATCH] checkpatch: add regex to match decodetree structs in typeList
Posted by matheus.ferst@eldorado.org.br 1 year, 11 months ago
From: Matheus Ferst <matheus.ferst@eldorado.org.br>

Decodetree generates code with structs named "arg_<identifier>" for
each argument set. When implementing methods that receive pointers to
these structs, like in [1], checkpatch will sometimes misinterpret them
as variables, resulting in errors like:

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

Add a regex in typeList to match decodetree structs so they are always
correctly identified as types.

[1] https://lists.gnu.org/archive/html/qemu-ppc/2022-05/msg00431.html

Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
This patch does get rid of the false positives related to decodetree
structs under target/ppc/translate/, but I'm no Perl programmer, so
maybe I've misunderstood the root cause of this problem. Even if it's
correct, there may be other ways to fix this, like adding a regex to
typeTypedef, but I'm not sure what would be preferable, so RFC.
---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d900d18048..2b98094c6f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -305,6 +305,7 @@ our @typeList = (
 	qr{${Ident}_handler},
 	qr{${Ident}_handler_fn},
 	qr{target_(?:u)?long},
+	qr{arg_${Ident}},
 	qr{hwaddr},
         # external libraries
 	qr{xen\w+_handle},
-- 
2.25.1