From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503570959241606.3362961889927; Thu, 24 Aug 2017 03:35:59 -0700 (PDT) Received: from localhost ([::1]:47634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpUT-00084Z-HX for importer@patchew.org; Thu, 24 Aug 2017 06:35:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpSb-0006rW-5L for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpSZ-00040g-3j for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33210) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpSY-00040Q-UR for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:33:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D656681DED; Thu, 24 Aug 2017 10:33:57 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA05B6A8F6; Thu, 24 Aug 2017 10:33:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D656681DED Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:37 +0200 Message-Id: <20170824103350.16400-2-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 24 Aug 2017 10:33:58 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 01/14] qdict: add qdict_put_null() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson , armbru@redhat.com, Eduardo Habkost , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A step towards completeness. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eduardo Habkost Reviewed-by: Markus Armbruster --- include/qapi/qmp/qdict.h | 4 +++- target/i386/cpu.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 363e431106..6588c7f0c8 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -53,13 +53,15 @@ void qdict_destroy_obj(QObject *obj); #define qdict_put(qdict, key, obj) \ qdict_put_obj(qdict, key, QOBJECT(obj)) =20 -/* Helpers for int, bool, and string */ +/* 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()) =20 /* High level helpers */ double qdict_get_double(const QDict *qdict, const char *key); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ddc45abd70..bec2009a9c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2454,7 +2454,7 @@ static QDict *x86_cpu_static_props(void) =20 d =3D qdict_new(); for (i =3D 0; props[i]; i++) { - qdict_put(d, props[i], qnull()); + qdict_put_null(d, props[i]); } =20 for (w =3D 0; w < FEATURE_WORDS; w++) { @@ -2464,7 +2464,7 @@ static QDict *x86_cpu_static_props(void) if (!fi->feat_names[bit]) { continue; } - qdict_put(d, fi->feat_names[bit], qnull()); + qdict_put_null(d, fi->feat_names[bit]); } } =20 --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503570966198523.9597769181283; Thu, 24 Aug 2017 03:36:06 -0700 (PDT) Received: from localhost ([::1]:47636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpUa-0008AI-SQ for importer@patchew.org; Thu, 24 Aug 2017 06:36:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpSe-0006sM-Bn for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpSd-00041y-4Y for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33424) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpSc-00041j-SB for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D82D981DE5 for ; Thu, 24 Aug 2017 10:34:01 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E49871C5A; Thu, 24 Aug 2017 10:33:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D82D981DE5 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:38 +0200 Message-Id: <20170824103350.16400-3-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 24 Aug 2017 10:34:02 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 02/14] qlit: move qlit from check-qjson to qobject/ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fix code style issues while at it, to please check-patch. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qapi/qmp/qlit.h | 49 +++++++++++++++++++++++++ qobject/qlit.c | 89 +++++++++++++++++++++++++++++++++++++++++++++ tests/check-qjson.c | 96 +--------------------------------------------= ---- qobject/Makefile.objs | 2 +- 4 files changed, 140 insertions(+), 96 deletions(-) create mode 100644 include/qapi/qmp/qlit.h create mode 100644 qobject/qlit.c diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h new file mode 100644 index 0000000000..4e2e760ef1 --- /dev/null +++ b/include/qapi/qmp/qlit.h @@ -0,0 +1,49 @@ +/* + * Copyright IBM, Corp. 2009 + * Copyright (c) 2013, 2015, 2017 Red Hat Inc. + * + * Authors: + * Anthony Liguori + * Markus Armbruster + * Marc-Andr=C3=A9 Lureau + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING.LIB file in the top-level directory. + * + */ +#ifndef QLIT_H_ +#define QLIT_H_ + +#include "qapi-types.h" +#include "qobject.h" + +typedef struct LiteralQDictEntry LiteralQDictEntry; +typedef struct LiteralQObject LiteralQObject; + +struct LiteralQObject { + int type; + union { + int64_t qnum; + const char *qstr; + LiteralQDictEntry *qdict; + LiteralQObject *qlist; + } value; +}; + +struct LiteralQDictEntry { + const char *key; + LiteralQObject value; +}; + +#define QLIT_QNUM(val) \ + (LiteralQObject){.type =3D QTYPE_QNUM, .value.qnum =3D (val)} +#define QLIT_QSTR(val) \ + (LiteralQObject){.type =3D QTYPE_QSTRING, .value.qstr =3D (val)} +#define QLIT_QDICT(val) \ + (LiteralQObject){.type =3D QTYPE_QDICT, .value.qdict =3D (val)} +#define QLIT_QLIST(val) \ + (LiteralQObject){.type =3D QTYPE_QLIST, .value.qlist =3D (val)} + +int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs); + +#endif /* QLIT_H_ */ diff --git a/qobject/qlit.c b/qobject/qlit.c new file mode 100644 index 0000000000..5917c3584e --- /dev/null +++ b/qobject/qlit.c @@ -0,0 +1,89 @@ +/* + * QLit literal qobject + * + * Copyright IBM, Corp. 2009 + * Copyright (c) 2013, 2015, 2017 Red Hat Inc. + * + * Authors: + * Anthony Liguori + * Markus Armbruster + * Marc-Andr=C3=A9 Lureau + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING.LIB file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "qapi/qmp/qlit.h" +#include "qapi/qmp/types.h" + +typedef struct QListCompareHelper { + int index; + LiteralQObject *objs; + int result; +} QListCompareHelper; + +static void compare_helper(QObject *obj, void *opaque) +{ + QListCompareHelper *helper =3D opaque; + + if (helper->result =3D=3D 0) { + return; + } + + if (helper->objs[helper->index].type =3D=3D QTYPE_NONE) { + helper->result =3D 0; + return; + } + + helper->result =3D + compare_litqobj_to_qobj(&helper->objs[helper->index++], obj); +} + +int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs) +{ + int64_t val; + + if (!rhs || lhs->type !=3D qobject_type(rhs)) { + return 0; + } + + switch (lhs->type) { + case QTYPE_QNUM: + g_assert(qnum_get_try_int(qobject_to_qnum(rhs), &val)); + return lhs->value.qnum =3D=3D val; + case QTYPE_QSTRING: + return (strcmp(lhs->value.qstr, + qstring_get_str(qobject_to_qstring(rhs))) =3D=3D 0); + case QTYPE_QDICT: { + int i; + + for (i =3D 0; lhs->value.qdict[i].key; i++) { + QObject *obj =3D qdict_get(qobject_to_qdict(rhs), + lhs->value.qdict[i].key); + + if (!compare_litqobj_to_qobj(&lhs->value.qdict[i].value, obj))= { + return 0; + } + } + + return 1; + } + case QTYPE_QLIST: { + QListCompareHelper helper; + + helper.index =3D 0; + helper.objs =3D lhs->value.qlist; + helper.result =3D 1; + + qlist_iter(qobject_to_qlist(rhs), compare_helper, &helper); + + return helper.result; + } + default: + break; + } + + return 0; +} diff --git a/tests/check-qjson.c b/tests/check-qjson.c index a3a97b0d99..525f79e60b 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -16,6 +16,7 @@ #include "qapi/error.h" #include "qapi/qmp/types.h" #include "qapi/qmp/qjson.h" +#include "qapi/qmp/qlit.h" #include "qemu-common.h" =20 static void escaped_string(void) @@ -1059,101 +1060,6 @@ static void keyword_literal(void) QDECREF(null); } =20 -typedef struct LiteralQDictEntry LiteralQDictEntry; -typedef struct LiteralQObject LiteralQObject; - -struct LiteralQObject -{ - int type; - union { - int64_t qnum; - const char *qstr; - LiteralQDictEntry *qdict; - LiteralQObject *qlist; - } value; -}; - -struct LiteralQDictEntry -{ - const char *key; - LiteralQObject value; -}; - -#define QLIT_QNUM(val) (LiteralQObject){.type =3D QTYPE_QNUM, .value.qnum = =3D (val)} -#define QLIT_QSTR(val) (LiteralQObject){.type =3D QTYPE_QSTRING, .value.qs= tr =3D (val)} -#define QLIT_QDICT(val) (LiteralQObject){.type =3D QTYPE_QDICT, .value.qdi= ct =3D (val)} -#define QLIT_QLIST(val) (LiteralQObject){.type =3D QTYPE_QLIST, .value.qli= st =3D (val)} - -typedef struct QListCompareHelper -{ - int index; - LiteralQObject *objs; - int result; -} QListCompareHelper; - -static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs); - -static void compare_helper(QObject *obj, void *opaque) -{ - QListCompareHelper *helper =3D opaque; - - if (helper->result =3D=3D 0) { - return; - } - - if (helper->objs[helper->index].type =3D=3D QTYPE_NONE) { - helper->result =3D 0; - return; - } - - helper->result =3D compare_litqobj_to_qobj(&helper->objs[helper->index= ++], obj); -} - -static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs) -{ - int64_t val; - - if (!rhs || lhs->type !=3D qobject_type(rhs)) { - return 0; - } - - switch (lhs->type) { - case QTYPE_QNUM: - g_assert(qnum_get_try_int(qobject_to_qnum(rhs), &val)); - return lhs->value.qnum =3D=3D val; - case QTYPE_QSTRING: - return (strcmp(lhs->value.qstr, qstring_get_str(qobject_to_qstring= (rhs))) =3D=3D 0); - case QTYPE_QDICT: { - int i; - - for (i =3D 0; lhs->value.qdict[i].key; i++) { - QObject *obj =3D qdict_get(qobject_to_qdict(rhs), lhs->value.q= dict[i].key); - - if (!compare_litqobj_to_qobj(&lhs->value.qdict[i].value, obj))= { - return 0; - } - } - - return 1; - } - case QTYPE_QLIST: { - QListCompareHelper helper; - - helper.index =3D 0; - helper.objs =3D lhs->value.qlist; - helper.result =3D 1; - =20 - qlist_iter(qobject_to_qlist(rhs), compare_helper, &helper); - - return helper.result; - } - default: - break; - } - - return 0; -} - static void simple_dict(void) { int i; diff --git a/qobject/Makefile.objs b/qobject/Makefile.objs index fc8885c9a4..002d25873a 100644 --- a/qobject/Makefile.objs +++ b/qobject/Makefile.objs @@ -1,2 +1,2 @@ -util-obj-y =3D qnull.o qnum.o qstring.o qdict.o qlist.o qbool.o +util-obj-y =3D qnull.o qnum.o qstring.o qdict.o qlist.o qbool.o qlit.o util-obj-y +=3D qjson.o qobject.o json-lexer.o json-streamer.o json-parser= .o --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571108825323.6544708540898; Thu, 24 Aug 2017 03:38:28 -0700 (PDT) Received: from localhost ([::1]:47648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpWt-0001jD-Jn for importer@patchew.org; Thu, 24 Aug 2017 06:38:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpSg-0006u1-Rv for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpSf-00042e-Mx for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37166) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpSf-00042P-Da for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B09FC04B924 for ; Thu, 24 Aug 2017 10:34:04 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id C58B171C5A; Thu, 24 Aug 2017 10:34:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6B09FC04B924 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:39 +0200 Message-Id: <20170824103350.16400-4-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 24 Aug 2017 10:34:04 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 03/14] qlit: use QLit prefix consistently X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rename from LiteralQ to QLit. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qapi/qmp/qlit.h | 24 ++++++++++++------------ qobject/qlit.c | 4 ++-- tests/check-qjson.c | 40 ++++++++++++++++++++-------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h index 4e2e760ef1..f36bca4554 100644 --- a/include/qapi/qmp/qlit.h +++ b/include/qapi/qmp/qlit.h @@ -17,33 +17,33 @@ #include "qapi-types.h" #include "qobject.h" =20 -typedef struct LiteralQDictEntry LiteralQDictEntry; -typedef struct LiteralQObject LiteralQObject; +typedef struct QLitDictEntry QLitDictEntry; +typedef struct QLitObject QLitObject; =20 -struct LiteralQObject { +struct QLitObject { int type; union { int64_t qnum; const char *qstr; - LiteralQDictEntry *qdict; - LiteralQObject *qlist; + QLitDictEntry *qdict; + QLitObject *qlist; } value; }; =20 -struct LiteralQDictEntry { +struct QLitDictEntry { const char *key; - LiteralQObject value; + QLitObject value; }; =20 #define QLIT_QNUM(val) \ - (LiteralQObject){.type =3D QTYPE_QNUM, .value.qnum =3D (val)} + (QLitObject){.type =3D QTYPE_QNUM, .value.qnum =3D (val)} #define QLIT_QSTR(val) \ - (LiteralQObject){.type =3D QTYPE_QSTRING, .value.qstr =3D (val)} + (QLitObject){.type =3D QTYPE_QSTRING, .value.qstr =3D (val)} #define QLIT_QDICT(val) \ - (LiteralQObject){.type =3D QTYPE_QDICT, .value.qdict =3D (val)} + (QLitObject){.type =3D QTYPE_QDICT, .value.qdict =3D (val)} #define QLIT_QLIST(val) \ - (LiteralQObject){.type =3D QTYPE_QLIST, .value.qlist =3D (val)} + (QLitObject){.type =3D QTYPE_QLIST, .value.qlist =3D (val)} =20 -int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs); +int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs); =20 #endif /* QLIT_H_ */ diff --git a/qobject/qlit.c b/qobject/qlit.c index 5917c3584e..262d64988d 100644 --- a/qobject/qlit.c +++ b/qobject/qlit.c @@ -20,7 +20,7 @@ =20 typedef struct QListCompareHelper { int index; - LiteralQObject *objs; + QLitObject *objs; int result; } QListCompareHelper; =20 @@ -41,7 +41,7 @@ static void compare_helper(QObject *obj, void *opaque) compare_litqobj_to_qobj(&helper->objs[helper->index++], obj); } =20 -int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs) +int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs) { int64_t val; =20 diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 525f79e60b..82b3681327 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1065,23 +1065,23 @@ static void simple_dict(void) int i; struct { const char *encoded; - LiteralQObject decoded; + QLitObject decoded; } test_cases[] =3D { { .encoded =3D "{\"foo\": 42, \"bar\": \"hello world\"}", - .decoded =3D QLIT_QDICT(((LiteralQDictEntry[]){ + .decoded =3D QLIT_QDICT(((QLitDictEntry[]){ { "foo", QLIT_QNUM(42) }, { "bar", QLIT_QSTR("hello world") }, { } })), }, { .encoded =3D "{}", - .decoded =3D QLIT_QDICT(((LiteralQDictEntry[]){ + .decoded =3D QLIT_QDICT(((QLitDictEntry[]){ { } })), }, { .encoded =3D "{\"foo\": 43}", - .decoded =3D QLIT_QDICT(((LiteralQDictEntry[]){ + .decoded =3D QLIT_QDICT(((QLitDictEntry[]){ { "foo", QLIT_QNUM(43) }, { } })), @@ -1163,11 +1163,11 @@ static void simple_list(void) int i; struct { const char *encoded; - LiteralQObject decoded; + QLitObject decoded; } test_cases[] =3D { { .encoded =3D "[43,42]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), QLIT_QNUM(42), { } @@ -1175,21 +1175,21 @@ static void simple_list(void) }, { .encoded =3D "[43]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), { } })), }, { .encoded =3D "[]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ { } })), }, { .encoded =3D "[{}]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ - QLIT_QDICT(((LiteralQDictEntry[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ + QLIT_QDICT(((QLitDictEntry[]){ {}, })), {}, @@ -1220,11 +1220,11 @@ static void simple_whitespace(void) int i; struct { const char *encoded; - LiteralQObject decoded; + QLitObject decoded; } test_cases[] =3D { { .encoded =3D " [ 43 , 42 ]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), QLIT_QNUM(42), { } @@ -1232,12 +1232,12 @@ static void simple_whitespace(void) }, { .encoded =3D " [ 43 , { 'h' : 'b' }, [ ], 42 ]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), - QLIT_QDICT(((LiteralQDictEntry[]){ + QLIT_QDICT(((QLitDictEntry[]){ { "h", QLIT_QSTR("b") }, { }})), - QLIT_QLIST(((LiteralQObject[]){ + QLIT_QLIST(((QLitObject[]){ { }})), QLIT_QNUM(42), { } @@ -1245,13 +1245,13 @@ static void simple_whitespace(void) }, { .encoded =3D " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]", - .decoded =3D QLIT_QLIST(((LiteralQObject[]){ + .decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(43), - QLIT_QDICT(((LiteralQDictEntry[]){ + QLIT_QDICT(((QLitDictEntry[]){ { "h", QLIT_QSTR("b") }, { "a", QLIT_QNUM(32) }, { }})), - QLIT_QLIST(((LiteralQObject[]){ + QLIT_QLIST(((QLitObject[]){ { }})), QLIT_QNUM(42), { } @@ -1282,10 +1282,10 @@ static void simple_varargs(void) { QObject *embedded_obj; QObject *obj; - LiteralQObject decoded =3D QLIT_QLIST(((LiteralQObject[]){ + QLitObject decoded =3D QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(1), QLIT_QNUM(2), - QLIT_QLIST(((LiteralQObject[]){ + QLIT_QLIST(((QLitObject[]){ QLIT_QNUM(32), QLIT_QNUM(42), {}})), --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571104468637.8066610126958; Thu, 24 Aug 2017 03:38:24 -0700 (PDT) Received: from localhost ([::1]:47647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpWp-0001fb-AK for importer@patchew.org; Thu, 24 Aug 2017 06:38:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpSl-0006xb-Sw for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpSh-000439-L4 for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpSh-00042w-El for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 76F01356CC for ; Thu, 24 Aug 2017 10:34:06 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id E52BC71C8C; Thu, 24 Aug 2017 10:34:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 76F01356CC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:40 +0200 Message-Id: <20170824103350.16400-5-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 24 Aug 2017 10:34:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 04/14] qlit: remove needless type cast X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" And misc code style fix. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qapi/qmp/qlit.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h index f36bca4554..1e9696988a 100644 --- a/include/qapi/qmp/qlit.h +++ b/include/qapi/qmp/qlit.h @@ -36,13 +36,13 @@ struct QLitDictEntry { }; =20 #define QLIT_QNUM(val) \ - (QLitObject){.type =3D QTYPE_QNUM, .value.qnum =3D (val)} + { .type =3D QTYPE_QNUM, .value.qnum =3D (val) } #define QLIT_QSTR(val) \ - (QLitObject){.type =3D QTYPE_QSTRING, .value.qstr =3D (val)} + { .type =3D QTYPE_QSTRING, .value.qstr =3D (val) } #define QLIT_QDICT(val) \ - (QLitObject){.type =3D QTYPE_QDICT, .value.qdict =3D (val)} + { .type =3D QTYPE_QDICT, .value.qdict =3D (val) } #define QLIT_QLIST(val) \ - (QLitObject){.type =3D QTYPE_QLIST, .value.qlist =3D (val)} + { .type =3D QTYPE_QLIST, .value.qlist =3D (val) } =20 int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs); =20 --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503570976108703.8006186271665; Thu, 24 Aug 2017 03:36:16 -0700 (PDT) Received: from localhost ([::1]:47638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpUk-0008Hg-VL for importer@patchew.org; Thu, 24 Aug 2017 06:36:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpSl-0006xZ-SG for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpSk-00043m-Fs for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48626) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpSk-00043T-6u for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26F39883C8 for ; Thu, 24 Aug 2017 10:34:09 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1818A6BF6C; Thu, 24 Aug 2017 10:34:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 26F39883C8 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:41 +0200 Message-Id: <20170824103350.16400-6-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 24 Aug 2017 10:34:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 05/14] qlit: rename compare_litqobj_to_qobj X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use qlit_ prefix. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qapi/qmp/qlit.h | 2 +- qobject/qlit.c | 6 +++--- tests/check-qjson.c | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h index 1e9696988a..e299e8fab0 100644 --- a/include/qapi/qmp/qlit.h +++ b/include/qapi/qmp/qlit.h @@ -44,6 +44,6 @@ struct QLitDictEntry { #define QLIT_QLIST(val) \ { .type =3D QTYPE_QLIST, .value.qlist =3D (val) } =20 -int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs); +int qlit_equal_qobject(QLitObject *lhs, QObject *rhs); =20 #endif /* QLIT_H_ */ diff --git a/qobject/qlit.c b/qobject/qlit.c index 262d64988d..0c4101898d 100644 --- a/qobject/qlit.c +++ b/qobject/qlit.c @@ -38,10 +38,10 @@ static void compare_helper(QObject *obj, void *opaque) } =20 helper->result =3D - compare_litqobj_to_qobj(&helper->objs[helper->index++], obj); + qlit_equal_qobject(&helper->objs[helper->index++], obj); } =20 -int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs) +int qlit_equal_qobject(QLitObject *lhs, QObject *rhs) { int64_t val; =20 @@ -63,7 +63,7 @@ int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs) QObject *obj =3D qdict_get(qobject_to_qdict(rhs), lhs->value.qdict[i].key); =20 - if (!compare_litqobj_to_qobj(&lhs->value.qdict[i].value, obj))= { + if (!qlit_equal_qobject(&lhs->value.qdict[i].value, obj)) { return 0; } } diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 82b3681327..e5ca273cbc 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1094,13 +1094,13 @@ static void simple_dict(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded, &error_abort); - g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) =3D= =3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); =20 str =3D qobject_to_json(obj); qobject_decref(obj); =20 obj =3D qobject_from_json(qstring_get_str(str), &error_abort); - g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) =3D= =3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); qobject_decref(obj); QDECREF(str); } @@ -1203,13 +1203,13 @@ static void simple_list(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded, &error_abort); - g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) =3D= =3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); =20 str =3D qobject_to_json(obj); qobject_decref(obj); =20 obj =3D qobject_from_json(qstring_get_str(str), &error_abort); - g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) =3D= =3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); qobject_decref(obj); QDECREF(str); } @@ -1265,13 +1265,13 @@ static void simple_whitespace(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded, &error_abort); - g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) =3D= =3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); =20 str =3D qobject_to_json(obj); qobject_decref(obj); =20 obj =3D qobject_from_json(qstring_get_str(str), &error_abort); - g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) =3D= =3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); =20 qobject_decref(obj); QDECREF(str); @@ -1295,7 +1295,7 @@ static void simple_varargs(void) g_assert(embedded_obj !=3D NULL); =20 obj =3D qobject_from_jsonf("[%d, 2, %p]", 1, embedded_obj); - g_assert(compare_litqobj_to_qobj(&decoded, obj) =3D=3D 1); + g_assert(qlit_equal_qobject(&decoded, obj) =3D=3D 1); =20 qobject_decref(obj); } --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150357122887311.390519187589007; Thu, 24 Aug 2017 03:40:28 -0700 (PDT) Received: from localhost ([::1]:47656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpYp-0003Rb-M4 for importer@patchew.org; Thu, 24 Aug 2017 06:40:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpSo-0006zT-4E for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpSn-00044n-5D for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48714) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpSm-00044W-S6 for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6E7E85541 for ; Thu, 24 Aug 2017 10:34:11 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3486A71C96; Thu, 24 Aug 2017 10:34:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D6E7E85541 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:42 +0200 Message-Id: <20170824103350.16400-7-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 24 Aug 2017 10:34:12 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 06/14] qlit: make qlit_equal_qobject return a bool X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make it more obvious about the expected return values. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qapi/qmp/qlit.h | 2 +- qobject/qlit.c | 18 +++++++++--------- tests/check-qjson.c | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h index e299e8fab0..2e22d0f73c 100644 --- a/include/qapi/qmp/qlit.h +++ b/include/qapi/qmp/qlit.h @@ -44,6 +44,6 @@ struct QLitDictEntry { #define QLIT_QLIST(val) \ { .type =3D QTYPE_QLIST, .value.qlist =3D (val) } =20 -int qlit_equal_qobject(QLitObject *lhs, QObject *rhs); +bool qlit_equal_qobject(QLitObject *lhs, QObject *rhs); =20 #endif /* QLIT_H_ */ diff --git a/qobject/qlit.c b/qobject/qlit.c index 0c4101898d..a2975bef3f 100644 --- a/qobject/qlit.c +++ b/qobject/qlit.c @@ -21,19 +21,19 @@ typedef struct QListCompareHelper { int index; QLitObject *objs; - int result; + bool result; } QListCompareHelper; =20 static void compare_helper(QObject *obj, void *opaque) { QListCompareHelper *helper =3D opaque; =20 - if (helper->result =3D=3D 0) { + if (!helper->result) { return; } =20 if (helper->objs[helper->index].type =3D=3D QTYPE_NONE) { - helper->result =3D 0; + helper->result =3D false; return; } =20 @@ -41,12 +41,12 @@ static void compare_helper(QObject *obj, void *opaque) qlit_equal_qobject(&helper->objs[helper->index++], obj); } =20 -int qlit_equal_qobject(QLitObject *lhs, QObject *rhs) +bool qlit_equal_qobject(QLitObject *lhs, QObject *rhs) { int64_t val; =20 if (!rhs || lhs->type !=3D qobject_type(rhs)) { - return 0; + return false; } =20 switch (lhs->type) { @@ -64,18 +64,18 @@ int qlit_equal_qobject(QLitObject *lhs, QObject *rhs) lhs->value.qdict[i].key); =20 if (!qlit_equal_qobject(&lhs->value.qdict[i].value, obj)) { - return 0; + return false; } } =20 - return 1; + return true; } case QTYPE_QLIST: { QListCompareHelper helper; =20 helper.index =3D 0; helper.objs =3D lhs->value.qlist; - helper.result =3D 1; + helper.result =3D true; =20 qlist_iter(qobject_to_qlist(rhs), compare_helper, &helper); =20 @@ -85,5 +85,5 @@ int qlit_equal_qobject(QLitObject *lhs, QObject *rhs) break; } =20 - return 0; + return false; } diff --git a/tests/check-qjson.c b/tests/check-qjson.c index e5ca273cbc..59227934ce 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1094,13 +1094,13 @@ static void simple_dict(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded, &error_abort); - g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj)); =20 str =3D qobject_to_json(obj); qobject_decref(obj); =20 obj =3D qobject_from_json(qstring_get_str(str), &error_abort); - g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj)); qobject_decref(obj); QDECREF(str); } @@ -1203,13 +1203,13 @@ static void simple_list(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded, &error_abort); - g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj)); =20 str =3D qobject_to_json(obj); qobject_decref(obj); =20 obj =3D qobject_from_json(qstring_get_str(str), &error_abort); - g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj)); qobject_decref(obj); QDECREF(str); } @@ -1265,13 +1265,13 @@ static void simple_whitespace(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded, &error_abort); - g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj)); =20 str =3D qobject_to_json(obj); qobject_decref(obj); =20 obj =3D qobject_from_json(qstring_get_str(str), &error_abort); - g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) =3D=3D 1); + g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj)); =20 qobject_decref(obj); QDECREF(str); @@ -1295,7 +1295,7 @@ static void simple_varargs(void) g_assert(embedded_obj !=3D NULL); =20 obj =3D qobject_from_jsonf("[%d, 2, %p]", 1, embedded_obj); - g_assert(qlit_equal_qobject(&decoded, obj) =3D=3D 1); + g_assert(qlit_equal_qobject(&decoded, obj)); =20 qobject_decref(obj); } --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571102934441.20435274894385; Thu, 24 Aug 2017 03:38:22 -0700 (PDT) Received: from localhost ([::1]:47646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpWn-0001eM-Oq for importer@patchew.org; Thu, 24 Aug 2017 06:38:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpSw-00074v-Ro for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpSr-00045m-WE for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpSr-00045c-PD for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B836037EEE for ; Thu, 24 Aug 2017 10:34:16 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id C39AE7F564; Thu, 24 Aug 2017 10:34:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B836037EEE Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:43 +0200 Message-Id: <20170824103350.16400-8-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 24 Aug 2017 10:34:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 07/14] qlit: make qlit_equal_qobject() take const arguments X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qapi/qmp/qlit.h | 2 +- qobject/qlit.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h index 2e22d0f73c..8882016199 100644 --- a/include/qapi/qmp/qlit.h +++ b/include/qapi/qmp/qlit.h @@ -44,6 +44,6 @@ struct QLitDictEntry { #define QLIT_QLIST(val) \ { .type =3D QTYPE_QLIST, .value.qlist =3D (val) } =20 -bool qlit_equal_qobject(QLitObject *lhs, QObject *rhs); +bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs); =20 #endif /* QLIT_H_ */ diff --git a/qobject/qlit.c b/qobject/qlit.c index a2975bef3f..ae2787ef35 100644 --- a/qobject/qlit.c +++ b/qobject/qlit.c @@ -41,7 +41,7 @@ static void compare_helper(QObject *obj, void *opaque) qlit_equal_qobject(&helper->objs[helper->index++], obj); } =20 -bool qlit_equal_qobject(QLitObject *lhs, QObject *rhs) +bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs) { int64_t val; =20 --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571226039513.5710040242466; Thu, 24 Aug 2017 03:40:26 -0700 (PDT) Received: from localhost ([::1]:47655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpYm-0003QH-St for importer@patchew.org; Thu, 24 Aug 2017 06:40:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpSx-00075W-Ha for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpSw-00046W-BJ for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46822) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpSw-00046M-59 for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 294DB4ACA5 for ; Thu, 24 Aug 2017 10:34:21 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8141477D6F; Thu, 24 Aug 2017 10:34:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 294DB4ACA5 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:44 +0200 Message-Id: <20170824103350.16400-9-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 24 Aug 2017 10:34:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 08/14] qlit: add QLIT_QNULL and QLIT_BOOL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" As they are going to be used in the following patches. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qapi/qmp/qlit.h | 5 +++++ qobject/qlit.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h index 8882016199..7118fc9e32 100644 --- a/include/qapi/qmp/qlit.h +++ b/include/qapi/qmp/qlit.h @@ -23,6 +23,7 @@ typedef struct QLitObject QLitObject; struct QLitObject { int type; union { + bool qbool; int64_t qnum; const char *qstr; QLitDictEntry *qdict; @@ -35,6 +36,10 @@ struct QLitDictEntry { QLitObject value; }; =20 +#define QLIT_QNULL \ + { .type =3D QTYPE_QNULL } +#define QLIT_QBOOL(val) \ + { .type =3D QTYPE_QBOOL, .value.qbool =3D (val) } #define QLIT_QNUM(val) \ { .type =3D QTYPE_QNUM, .value.qnum =3D (val) } #define QLIT_QSTR(val) \ diff --git a/qobject/qlit.c b/qobject/qlit.c index ae2787ef35..07ad6b05e8 100644 --- a/qobject/qlit.c +++ b/qobject/qlit.c @@ -50,6 +50,8 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObj= ect *rhs) } =20 switch (lhs->type) { + case QTYPE_QBOOL: + return lhs->value.qbool =3D=3D qbool_get_bool(qobject_to_qbool(rhs= )); case QTYPE_QNUM: g_assert(qnum_get_try_int(qobject_to_qnum(rhs), &val)); return lhs->value.qnum =3D=3D val; @@ -81,6 +83,8 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObj= ect *rhs) =20 return helper.result; } + case QTYPE_QNULL: + return true; default: break; } --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571353723800.978705779151; Thu, 24 Aug 2017 03:42:33 -0700 (PDT) Received: from localhost ([::1]:47669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpaq-0005E6-I6 for importer@patchew.org; Thu, 24 Aug 2017 06:42:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpSz-00077V-EU for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpSy-00047F-OI for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpSy-000471-HR for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C8FA4ACA7 for ; Thu, 24 Aug 2017 10:34:23 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B1137F56B; Thu, 24 Aug 2017 10:34:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8C8FA4ACA7 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:45 +0200 Message-Id: <20170824103350.16400-10-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 24 Aug 2017 10:34:23 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 09/14] qlit: replace assert(qnum_get_try_int) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" qnum_get_int() will assert if underlying type isn't compatible. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- qobject/qlit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qobject/qlit.c b/qobject/qlit.c index 07ad6b05e8..7e4bf92862 100644 --- a/qobject/qlit.c +++ b/qobject/qlit.c @@ -53,7 +53,7 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObj= ect *rhs) case QTYPE_QBOOL: return lhs->value.qbool =3D=3D qbool_get_bool(qobject_to_qbool(rhs= )); case QTYPE_QNUM: - g_assert(qnum_get_try_int(qobject_to_qnum(rhs), &val)); + val =3D qnum_get_int(qobject_to_qnum(rhs)); return lhs->value.qnum =3D=3D val; case QTYPE_QSTRING: return (strcmp(lhs->value.qstr, --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571473065626.012288844401; Thu, 24 Aug 2017 03:44:33 -0700 (PDT) Received: from localhost ([::1]:47680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpcl-0006rS-R8 for importer@patchew.org; Thu, 24 Aug 2017 06:44:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpT7-0007F2-NM for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpT2-000480-RA for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpT2-00047n-IB for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 899FB8765E for ; Thu, 24 Aug 2017 10:34:27 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62BBB7B5E1; Thu, 24 Aug 2017 10:34:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 899FB8765E Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:46 +0200 Message-Id: <20170824103350.16400-11-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 24 Aug 2017 10:34:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/14] tests: add qlit tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/check-qlit.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ tests/Makefile.include | 5 +++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/check-qlit.c diff --git a/tests/check-qlit.c b/tests/check-qlit.c new file mode 100644 index 0000000000..47fde92a46 --- /dev/null +++ b/tests/check-qlit.c @@ -0,0 +1,64 @@ +/* + * QLit unit-tests. + * + * Copyright (C) 2017 Red Hat Inc. + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING.LIB file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "qapi/qmp/qbool.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlit.h" +#include "qapi/qmp/qnum.h" +#include "qapi/qmp/qstring.h" + +static QLitObject qlit =3D QLIT_QDICT(((QLitDictEntry[]) { + { "foo", QLIT_QNUM(42) }, + { "bar", QLIT_QSTR("hello world") }, + { "baz", QLIT_QNULL }, + { "bee", QLIT_QLIST(((QLitObject[]) { + QLIT_QNUM(43), + QLIT_QNUM(44), + QLIT_QBOOL(true), + { }, + }))}, + { }, +})); + +static QObject *make_qobject(void) +{ + QDict *qdict =3D qdict_new(); + QList *list =3D qlist_new(); + + qdict_put_int(qdict, "foo", 42); + qdict_put_str(qdict, "bar", "hello world"); + qdict_put_null(qdict, "baz"); + + qlist_append_int(list, 43); + qlist_append_int(list, 44); + qlist_append_bool(list, true); + qdict_put(qdict, "bee", list); + + return QOBJECT(qdict); +} + +static void qlit_equal_qobject_test(void) +{ + QObject *qobj =3D make_qobject(); + + g_assert(qlit_equal_qobject(&qlit, qobj)); + + qobject_decref(qobj); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + g_test_add_func("/qlit/equal_qobject", qlit_equal_qobject_test); + + return g_test_run(); +} diff --git a/tests/Makefile.include b/tests/Makefile.include index 37c1bed683..3653c7b40a 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -43,6 +43,8 @@ check-unit-y +=3D tests/check-qnull$(EXESUF) gcov-files-check-qnull-y =3D qobject/qnull.c check-unit-y +=3D tests/check-qjson$(EXESUF) gcov-files-check-qjson-y =3D qobject/qjson.c +check-unit-y +=3D tests/check-qlit$(EXESUF) +gcov-files-check-qlit-y =3D qobject/qlit.c check-unit-y +=3D tests/test-qobject-output-visitor$(EXESUF) gcov-files-test-qobject-output-visitor-y =3D qapi/qobject-output-visitor.c check-unit-y +=3D tests/test-clone-visitor$(EXESUF) @@ -535,7 +537,7 @@ GENERATED_FILES +=3D tests/test-qapi-types.h tests/test= -qapi-visit.h \ =20 test-obj-y =3D tests/check-qnum.o tests/check-qstring.o tests/check-qdict.= o \ tests/check-qlist.o tests/check-qnull.o \ - tests/check-qjson.o \ + tests/check-qjson.o tests/check-qlit.o \ tests/test-coroutine.o tests/test-string-output-visitor.o \ tests/test-string-input-visitor.o tests/test-qobject-output-visitor.o \ tests/test-clone-visitor.o \ @@ -569,6 +571,7 @@ tests/check-qdict$(EXESUF): tests/check-qdict.o $(test-= util-obj-y) tests/check-qlist$(EXESUF): tests/check-qlist.o $(test-util-obj-y) tests/check-qnull$(EXESUF): tests/check-qnull.o $(test-util-obj-y) tests/check-qjson$(EXESUF): tests/check-qjson.o $(test-util-obj-y) +tests/check-qlit$(EXESUF): tests/check-qlit.o $(test-util-obj-y) tests/check-qom-interface$(EXESUF): tests/check-qom-interface.o $(test-qom= -obj-y) tests/check-qom-proplist$(EXESUF): tests/check-qom-proplist.o $(test-qom-o= bj-y) =20 --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571232597723.9681190686416; Thu, 24 Aug 2017 03:40:32 -0700 (PDT) Received: from localhost ([::1]:47661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpYt-0003W4-FO for importer@patchew.org; Thu, 24 Aug 2017 06:40:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpT7-0007F1-N8 for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpT6-00048y-IP for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpT6-00048e-9v for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55D03C04B930 for ; Thu, 24 Aug 2017 10:34:31 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18CF271C5A; Thu, 24 Aug 2017 10:34:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 55D03C04B930 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:47 +0200 Message-Id: <20170824103350.16400-12-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 24 Aug 2017 10:34:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 11/14] qlit: improve QLit dict vs qdict comparison X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fail if the QLit dict doesn't match exactly the object dict. To do so, create a copy of the original qdict, and remove the checked elements. Verify that the dict is empty by the end of the comparison. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qobject/qlit.c | 42 ++++++++++++++++++++++++++++-------------- tests/check-qlit.c | 7 +++++++ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/qobject/qlit.c b/qobject/qlit.c index 7e4bf92862..45ae0635c0 100644 --- a/qobject/qlit.c +++ b/qobject/qlit.c @@ -41,6 +41,32 @@ static void compare_helper(QObject *obj, void *opaque) qlit_equal_qobject(&helper->objs[helper->index++], obj); } =20 +static bool qlit_equal_qdict(const QLitObject *lhs, const QDict *qdict) +{ + QDict *dict =3D qdict_clone_shallow(qdict); + bool success =3D false; + int i; + + for (i =3D 0; lhs->value.qdict[i].key; i++) { + QObject *obj =3D qdict_get(dict, lhs->value.qdict[i].key); + + if (!qlit_equal_qobject(&lhs->value.qdict[i].value, obj)) { + goto end; + } + qdict_del(dict, lhs->value.qdict[i].key); + } + + if (qdict_size(dict) !=3D 0) { + goto end; + } + + success =3D true; + +end: + QDECREF(dict); + return success; +} + bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs) { int64_t val; @@ -58,20 +84,8 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QOb= ject *rhs) case QTYPE_QSTRING: return (strcmp(lhs->value.qstr, qstring_get_str(qobject_to_qstring(rhs))) =3D=3D 0); - case QTYPE_QDICT: { - int i; - - for (i =3D 0; lhs->value.qdict[i].key; i++) { - QObject *obj =3D qdict_get(qobject_to_qdict(rhs), - lhs->value.qdict[i].key); - - if (!qlit_equal_qobject(&lhs->value.qdict[i].value, obj)) { - return false; - } - } - - return true; - } + case QTYPE_QDICT: + return qlit_equal_qdict(lhs, qobject_to_qdict(rhs)); case QTYPE_QLIST: { QListCompareHelper helper; =20 diff --git a/tests/check-qlit.c b/tests/check-qlit.c index 47fde92a46..5d9558dfd9 100644 --- a/tests/check-qlit.c +++ b/tests/check-qlit.c @@ -28,6 +28,11 @@ static QLitObject qlit =3D QLIT_QDICT(((QLitDictEntry[])= { { }, })); =20 +static QLitObject qlit_foo =3D QLIT_QDICT(((QLitDictEntry[]) { + { "foo", QLIT_QNUM(42) }, + { }, +})); + static QObject *make_qobject(void) { QDict *qdict =3D qdict_new(); @@ -51,6 +56,8 @@ static void qlit_equal_qobject_test(void) =20 g_assert(qlit_equal_qobject(&qlit, qobj)); =20 + g_assert(!qlit_equal_qobject(&qlit_foo, qobj)); + qobject_decref(qobj); } =20 --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571610814630.0953724672343; Thu, 24 Aug 2017 03:46:50 -0700 (PDT) Received: from localhost ([::1]:47694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpez-0000ns-Kr for importer@patchew.org; Thu, 24 Aug 2017 06:46:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpTC-0007J3-36 for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpTB-0004BR-9E for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49458) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpTB-0004AK-0d for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 044FF85541 for ; Thu, 24 Aug 2017 10:34:36 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 288547F56A; Thu, 24 Aug 2017 10:34:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 044FF85541 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:48 +0200 Message-Id: <20170824103350.16400-13-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 24 Aug 2017 10:34:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 12/14] qlit: improve QLit list vs qlist comparison X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Check that the QLit list has the same size as the qlist, this should ensure that we have an exact match when iterating over qlist for comparing the elements. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qobject/qlit.c | 39 ++++++++++++++++++++++++++------------- tests/check-qlit.c | 3 +++ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/qobject/qlit.c b/qobject/qlit.c index 45ae0635c0..0a60802d74 100644 --- a/qobject/qlit.c +++ b/qobject/qlit.c @@ -67,6 +67,28 @@ end: return success; } =20 +static bool qlit_equal_qlist(const QLitObject *lhs, const QList *qlist) +{ + QListCompareHelper helper; + int i; + + for (i =3D 0; lhs->value.qlist[i].type !=3D QTYPE_NONE; i++) { + continue; + } + + if (qlist_size(qlist) !=3D i) { + return false; + } + + helper.index =3D 0; + helper.objs =3D lhs->value.qlist; + helper.result =3D true; + + qlist_iter(qlist, compare_helper, &helper); + + return helper.result; +} + bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs) { int64_t val; @@ -82,21 +104,12 @@ bool qlit_equal_qobject(const QLitObject *lhs, const Q= Object *rhs) val =3D qnum_get_int(qobject_to_qnum(rhs)); return lhs->value.qnum =3D=3D val; case QTYPE_QSTRING: - return (strcmp(lhs->value.qstr, - qstring_get_str(qobject_to_qstring(rhs))) =3D=3D 0); + return g_str_equal(lhs->value.qstr, + qstring_get_str(qobject_to_qstring(rhs))); case QTYPE_QDICT: return qlit_equal_qdict(lhs, qobject_to_qdict(rhs)); - case QTYPE_QLIST: { - QListCompareHelper helper; - - helper.index =3D 0; - helper.objs =3D lhs->value.qlist; - helper.result =3D true; - - qlist_iter(qobject_to_qlist(rhs), compare_helper, &helper); - - return helper.result; - } + case QTYPE_QLIST: + return qlit_equal_qlist(lhs, qobject_to_qlist(rhs)); case QTYPE_QNULL: return true; default: diff --git a/tests/check-qlit.c b/tests/check-qlit.c index 5d9558dfd9..ae74bfcb83 100644 --- a/tests/check-qlit.c +++ b/tests/check-qlit.c @@ -58,6 +58,9 @@ static void qlit_equal_qobject_test(void) =20 g_assert(!qlit_equal_qobject(&qlit_foo, qobj)); =20 + qdict_put(qobject_to_qdict(qobj), "bee", qlist_new()); + g_assert(!qlit_equal_qobject(&qlit, qobj)); + qobject_decref(qobj); } =20 --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571684161387.622235883318; Thu, 24 Aug 2017 03:48:04 -0700 (PDT) Received: from localhost ([::1]:47704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpgA-0001d6-T1 for importer@patchew.org; Thu, 24 Aug 2017 06:48:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpTI-0007Pi-OY for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpTD-0004C9-Re for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpTD-0004Bu-IG for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E8C4883AC for ; Thu, 24 Aug 2017 10:34:38 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0B6E18245; Thu, 24 Aug 2017 10:34:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8E8C4883AC Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:49 +0200 Message-Id: <20170824103350.16400-14-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 24 Aug 2017 10:34:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 13/14] qlit: add qobject_form_qlit() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qapi/qmp/qlit.h | 2 ++ qobject/qlit.c | 37 +++++++++++++++++++++++++++++++++++++ tests/check-qlit.c | 26 ++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/include/qapi/qmp/qlit.h b/include/qapi/qmp/qlit.h index 7118fc9e32..9b6e06d02f 100644 --- a/include/qapi/qmp/qlit.h +++ b/include/qapi/qmp/qlit.h @@ -51,4 +51,6 @@ struct QLitDictEntry { =20 bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs); =20 +QObject *qobject_from_qlit(const QLitObject *qlit); + #endif /* QLIT_H_ */ diff --git a/qobject/qlit.c b/qobject/qlit.c index 0a60802d74..4adc2033a9 100644 --- a/qobject/qlit.c +++ b/qobject/qlit.c @@ -118,3 +118,40 @@ bool qlit_equal_qobject(const QLitObject *lhs, const Q= Object *rhs) =20 return false; } + +QObject *qobject_from_qlit(const QLitObject *qlit) +{ + int i; + + switch (qlit->type) { + case QTYPE_QNULL: + return QOBJECT(qnull()); + case QTYPE_QNUM: + return QOBJECT(qnum_from_int(qlit->value.qnum)); + case QTYPE_QSTRING: + return QOBJECT(qstring_from_str(qlit->value.qstr)); + case QTYPE_QDICT: { + QDict *qdict =3D qdict_new(); + for (i =3D 0; qlit->value.qdict[i].value.type !=3D QTYPE_NONE; i++= ) { + QLitDictEntry *e =3D &qlit->value.qdict[i]; + + qdict_put_obj(qdict, e->key, qobject_from_qlit(&e->value)); + } + return QOBJECT(qdict); + } + case QTYPE_QLIST: { + QList *qlist =3D qlist_new(); + + for (i =3D 0; qlit->value.qlist[i].type !=3D QTYPE_NONE; i++) { + qlist_append_obj(qlist, qobject_from_qlit(&qlit->value.qlist[i= ])); + } + return QOBJECT(qlist); + } + case QTYPE_QBOOL: + return QOBJECT(qbool_from_bool(qlit->value.qbool)); + case QTYPE_NONE: + assert(0); + } + + return NULL; +} diff --git a/tests/check-qlit.c b/tests/check-qlit.c index ae74bfcb83..135a399c6d 100644 --- a/tests/check-qlit.c +++ b/tests/check-qlit.c @@ -64,11 +64,37 @@ static void qlit_equal_qobject_test(void) qobject_decref(qobj); } =20 +static void qobject_from_qlit_test(void) +{ + QObject *obj, *qobj =3D qobject_from_qlit(&qlit); + QDict *qdict; + QList *bee; + + qdict =3D qobject_to_qdict(qobj); + g_assert_cmpint(qdict_get_int(qdict, "foo"), =3D=3D, 42); + g_assert_cmpstr(qdict_get_str(qdict, "bar"), =3D=3D, "hello world"); + g_assert(qobject_type(qdict_get(qdict, "baz")) =3D=3D QTYPE_QNULL); + + bee =3D qdict_get_qlist(qdict, "bee"); + obj =3D qlist_pop(bee); + g_assert_cmpint(qnum_get_int(qobject_to_qnum(obj)), =3D=3D, 43); + qobject_decref(obj); + obj =3D qlist_pop(bee); + g_assert_cmpint(qnum_get_int(qobject_to_qnum(obj)), =3D=3D, 44); + qobject_decref(obj); + obj =3D qlist_pop(bee); + g_assert(qbool_get_bool(qobject_to_qbool(obj))); + qobject_decref(obj); + + qobject_decref(qobj); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); =20 g_test_add_func("/qlit/equal_qobject", qlit_equal_qobject_test); + g_test_add_func("/qlit/qobject_from_qlit", qobject_from_qlit_test); =20 return g_test_run(); } --=20 2.14.1.146.gd35faa819 From nobody Thu May 2 21:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503571756550465.78271936065516; Thu, 24 Aug 2017 03:49:16 -0700 (PDT) Received: from localhost ([::1]:47708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkphL-0002FZ-CI for importer@patchew.org; Thu, 24 Aug 2017 06:49:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpTI-0007Pj-Oj for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpTG-0004DJ-KM for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44432) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpTG-0004Cy-B3 for qemu-devel@nongnu.org; Thu, 24 Aug 2017 06:34:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55E7A37EEE; Thu, 24 Aug 2017 10:34:41 +0000 (UTC) Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8349B7B54B; Thu, 24 Aug 2017 10:34:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 55E7A37EEE Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 12:33:50 +0200 Message-Id: <20170824103350.16400-15-marcandre.lureau@redhat.com> In-Reply-To: <20170824103350.16400-1-marcandre.lureau@redhat.com> References: <20170824103350.16400-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 24 Aug 2017 10:34:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 14/14] qapi: generate a literal qobject for introspection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com, "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Replace the generated json string with a literal qobject. The later is easier to deal with, at run time as well as compile time: adding #if conditionals will be easier than in a json string. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- scripts/qapi-introspect.py | 87 ++++++++++++++++++++++------------= ---- monitor.c | 2 +- tests/test-qobject-input-visitor.c | 11 +++-- docs/devel/qapi-code-gen.txt | 29 ++++++++----- 4 files changed, 78 insertions(+), 51 deletions(-) diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 032bcea491..a157a5f91c 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -12,31 +12,41 @@ from qapi import * =20 =20 -# Caveman's json.dumps() replacement (we're stuck at Python 2.4) -# TODO try to use json.dumps() once we get unstuck -def to_json(obj, level=3D0): +def to_qlit(obj, level=3D0, suppress_first_indent=3DFalse): + + def indent(level): + return level * 4 * ' ' + + ret =3D '' + if not suppress_first_indent: + ret +=3D indent(level) if obj is None: - ret =3D 'null' + ret +=3D 'QLIT_QNULL' elif isinstance(obj, str): - ret =3D '"' + obj.replace('"', r'\"') + '"' + ret +=3D 'QLIT_QSTR(' + to_c_string(obj) + ')' elif isinstance(obj, list): - elts =3D [to_json(elt, level + 1) + elts =3D [to_qlit(elt, level + 1) for elt in obj] - ret =3D '[' + ', '.join(elts) + ']' + elts.append(indent(level + 1) + "{}") + ret +=3D 'QLIT_QLIST(((QLitObject[]) {\n' + ret +=3D ',\n'.join(elts) + '\n' + ret +=3D indent(level) + '}))' elif isinstance(obj, dict): - elts =3D ['"%s": %s' % (key.replace('"', r'\"'), - to_json(obj[key], level + 1)) - for key in sorted(obj.keys())] - ret =3D '{' + ', '.join(elts) + '}' + elts =3D [] + for key, value in sorted(obj.iteritems()): + elts.append(indent(level + 1) + '{ %s, %s }' % + (to_c_string(key), to_qlit(value, level + 1, False= ))) + elts.append(indent(level + 1) + '{}') + ret +=3D 'QLIT_QDICT(((QLitDictEntry[]) {\n' + ret +=3D ',\n'.join(elts) + '\n' + ret +=3D indent(level) + '}))' else: assert False # not implemented - if level =3D=3D 1: - ret =3D '\n' + ret return ret =20 =20 -def to_c_string(string): - return '"' + string.replace('\\', r'\\').replace('"', r'\"') + '"' +def to_c_string(s): + return '"' + s.replace('\\', r'\\').replace('"', r'\"') + '"' =20 =20 class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): @@ -45,39 +55,37 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): self.defn =3D None self.decl =3D None self._schema =3D None - self._jsons =3D None + self._qlits =3D None self._used_types =3D None self._name_map =3D None =20 def visit_begin(self, schema): self._schema =3D schema - self._jsons =3D [] + self._qlits =3D [] self._used_types =3D [] self._name_map =3D {} =20 def visit_end(self): # visit the types that are actually used - jsons =3D self._jsons - self._jsons =3D [] + qlits =3D self._qlits + self._qlits =3D [] for typ in self._used_types: typ.visit(self) # generate C # TODO can generate awfully long lines - jsons.extend(self._jsons) - name =3D c_name(prefix, protect=3DFalse) + 'qmp_schema_json' + qlits.extend(self._qlits) + name =3D c_name(prefix, protect=3DFalse) + 'qmp_schema_qlit' self.decl =3D mcgen(''' -extern const char %(c_name)s[]; +extern const QLitObject %(c_name)s; ''', c_name=3Dc_name(name)) - lines =3D to_json(jsons).split('\n') - c_string =3D '\n '.join([to_c_string(line) for line in lines]) self.defn =3D mcgen(''' -const char %(c_name)s[] =3D %(c_string)s; +const QLitObject %(c_name)s =3D %(c_string)s; ''', c_name=3Dc_name(name), - c_string=3Dc_string) + c_string=3Dto_qlit(qlits)) self._schema =3D None - self._jsons =3D None + self._qlits =3D None self._used_types =3D None self._name_map =3D None =20 @@ -111,12 +119,12 @@ const char %(c_name)s[] =3D %(c_string)s; return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) =20 - def _gen_json(self, name, mtype, obj): + def _gen_qlit(self, name, mtype, obj): if mtype not in ('command', 'event', 'builtin', 'array'): name =3D self._name(name) obj['name'] =3D name obj['meta-type'] =3D mtype - self._jsons.append(obj) + self._qlits.append(obj) =20 def _gen_member(self, member): ret =3D {'name': member.name, 'type': self._use_type(member.type)} @@ -132,24 +140,24 @@ const char %(c_name)s[] =3D %(c_string)s; return {'case': variant.name, 'type': self._use_type(variant.type)} =20 def visit_builtin_type(self, name, info, json_type): - self._gen_json(name, 'builtin', {'json-type': json_type}) + self._gen_qlit(name, 'builtin', {'json-type': json_type}) =20 def visit_enum_type(self, name, info, values, prefix): - self._gen_json(name, 'enum', {'values': values}) + self._gen_qlit(name, 'enum', {'values': values}) =20 def visit_array_type(self, name, info, element_type): element =3D self._use_type(element_type) - self._gen_json('[' + element + ']', 'array', {'element-type': elem= ent}) + self._gen_qlit('[' + element + ']', 'array', {'element-type': elem= ent}) =20 def visit_object_type_flat(self, name, info, members, variants): obj =3D {'members': [self._gen_member(m) for m in members]} if variants: obj.update(self._gen_variants(variants.tag_member.name, variants.variants)) - self._gen_json(name, 'object', obj) + self._gen_qlit(name, 'object', obj) =20 def visit_alternate_type(self, name, info, variants): - self._gen_json(name, 'alternate', + self._gen_qlit(name, 'alternate', {'members': [{'type': self._use_type(m.type)} for m in variants.variants]}) =20 @@ -157,13 +165,13 @@ const char %(c_name)s[] =3D %(c_string)s; gen, success_response, boxed): arg_type =3D arg_type or self._schema.the_empty_object_type ret_type =3D ret_type or self._schema.the_empty_object_type - self._gen_json(name, 'command', + self._gen_qlit(name, 'command', {'arg-type': self._use_type(arg_type), 'ret-type': self._use_type(ret_type)}) =20 def visit_event(self, name, info, arg_type, boxed): arg_type =3D arg_type or self._schema.the_empty_object_type - self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type= )}) + self._gen_qlit(name, 'event', {'arg-type': self._use_type(arg_type= )}) =20 # Debugging aid: unmask QAPI schema's type names # We normally mask them, because they're not QMP wire ABI @@ -205,11 +213,18 @@ h_comment =3D ''' =20 fdef.write(mcgen(''' #include "qemu/osdep.h" +#include "qapi/qmp/qlit.h" #include "%(prefix)sqmp-introspect.h" =20 ''', prefix=3Dprefix)) =20 +fdecl.write(mcgen(''' +#include "qemu/osdep.h" +#include "qapi/qmp/qlit.h" + +''')) + schema =3D QAPISchema(input_file) gen =3D QAPISchemaGenIntrospectVisitor(opt_unmask) schema.visit(gen) diff --git a/monitor.c b/monitor.c index e0f880107f..14c27d4b6f 100644 --- a/monitor.c +++ b/monitor.c @@ -953,7 +953,7 @@ EventInfoList *qmp_query_events(Error **errp) static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, Error **errp) { - *ret_data =3D qobject_from_json(qmp_schema_json, &error_abort); + *ret_data =3D qobject_from_qlit(&qmp_schema_qlit); } =20 /* diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index bcf02617dc..bdd00f6bd8 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -1247,24 +1247,27 @@ static void test_visitor_in_fail_alternate(TestInpu= tVisitorData *data, } =20 static void do_test_visitor_in_qmp_introspect(TestInputVisitorData *data, - const char *schema_json) + const QLitObject *qlit) { SchemaInfoList *schema =3D NULL; + QObject *obj =3D qobject_from_qlit(qlit); Visitor *v; =20 - v =3D visitor_input_test_init_raw(data, schema_json); + v =3D qobject_input_visitor_new(obj); =20 visit_type_SchemaInfoList(v, NULL, &schema, &error_abort); g_assert(schema); =20 qapi_free_SchemaInfoList(schema); + qobject_decref(obj); + visit_free(v); } =20 static void test_visitor_in_qmp_introspect(TestInputVisitorData *data, const void *unused) { - do_test_visitor_in_qmp_introspect(data, test_qmp_schema_json); - do_test_visitor_in_qmp_introspect(data, qmp_schema_json); + do_test_visitor_in_qmp_introspect(data, &test_qmp_schema_qlit); + do_test_visitor_in_qmp_introspect(data, &qmp_schema_qlit); } =20 int main(int argc, char **argv) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 9903ac4c19..b653e86bff 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -1295,18 +1295,27 @@ Example: #ifndef EXAMPLE_QMP_INTROSPECT_H #define EXAMPLE_QMP_INTROSPECT_H =20 - extern const char example_qmp_schema_json[]; + extern const QLitObject qmp_schema_qlit; =20 #endif $ cat qapi-generated/example-qmp-introspect.c [Uninteresting stuff omitted...] =20 - const char example_qmp_schema_json[] =3D "[" - "{\"arg-type\": \"0\", \"meta-type\": \"event\", \"name\": \"MY_EV= ENT\"}, " - "{\"arg-type\": \"1\", \"meta-type\": \"command\", \"name\": \"my-= command\", \"ret-type\": \"2\"}, " - "{\"members\": [], \"meta-type\": \"object\", \"name\": \"0\"}, " - "{\"members\": [{\"name\": \"arg1\", \"type\": \"[2]\"}], \"meta-t= ype\": \"object\", \"name\": \"1\"}, " - "{\"members\": [{\"name\": \"integer\", \"type\": \"int\"}, {\"def= ault\": null, \"name\": \"string\", \"type\": \"str\"}], \"meta-type\": \"o= bject\", \"name\": \"2\"}, " - "{\"element-type\": \"2\", \"meta-type\": \"array\", \"name\": \"[= 2]\"}, " - "{\"json-type\": \"int\", \"meta-type\": \"builtin\", \"name\": \"= int\"}, " - "{\"json-type\": \"string\", \"meta-type\": \"builtin\", \"name\":= \"str\"}]"; + const QLitObject example_qmp_schema_qlit =3D QLIT_QLIST(((QLitObject[]= ) { + QLIT_QDICT(((QLitDictEntry[]) { + { "arg-type", QLIT_QSTR("0") }, + { "meta-type", QLIT_QSTR("event") }, + { "name", QLIT_QSTR("Event") }, + { } + })), + QLIT_QDICT(((QLitDictEntry[]) { + { "members", QLIT_QLIST(((QLitObject[]) { + { } + })) }, + { "meta-type", QLIT_QSTR("object") }, + { "name", QLIT_QSTR("0") }, + { } + })), + ... + { } + })); --=20 2.14.1.146.gd35faa819