]> Git Repo - qemu.git/commitdiff
coccinelle: Add script to remove useless QObject casts
authorEric Blake <[email protected]>
Thu, 27 Apr 2017 21:58:14 +0000 (16:58 -0500)
committerMarkus Armbruster <[email protected]>
Mon, 8 May 2017 18:32:14 +0000 (20:32 +0200)
We have macros in place to make it less verbose to add a subtype
of QObject to both QDict and QList. While we have made cleanups
like this in the past (see commit fcfcd8ffc, for example), having
it be automated by Coccinelle makes it easier to maintain.

The script is separate from the cleanups, for ease of review and
backporting.  A later patch will then add further possible cleanups.

Signed-off-by: Eric Blake <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Message-Id: <20170427215821[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
MAINTAINERS
scripts/coccinelle/qobject.cocci [new file with mode: 0644]

index efdec473196f9705e0f44edf486756c9e1d91688..66c9734311fa4585b481838a9daaace3b54be9ce 100644 (file)
@@ -1393,6 +1393,7 @@ S: Supported
 F: qobject/
 F: include/qapi/qmp/
 X: include/qapi/qmp/dispatch.h
+F: scripts/coccinelle/qobject.cocci
 F: tests/check-qdict.c
 F: tests/check-qfloat.c
 F: tests/check-qint.c
diff --git a/scripts/coccinelle/qobject.cocci b/scripts/coccinelle/qobject.cocci
new file mode 100644 (file)
index 0000000..aa899e2
--- /dev/null
@@ -0,0 +1,13 @@
+// Use QDict macros where they make sense
+@@
+expression Obj, Key, E;
+@@
+- qdict_put_obj(Obj, Key, QOBJECT(E));
++ qdict_put(Obj, Key, E);
+
+// Use QList macros where they make sense
+@@
+expression Obj, E;
+@@
+- qlist_append_obj(Obj, QOBJECT(E));
++ qlist_append(Obj, E);
This page took 0.026918 seconds and 4 git commands to generate.