From: Eric Blake Date: Sat, 24 Jun 2017 18:10:08 +0000 (-0600) Subject: qobject: Update coccinelle script to catch Q{INC, DEC}REF X-Git-Tag: qemu-xen-4.10.0-rc1~142^2~1 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8a4613a0ab4b6e9271e64aaa88f588ed1b749eb4;p=qemu-xen.git qobject: Update coccinelle script to catch Q{INC, DEC}REF The recent commit b097efc0 used qobject_decref(QOBJECT(E)), even though we already have QDECREF(E) for that purpose. We can update our coccinelle script to catch any future relapses; with that in place, the rest of the patch is generated with: spatch --sp-file scripts/coccinelle/qobject.cocci \ --macro-file scripts/cocci-macro-file.h --dir . --in-place Signed-off-by: Eric Blake Message-Id: <20170624181008.25497-3-eblake@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Markus Armbruster --- diff --git a/monitor.c b/monitor.c index d8ac20f6ca..61b7982678 100644 --- a/monitor.c +++ b/monitor.c @@ -3842,7 +3842,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) req_json = qobject_to_json(req); trace_handle_qmp_command(mon, qstring_get_str(req_json)); - qobject_decref(QOBJECT(req_json)); + QDECREF(req_json); rsp = qmp_dispatch(cur_mon->qmp.commands, req); diff --git a/scripts/coccinelle/qobject.cocci b/scripts/coccinelle/qobject.cocci index c3253deb1b..c518caf7b1 100644 --- a/scripts/coccinelle/qobject.cocci +++ b/scripts/coccinelle/qobject.cocci @@ -3,6 +3,12 @@ expression Obj, Key, E; @@ ( +- qobject_incref(QOBJECT(E)); ++ QINCREF(E); +| +- qobject_decref(QOBJECT(E)); ++ QDECREF(E); +| - qdict_put_obj(Obj, Key, QOBJECT(E)); + qdict_put(Obj, Key, E); |