]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qlit: Change compound literals to initializers
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Fri, 25 Aug 2017 10:59:03 +0000 (12:59 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 4 Sep 2017 11:09:11 +0000 (13:09 +0200)
The QLIT_QFOO() macros expand into compound literals.  Sadly, gcc
doesn't recognizes these as constant expressions (clang does), which
makes the macros useless for initializing objects with static storage
duration.

There is a gcc bug about it:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71713

Change the macros to expand into initializers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-5-marcandre.lureau@redhat.com>
[Commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
include/qapi/qmp/qlit.h

index a4ad91321bf795327b56a680fcb652136971a177..f1d6eed317a4187c03afd2f4fd6a8b7fcdb42c57 100644 (file)
@@ -36,13 +36,13 @@ struct QLitDictEntry {
 };
 
 #define QLIT_QNUM(val) \
-    (QLitObject){.type = QTYPE_QNUM, .value.qnum = (val)}
+    { .type = QTYPE_QNUM, .value.qnum = (val) }
 #define QLIT_QSTR(val) \
-    (QLitObject){.type = QTYPE_QSTRING, .value.qstr = (val)}
+    { .type = QTYPE_QSTRING, .value.qstr = (val) }
 #define QLIT_QDICT(val) \
-    (QLitObject){.type = QTYPE_QDICT, .value.qdict = (val)}
+    { .type = QTYPE_QDICT, .value.qdict = (val) }
 #define QLIT_QLIST(val) \
-    (QLitObject){.type = QTYPE_QLIST, .value.qlist = (val)}
+    { .type = QTYPE_QLIST, .value.qlist = (val) }
 
 int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs);