All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: [Qemu-devel] [PATCH v5 03/10] coccinelle: Add script to remove useless QObject casts
Date: Thu, 27 Apr 2017 16:58:14 -0500	[thread overview]
Message-ID: <20170427215821.19397-4-eblake@redhat.com> (raw)
In-Reply-To: <20170427215821.19397-1-eblake@redhat.com>

We have macros in place to make it less verbose to add a subtype
of QObject to both QDict and QList. While we have made cleanups
like this in the past (see commit fcfcd8ffc, for example), having
it be automated by Coccinelle makes it easier to maintain.

The script is separate from the cleanups, for ease of review and
backporting.  A later patch will then add further possible cleanups.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>

---
v5: add R-b
v4: no change
v3: new patch
---
 MAINTAINERS                      |  1 +
 scripts/coccinelle/qobject.cocci | 13 +++++++++++++
 2 files changed, 14 insertions(+)
 create mode 100644 scripts/coccinelle/qobject.cocci

diff --git a/MAINTAINERS b/MAINTAINERS
index a1d2b3a..d852efc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1393,6 +1393,7 @@ S: Supported
 F: qobject/
 F: include/qapi/qmp/
 X: include/qapi/qmp/dispatch.h
+F: scripts/coccinelle/qobject.cocci
 F: tests/check-qdict.c
 F: tests/check-qfloat.c
 F: tests/check-qint.c
diff --git a/scripts/coccinelle/qobject.cocci b/scripts/coccinelle/qobject.cocci
new file mode 100644
index 0000000..aa899e2
--- /dev/null
+++ b/scripts/coccinelle/qobject.cocci
@@ -0,0 +1,13 @@
+// Use QDict macros where they make sense
+@@
+expression Obj, Key, E;
+@@
+- qdict_put_obj(Obj, Key, QOBJECT(E));
++ qdict_put(Obj, Key, E);
+
+// Use QList macros where they make sense
+@@
+expression Obj, E;
+@@
+- qlist_append_obj(Obj, QOBJECT(E));
++ qlist_append(Obj, E);
-- 
2.9.3

  parent reply	other threads:[~2017-04-27 21:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-27 21:58 [Qemu-devel] [PATCH v5 00/10] qapi-related cleanups Eric Blake
2017-04-27 21:58 ` [Qemu-devel] [PATCH v5 01/10] pci: Use struct instead of QDict to pass back parameters Eric Blake
2017-04-27 21:58 ` [Qemu-devel] [PATCH v5 02/10] pci: Reduce scope of error injection Eric Blake
2017-04-27 21:58 ` Eric Blake [this message]
2017-04-27 21:58 ` [Qemu-devel] [PATCH v5 04/10] qobject: Drop useless QObject casts Eric Blake
2017-04-27 21:58 ` [Qemu-devel] [PATCH v5 05/10] qobject: Add helper macros for common scalar insertions Eric Blake
2017-04-27 21:58 ` [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros Eric Blake
2017-04-28  8:33   ` Markus Armbruster
2017-04-28  8:33   ` Markus Armbruster
2017-05-02 15:56     ` Stefan Hajnoczi
2017-05-02 15:56       ` Stefan Hajnoczi
2017-05-02 16:26       ` Markus Armbruster
2017-05-02 16:26       ` Markus Armbruster
     [not found]     ` <e95da4dd-ae83-ea7b-73bb-849a88e8e049@suse.com>
2017-05-02 17:30       ` [Qemu-devel] [Research] Strato HiDrive as a Dropbox Replacement? Michal Suchánek
2017-05-08 14:48     ` [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros Alberto Garcia
2017-05-08 14:48       ` Alberto Garcia
2017-05-09  7:14       ` Markus Armbruster
2017-05-09  7:14       ` Markus Armbruster
2017-04-27 21:58 ` Eric Blake
2017-04-27 21:58 ` [Qemu-devel] [PATCH v5 07/10] block: Simplify bdrv_append_temp_snapshot() logic Eric Blake
2017-04-27 21:58 ` [Qemu-devel] [PATCH v5 08/10] QemuOpts: Simplify qemu_opts_to_qdict() Eric Blake
2017-04-27 21:58 ` [Qemu-devel] [PATCH v5 09/10] fdc-test: Avoid deprecated 'change' command Eric Blake
2017-04-27 21:58 ` [Qemu-devel] [PATCH v5 10/10] test-qga: Actually test 0xff sync bytes Eric Blake
2017-05-02 16:46   ` Michael Roth
2017-05-02 16:56     ` Michael Roth
2017-05-03  8:57       ` Markus Armbruster
2017-05-03 19:52         ` Michael Roth
2017-05-04  7:23           ` Markus Armbruster
2017-05-04 13:16             ` Eric Blake

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=20170427215821.19397-4-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.