Skip to content

Commit

Permalink
qobject: Update coccinelle script to catch Q{INC, DEC}REF
Browse files Browse the repository at this point in the history
The recent commit b097efc 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 <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
  • Loading branch information
ebblake authored and Markus Armbruster committed Jul 12, 2017
1 parent 187f47e commit 8a4613a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions scripts/coccinelle/qobject.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -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);
|
Expand Down

0 comments on commit 8a4613a

Please sign in to comment.