Commit a2f3453e authored by Eric Blake's avatar Eric Blake Committed by Markus Armbruster
Browse files

coccinelle: Add script to remove useless QObject casts



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 fcfcd8ff, 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: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Message-Id: <20170427215821.19397-4-eblake@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent 8f16de18
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+13 −0
Original line number Diff line number Diff line
// 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);