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 <ebl...@redhat.com> --- v2: fix a misuse that crept in since v1 --- monitor.c | 2 +- scripts/coccinelle/qobject.cocci | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/monitor.c b/monitor.c index 3c369f4..b0fde7f 100644 --- a/monitor.c +++ b/monitor.c @@ -3829,7 +3829,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 c3253de..c518caf 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); | -- 2.9.4