qobject coccinelle followups
v2 cover qobject coccinelle followups
v1 was here:
https://lists.gnu.org/archive/html/qemu-devel/2017-06/msg02589.html
Since then:
- reorder the series
- add R-b on patch 1
- patch 2 updated to catch recent introduction of longhand usage
Eric Blake (2):
qobject: Catch another straggler for use of qdict_put_str()
qobject: Update coccinelle script to catch Q{INC,DEC}REF
monitor.c | 2 +- qemu-img.c | 2 +- scripts/coccinelle/qobject.cocci | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.9.4
PATCH v2 1/2 qobject: Catch another straggler for use of qdict_put_str()
Dan's addition of key-secret improvements in commit 29cf9336 was developed prior to the addition of QDict scalar insertion macros, but merged after the general cleanup in commit 46f5ac20. Patch created mechanically by rerunning:
spatch --sp-file scripts/coccinelle/qobject.cocci \
--macro-file scripts/cocci-macro-file.h --dir . --in-place---
v2: reorder series
--- qemu-img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-img.c +1 -1
@@ -355,7 +355,7 @@ static int img_add_key_secrets(void *opaque,QDict *options = opaque;if (g_str_has_suffix (name,"key-secret" )) { -qdict_put (options, name,qstring_from_str (value)); +qdict_put_str (options, name, value); }return 0 ;
Signature · 1 line
2.9.4
PATCH v2 2/2 qobject: Update coccinelle script to catch Q{INC, DEC}REF
In reply to Eric BlakeThe 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---
v2: fix a misuse that crept in since v1
--- monitor.c | 2 +- scripts/coccinelle/qobject.cocci | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
monitor.c +1 -1
@@ -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);
scripts/coccinelle/qobject.cocci +6 -0
@@ -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); |
Signature · 1 line
2.9.4
Markus Armbruster
AppliedQuoted 6 lines · Eric Blake
v1 was here:
https://lists.gnu.org/archive/html/qemu-devel/2017-06/msg02589.htmlSince then:
- reorder the series
- add R-b on patch 1
You missed Max's. Adding it in my tree.
Quoted 1 line
- patch 2 updated to catch recent introduction of longhand usage
Applied to qapi-next. Thanks!
Quoted 8 lines · Eric Blake
v1 was here:
https://lists.gnu.org/archive/html/qemu-devel/2017-06/msg02589.htmlSince then:
- reorder the series
- add R-b on patch 1
- patch 2 updated to catch recent introduction of longhand usage
Quoted 12 lines
Eric Blake (2):
qobject: Catch another straggler for use ofqdict_put_str()
qobject: Update coccinelle script to catch Q{INC,DEC}REFmonitor.c | 2 +- qemu-img.c | 2 +- scripts/coccinelle/qobject.cocci | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-)Signature · 1 line
2.9.4