qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, marcandre.lureau@redhat.com,
	stefanha@redhat.com,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] [PATCH v2 2/2] qobject: Update coccinelle script to catch Q{INC, DEC}REF
Date: Sat, 24 Jun 2017 12:10:08 -0600	[thread overview]
Message-ID: <20170624181008.25497-3-eblake@redhat.com> (raw)
In-Reply-To: <20170624181008.25497-1-eblake@redhat.com>

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 <eblake@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

  parent reply	other threads:[~2017-06-24 18:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-24 18:10 [Qemu-devel] [PATCH v2 0/2] qobject coccinelle followups Eric Blake
2017-06-24 18:10 ` [Qemu-devel] [PATCH v2 1/2] qobject: Catch another straggler for use of qdict_put_str() Eric Blake
2017-06-24 18:10 ` Eric Blake [this message]
2017-06-26  9:51 ` [Qemu-devel] [PATCH v2 0/2] qobject coccinelle followups Markus Armbruster
2017-06-26 15:56 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170624181008.25497-3-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).