]> git.proxmox.com Git - mirror_qemu.git/commitdiff
coccinelle: Add script to remove useless QObject casts
authorEric Blake <eblake@redhat.com>
Thu, 27 Apr 2017 21:58:14 +0000 (16:58 -0500)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 31 Jul 2017 22:06:58 +0000 (17:06 -0500)
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 <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-4-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
(cherry picked from commit a2f3453ebc64b1ebe094aeaf83f9e67896f90ac3)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
MAINTAINERS
scripts/coccinelle/qobject.cocci [new file with mode: 0644]

index c60235eaf6f592732c7567286fb14e17e7659949..430efb0ab71031f02b8c3f5fe7e54a1361216d08 100644 (file)
@@ -1395,6 +1395,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);