[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 03/10] coccinelle: Add script to remove useless Q
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v5 03/10] coccinelle: Add script to remove useless QObject casts |
Date: |
Thu, 27 Apr 2017 16:58:14 -0500 |
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 <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
---
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
- [Qemu-devel] [PATCH v5 00/10] qapi-related cleanups, Eric Blake, 2017/04/27
- [Qemu-devel] [PATCH v5 01/10] pci: Use struct instead of QDict to pass back parameters, Eric Blake, 2017/04/27
- [Qemu-devel] [PATCH v5 02/10] pci: Reduce scope of error injection, Eric Blake, 2017/04/27
- [Qemu-devel] [PATCH v5 03/10] coccinelle: Add script to remove useless QObject casts,
Eric Blake <=
- [Qemu-devel] [PATCH v5 05/10] qobject: Add helper macros for common scalar insertions, Eric Blake, 2017/04/27
- [Qemu-devel] [PATCH v5 04/10] qobject: Drop useless QObject casts, Eric Blake, 2017/04/27
- [Qemu-devel] [PATCH v5 08/10] QemuOpts: Simplify qemu_opts_to_qdict(), Eric Blake, 2017/04/27
- [Qemu-devel] [PATCH v5 07/10] block: Simplify bdrv_append_temp_snapshot() logic, Eric Blake, 2017/04/27
- [Qemu-devel] [PATCH v5 09/10] fdc-test: Avoid deprecated 'change' command, Eric Blake, 2017/04/27
- [Qemu-devel] [PATCH v5 10/10] test-qga: Actually test 0xff sync bytes, Eric Blake, 2017/04/27
- [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros, Eric Blake, 2017/04/27