]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
qdict qlist: Make most helper macros functions
authorMarkus Armbruster <armbru@redhat.com>
Thu, 1 Feb 2018 11:18:36 +0000 (12:18 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 9 Feb 2018 12:52:15 +0000 (13:52 +0100)
The macro expansions of qdict_put_TYPE() and qlist_append_TYPE() need
qbool.h, qnull.h, qnum.h and qstring.h to compile.  We include qnull.h
and qnum.h in the headers, but not qbool.h and qstring.h.  Works,
because we include those wherever the macros get used.

Open-coding these helpers is of dubious value.  Turn them into
functions and drop the includes from the headers.

This cleanup makes the number of objects depending on qapi/qmp/qnum.h
from 4551 (out of 4743) to 46 in my "build everything" tree.  For
qapi/qmp/qnull.h, the number drops from 4552 to 21.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180201111846.21846-10-armbru@redhat.com>

27 files changed:
block/qapi.c
blockdev.c
hw/i386/acpi-build.c
hw/ppc/spapr_drc.c
include/qapi/qmp/qdict.h
include/qapi/qmp/qlist.h
migration/migration.c
monitor.c
qapi/qapi-dealloc-visitor.c
qapi/qobject-input-visitor.c
qapi/qobject-output-visitor.c
qobject/json-parser.c
qobject/qdict.c
qobject/qjson.c
qobject/qlist.c
qobject/qlit.c
qobject/qobject.c
qom/object.c
target/ppc/translate.c
tests/check-qdict.c
tests/check-qjson.c
tests/check-qobject.c
tests/test-qmp-commands.c
tests/test-qmp-event.c
tests/test-qobject-input-visitor.c
tests/test-qobject-output-visitor.c
util/qemu-option.c

index 1ab437251927220217d6040ea1b9c3b0faba2461..1e0cb2743d2770a5ee0520e1902cd61d354dfc78 100644 (file)
@@ -32,6 +32,7 @@
 #include "qapi/error.h"
 #include "qapi/qobject-output-visitor.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qstring.h"
 #include "sysemu/block-backend.h"
 #include "qemu/cutils.h"
index 8a474599379756ff57d41630ca64032f781ad553..c487cf0e4b72fa75c4bc4b97773e4de0e6e5875a 100644 (file)
@@ -40,6 +40,7 @@
 #include "qemu/error-report.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qstring.h"
 #include "qapi-visit.h"
 #include "qapi/error.h"
index ed78c4ed9f1daba51c85d61931465b0118006ebe..deb440f286347eef0f8034b431f5ef581fbec9a3 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qapi/qmp/qnum.h"
 #include "acpi-build.h"
 #include "qemu-common.h"
 #include "qemu/bitmap.h"
index e3b122968e89c99cd75557b6e45255873909ebf2..aa251133dec14647d19b40436315cdeb6e636080 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qapi/qmp/qnull.h"
 #include "cpu.h"
 #include "qemu/cutils.h"
 #include "hw/ppc/spapr_drc.h"
index d0c298114e750f5b6ccbaea1cef59bc8676dadce..3c1def00f736d5be0219b4b4d2ae86289e8d8176 100644 (file)
@@ -15,8 +15,6 @@
 
 #include "qapi/qmp/qobject.h"
 #include "qapi/qmp/qlist.h"
-#include "qapi/qmp/qnull.h"
-#include "qapi/qmp/qnum.h"
 #include "qemu/queue.h"
 
 #define QDICT_BUCKET_MAX 512
@@ -55,17 +53,11 @@ void qdict_destroy_obj(QObject *obj);
 #define qdict_put(qdict, key, obj) \
         qdict_put_obj(qdict, key, QOBJECT(obj))
 
-/* Helpers for int, bool, null, and string */
-#define qdict_put_int(qdict, key, value) \
-        qdict_put(qdict, key, qnum_from_int(value))
-#define qdict_put_bool(qdict, key, value) \
-        qdict_put(qdict, key, qbool_from_bool(value))
-#define qdict_put_str(qdict, key, value) \
-        qdict_put(qdict, key, qstring_from_str(value))
-#define qdict_put_null(qdict, key) \
-        qdict_put(qdict, key, qnull())
+void qdict_put_bool(QDict *qdict, const char *key, bool value);
+void qdict_put_int(QDict *qdict, const char *key, int64_t value);
+void qdict_put_null(QDict *qdict, const char *key);
+void qdict_put_str(QDict *qdict, const char *key, const char *value);
 
-/* High level helpers */
 double qdict_get_double(const QDict *qdict, const char *key);
 int64_t qdict_get_int(const QDict *qdict, const char *key);
 bool qdict_get_bool(const QDict *qdict, const char *key);
index 632b7ef2c153b180edbb99fc960216f5554c6905..5fd976a3981e2d2e4505cd57332f54bb673312aa 100644 (file)
@@ -14,8 +14,6 @@
 #define QLIST_H
 
 #include "qapi/qmp/qobject.h"
-#include "qapi/qmp/qnum.h"
-#include "qapi/qmp/qnull.h"
 #include "qemu/queue.h"
 
 typedef struct QListEntry {
@@ -31,15 +29,10 @@ struct QList {
 #define qlist_append(qlist, obj) \
         qlist_append_obj(qlist, QOBJECT(obj))
 
-/* Helpers for int, bool, and string */
-#define qlist_append_int(qlist, value) \
-        qlist_append(qlist, qnum_from_int(value))
-#define qlist_append_bool(qlist, value) \
-        qlist_append(qlist, qbool_from_bool(value))
-#define qlist_append_str(qlist, value) \
-        qlist_append(qlist, qstring_from_str(value))
-#define qlist_append_null(qlist) \
-        qlist_append(qlist, qnull())
+void qlist_append_bool(QList *qlist, bool value);
+void qlist_append_int(QList *qlist, int64_t value);
+void qlist_append_null(QList *qlist);
+void qlist_append_str(QList *qlist, const char *value);
 
 #define QLIST_FOREACH_ENTRY(qlist, var)             \
         for ((var) = ((qlist)->head.tqh_first);     \
index 274160e9700da78dd73ecd91e6571ec8c5008528..86d69120a62b8f584002a42933ba90f2501348ae 100644 (file)
@@ -32,6 +32,7 @@
 #include "block/block.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
+#include "qapi/qmp/qnull.h"
 #include "qemu/rcu.h"
 #include "block.h"
 #include "postcopy-ram.h"
index f38640c1e46dcd387efa54a0efbbcb23a68cd728..20f7b159b3976f2321712807d1daf6473f58b97f 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -54,6 +54,7 @@
 #include "sysemu/tpm.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/json-streamer.h"
 #include "qapi/qmp/json-parser.h"
index c7d5f80302c60118aa75a0dd926a3dce81a5afb3..fd2380316622410de9c810ad0700fd3b8acc79bb 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/dealloc-visitor.h"
+#include "qapi/qmp/qnull.h"
 #include "qemu/queue.h"
 #include "qemu-common.h"
 #include "qapi/visitor-impl.h"
index 8fb34c472e1011b960aadd434d393a536568f7bb..31183dcb6290080d8db3c7df70d2e5d24d8bb694 100644 (file)
@@ -22,6 +22,8 @@
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qerror.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
 #include "qemu/cutils.h"
 #include "qemu/option.h"
 
index 60398765df0de48f78db6e0272a3105d0ba6169c..f0cc46b3cf82dcb8bd87a52aede2c12bf1a0d875 100644 (file)
@@ -18,6 +18,8 @@
 #include "qemu/queue.h"
 #include "qemu-common.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qstring.h"
 
 typedef struct QStackEntry {
index 30dfb9dc4117268ee336e22780d85da62cf443fa..8f4badc6d9957eab2e1385799855fff23d2ba501 100644 (file)
@@ -16,6 +16,8 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qstring.h"
 #include "qapi/qmp/json-parser.h"
 #include "qapi/qmp/json-lexer.h"
index e8f15f113244293e3a37c2530883c920865e8a45..7e7ac24cf7e8eb046f1fc56efad30a4ca87900d0 100644 (file)
@@ -14,6 +14,7 @@
 #include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnull.h"
 #include "qapi/qmp/qstring.h"
 #include "qapi/qmp/qobject.h"
 #include "qapi/error.h"
@@ -143,6 +144,26 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value)
     }
 }
 
+void qdict_put_int(QDict *qdict, const char *key, int64_t value)
+{
+    qdict_put(qdict, key, qnum_from_int(value));
+}
+
+void qdict_put_bool(QDict *qdict, const char *key, bool value)
+{
+    qdict_put(qdict, key, qbool_from_bool(value));
+}
+
+void qdict_put_str(QDict *qdict, const char *key, const char *value)
+{
+    qdict_put(qdict, key, qstring_from_str(value));
+}
+
+void qdict_put_null(QDict *qdict, const char *key)
+{
+    qdict_put(qdict, key, qnull());
+}
+
 /**
  * qdict_get(): Lookup for a given 'key'
  *
index fe892132474fd902ea119146d97eed7412beeb05..7fbb68b6ba5ef029cb314440212c94ed59f79848 100644 (file)
@@ -18,6 +18,7 @@
 #include "qapi/qmp/json-streamer.h"
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnum.h"
 #include "qemu/unicode.h"
 
 typedef struct JSONParsingState
index 3ef57d31d14ff844861f1d38a046965381d02dba..268e46c8f09ff1a9bb9084baf6af15626d3ff34e 100644 (file)
  */
 
 #include "qemu/osdep.h"
+#include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qlist.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qobject.h"
+#include "qapi/qmp/qstring.h"
 #include "qemu/queue.h"
 #include "qemu-common.h"
 
@@ -64,6 +68,26 @@ void qlist_append_obj(QList *qlist, QObject *value)
     QTAILQ_INSERT_TAIL(&qlist->head, entry, next);
 }
 
+void qlist_append_int(QList *qlist, int64_t value)
+{
+    qlist_append(qlist, qnum_from_int(value));
+}
+
+void qlist_append_bool(QList *qlist, bool value)
+{
+    qlist_append(qlist, qbool_from_bool(value));
+}
+
+void qlist_append_str(QList *qlist, const char *value)
+{
+    qlist_append(qlist, qstring_from_str(value));
+}
+
+void qlist_append_null(QList *qlist)
+{
+    qlist_append(qlist, qnull());
+}
+
 /**
  * qlist_iter(): Iterate over all the list's stored values.
  *
index dbf19225c8101051276f31d792d27072c86f3663..c2d0303425d179a93385eb51849e513fb84a49c7 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "qapi/qmp/qlit.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
 
index 9b61ece06b34587ae651c9cb25883d4fc8496d94..5bbcd0481283ee530138e66d26e1df9b08186767 100644 (file)
@@ -10,6 +10,8 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
 
index c58c52d518b16da2db93feee27e1633b1fc572d1..d97f09c1fb5f2567c7659dbe726fd50b67ff8e8a 100644 (file)
@@ -27,6 +27,7 @@
 #include "qom/qom-qobject.h"
 #include "qapi/qmp/qobject.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qstring.h"
 
 #define MAX_INTERFACES 32
index 4132f67bb1f77fca43ea0b47e1b25dd17834622e..eeaad9e91f1bbccfd5c150e3302471f50612ae97 100644 (file)
@@ -24,6 +24,7 @@
 #include "disas/disas.h"
 #include "exec/exec-all.h"
 #include "tcg-op.h"
+#include "qapi/qmp/qnull.h"
 #include "qemu/host-utils.h"
 #include "exec/cpu_ldst.h"
 
index 35405778ccfac9d8cf0444bd085094bc2bdbdbad..1b1173634f3c447fe7586366f6ee3b1c3860e45b 100644 (file)
@@ -12,6 +12,7 @@
 #include "qemu/osdep.h"
 
 #include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qstring.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
index 7881009f1c516f90e1609f10d66f62ae943b20f4..26f5d4401e77b0e769572c6e2dd86d8b95ffc64c 100644 (file)
@@ -17,6 +17,8 @@
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qlit.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
 #include "qemu-common.h"
 
 static void escaped_string(void)
index 06b9c6ec34a2023c11b4da21f2f070efb44e717c..9e1e82045fe463955295d00e44bb95e353a4aa4d 100644 (file)
@@ -9,6 +9,8 @@
 #include "qemu/osdep.h"
 
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qstring.h"
 #include "qemu-common.h"
 
index 4794d1a9d8c34dbfd9a7a2628a5d73f6cadf20d4..b5a3d88775fdfcb6fecf580570468aa9f8422c2e 100644 (file)
@@ -1,6 +1,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qstring.h"
 #include "test-qmp-commands.h"
 #include "qapi/error.h"
index b197dff45352f257be8cbcd905ddefabd0f9645b..cad94778c7b56c25e47d17a140e3c0b9a04e9992 100644 (file)
@@ -18,6 +18,7 @@
 #include "test-qapi-event.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qobject.h"
 #include "qapi/qmp/qstring.h"
 #include "qapi/qmp-event.h"
index 96405991bb0c6a8eb63bb072c55088d3f22c17e3..20bf9a54140c80e5fca9c1065d6c862cb8c7ba62 100644 (file)
@@ -18,6 +18,8 @@
 #include "qapi/qobject-input-visitor.h"
 #include "test-qapi-visit.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qjson.h"
 #include "test-qmp-introspect.h"
 #include "qmp-introspect.h"
index a0b7fe6addb48d74a6356aa067e581444a3cd2c2..4a24e12121c84a55925a6f7e631650db4ed697fd 100644 (file)
@@ -17,6 +17,8 @@
 #include "qapi/qobject-output-visitor.h"
 #include "test-qapi-visit.h"
 #include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qnull.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qjson.h"
 
 typedef struct TestOutputVisitorData {
index d790c1b85a7c636e3e674d52f3132e2b40a490e6..a401e936daf65f198a74530aa2ff030559406e56 100644 (file)
@@ -30,6 +30,7 @@
 #include "qemu/error-report.h"
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qnum.h"
 #include "qapi/qmp/qstring.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/option_int.h"