From nobody Sun May 5 20:08:35 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.zoho.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 1487791029632470.90627225169703; Wed, 22 Feb 2017 11:17:09 -0800 (PST) Received: from localhost ([::1]:54850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcPR-0005rb-EN for importer@patchew.org; Wed, 22 Feb 2017 14:17:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004d3-Ds for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNR-0000dK-7f for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47424) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNR-0000cx-2F for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:01 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 29FF97FB76 for ; Wed, 22 Feb 2017 19:15:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJExqt023282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:00 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 510E3113864A; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:43 +0100 Message-Id: <1487790898-24921-2-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 22 Feb 2017 19:15:01 +0000 (UTC) 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] [PULL 01/16] numa: Flatten simple union NumaOptions 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Simple unions are simpler than flat unions in the schema, but more complicated in C and on the QMP wire: there's extra indirection in C and extra nesting on the wire, both pointless. They're best avoided in new code. NumaOptions isn't new, but it's only used internally, not in QMP. Convert it to a flat union. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <1487709988-14322-2-git-send-email-armbru@redhat.com> --- numa.c | 4 ++-- qapi-schema.json | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/numa.c b/numa.c index 9f56be9..e01cb54 100644 --- a/numa.c +++ b/numa.c @@ -228,8 +228,8 @@ static int parse_numa(void *opaque, QemuOpts *opts, Err= or **errp) } =20 switch (object->type) { - case NUMA_OPTIONS_KIND_NODE: - numa_node_parse(object->u.node.data, opts, &err); + case NUMA_OPTIONS_TYPE_NODE: + numa_node_parse(&object->u.node, opts, &err); if (err) { goto end; } diff --git a/qapi-schema.json b/qapi-schema.json index e9a6364..a448ea8 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -5571,6 +5571,14 @@ 'events' : [ 'InputEvent' ] } } =20 ## +# @NumaOptionsType: +# +# Since: 2.1 +## +{ 'enum': 'NumaOptionsType', + 'data': [ 'node' ] } + +## # @NumaOptions: # # A discriminated record of NUMA options. (for OptsVisitor) @@ -5578,6 +5586,8 @@ # Since: 2.1 ## { 'union': 'NumaOptions', + 'base': { 'type': 'NumaOptionsType' }, + 'discriminator': 'type', 'data': { 'node': 'NumaNodeOptions' }} =20 --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 148779151357918.867904487101328; Wed, 22 Feb 2017 11:25:13 -0800 (PST) Received: from localhost ([::1]:54892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcXI-0005Xu-61 for importer@patchew.org; Wed, 22 Feb 2017 14:25:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004cz-Ce for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNR-0000di-D1 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38966) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNR-0000d2-3O for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:01 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AB1C3B755 for ; Wed, 22 Feb 2017 19:15:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJExMg004689 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:00 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 52D6D113864D; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:44 +0100 Message-Id: <1487790898-24921-3-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 22 Feb 2017 19:15:01 +0000 (UTC) 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] [PULL 02/16] net: Flatten simple union NetLegacyOptions 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Simple unions are simpler than flat unions in the schema, but more complicated in C and on the QMP wire: there's extra indirection in C and extra nesting on the wire, both pointless. They're best avoided in new code. NetLegacyOptions isn't new, but it's only used internally, not in QMP. Convert it to a flat union. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <1487709988-14322-3-git-send-email-armbru@redhat.com> --- net/net.c | 44 ++++++++++++++++++++++---------------------- qapi-schema.json | 11 +++++++++++ 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/net/net.c b/net/net.c index fb7af3a..0ac3b9e 100644 --- a/net/net.c +++ b/net/net.c @@ -993,47 +993,47 @@ static int net_client_init1(const void *object, bool = is_netdev, Error **errp) =20 /* Map the old options to the new flat type */ switch (opts->type) { - case NET_LEGACY_OPTIONS_KIND_NONE: + case NET_LEGACY_OPTIONS_TYPE_NONE: return 0; /* nothing to do */ - case NET_LEGACY_OPTIONS_KIND_NIC: + case NET_LEGACY_OPTIONS_TYPE_NIC: legacy.type =3D NET_CLIENT_DRIVER_NIC; - legacy.u.nic =3D *opts->u.nic.data; + legacy.u.nic =3D opts->u.nic; break; - case NET_LEGACY_OPTIONS_KIND_USER: + case NET_LEGACY_OPTIONS_TYPE_USER: legacy.type =3D NET_CLIENT_DRIVER_USER; - legacy.u.user =3D *opts->u.user.data; + legacy.u.user =3D opts->u.user; break; - case NET_LEGACY_OPTIONS_KIND_TAP: + case NET_LEGACY_OPTIONS_TYPE_TAP: legacy.type =3D NET_CLIENT_DRIVER_TAP; - legacy.u.tap =3D *opts->u.tap.data; + legacy.u.tap =3D opts->u.tap; break; - case NET_LEGACY_OPTIONS_KIND_L2TPV3: + case NET_LEGACY_OPTIONS_TYPE_L2TPV3: legacy.type =3D NET_CLIENT_DRIVER_L2TPV3; - legacy.u.l2tpv3 =3D *opts->u.l2tpv3.data; + legacy.u.l2tpv3 =3D opts->u.l2tpv3; break; - case NET_LEGACY_OPTIONS_KIND_SOCKET: + case NET_LEGACY_OPTIONS_TYPE_SOCKET: legacy.type =3D NET_CLIENT_DRIVER_SOCKET; - legacy.u.socket =3D *opts->u.socket.data; + legacy.u.socket =3D opts->u.socket; break; - case NET_LEGACY_OPTIONS_KIND_VDE: + case NET_LEGACY_OPTIONS_TYPE_VDE: legacy.type =3D NET_CLIENT_DRIVER_VDE; - legacy.u.vde =3D *opts->u.vde.data; + legacy.u.vde =3D opts->u.vde; break; - case NET_LEGACY_OPTIONS_KIND_DUMP: + case NET_LEGACY_OPTIONS_TYPE_DUMP: legacy.type =3D NET_CLIENT_DRIVER_DUMP; - legacy.u.dump =3D *opts->u.dump.data; + legacy.u.dump =3D opts->u.dump; break; - case NET_LEGACY_OPTIONS_KIND_BRIDGE: + case NET_LEGACY_OPTIONS_TYPE_BRIDGE: legacy.type =3D NET_CLIENT_DRIVER_BRIDGE; - legacy.u.bridge =3D *opts->u.bridge.data; + legacy.u.bridge =3D opts->u.bridge; break; - case NET_LEGACY_OPTIONS_KIND_NETMAP: + case NET_LEGACY_OPTIONS_TYPE_NETMAP: legacy.type =3D NET_CLIENT_DRIVER_NETMAP; - legacy.u.netmap =3D *opts->u.netmap.data; + legacy.u.netmap =3D opts->u.netmap; break; - case NET_LEGACY_OPTIONS_KIND_VHOST_USER: + case NET_LEGACY_OPTIONS_TYPE_VHOST_USER: legacy.type =3D NET_CLIENT_DRIVER_VHOST_USER; - legacy.u.vhost_user =3D *opts->u.vhost_user.data; + legacy.u.vhost_user =3D opts->u.vhost_user; break; default: abort(); @@ -1048,7 +1048,7 @@ static int net_client_init1(const void *object, bool = is_netdev, Error **errp) =20 /* Do not add to a vlan if it's a nic with a netdev=3D parameter. = */ if (netdev->type !=3D NET_CLIENT_DRIVER_NIC || - !opts->u.nic.data->has_netdev) { + !opts->u.nic.has_netdev) { peer =3D net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL); } =20 diff --git a/qapi-schema.json b/qapi-schema.json index a448ea8..5347781 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3959,6 +3959,15 @@ 'opts': 'NetLegacyOptions' } } =20 ## +# @NetLegacyOptionsType: +# +# Since: 1.2 +## +{ 'enum': 'NetLegacyOptionsType', + 'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', + 'dump', 'bridge', 'netmap', 'vhost-user'] } + +## # @NetLegacyOptions: # # Like Netdev, but for use only by the legacy command line options @@ -3966,6 +3975,8 @@ # Since: 1.2 ## { 'union': 'NetLegacyOptions', + 'base': { 'type': 'NetLegacyOptionsType' }, + 'discriminator': 'type', 'data': { 'none': 'NetdevNoneOptions', 'nic': 'NetLegacyNicOptions', --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487791306121375.83367786426584; Wed, 22 Feb 2017 11:21:46 -0800 (PST) Received: from localhost ([::1]:54877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcTu-0001uo-SC for importer@patchew.org; Wed, 22 Feb 2017 14:21:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004d0-Cg for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNR-0000dW-Ao for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNR-0000cw-32 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:01 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F3342E6060 for ; Wed, 22 Feb 2017 19:15:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0945A7FE77 for ; Wed, 22 Feb 2017 19:15:00 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 565A71138650; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:45 +0100 Message-Id: <1487790898-24921-4-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 22 Feb 2017 19:15:01 +0000 (UTC) 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] [PULL 03/16] qdict: Make qdict_get_qlist() safe like qdict_get_qdict() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 89cad9f changed qdict_get_qdict() to return NULL instead of crash when the key doesn't exist or its value isn't a QDict. Commit 2d6421a neglected to do the same for qdict_get_qlist(). Correct that, and update the function comments. qdict_get_obj() is now unused, remove. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-2-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- qobject/qdict.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/qobject/qdict.c b/qobject/qdict.c index 197b0fb..b0c5364 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -178,20 +178,6 @@ size_t qdict_size(const QDict *qdict) } =20 /** - * qdict_get_obj(): Get a QObject of a specific type - */ -static QObject *qdict_get_obj(const QDict *qdict, const char *key, QType t= ype) -{ - QObject *obj; - - obj =3D qdict_get(qdict, key); - assert(obj !=3D NULL); - assert(qobject_type(obj) =3D=3D type); - - return obj; -} - -/** * qdict_get_double(): Get an number mapped by 'key' * * This function assumes that 'key' exists and it stores a @@ -241,25 +227,15 @@ bool qdict_get_bool(const QDict *qdict, const char *k= ey) } =20 /** - * qdict_get_qlist(): Get the QList mapped by 'key' - * - * This function assumes that 'key' exists and it stores a - * QList object. - * - * Return QList mapped by 'key'. + * qdict_get_qlist(): If @qdict maps @key to a QList, return it, else NULL. */ QList *qdict_get_qlist(const QDict *qdict, const char *key) { - return qobject_to_qlist(qdict_get_obj(qdict, key, QTYPE_QLIST)); + return qobject_to_qlist(qdict_get(qdict, key)); } =20 /** - * qdict_get_qdict(): Get the QDict mapped by 'key' - * - * This function assumes that 'key' exists and it stores a - * QDict object. - * - * Return QDict mapped by 'key'. + * qdict_get_qdict(): If @qdict maps @key to a QDict, return it, else NULL. */ QDict *qdict_get_qdict(const QDict *qdict, const char *key) { --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487791894885324.2142969533825; Wed, 22 Feb 2017 11:31:34 -0800 (PST) Received: from localhost ([::1]:54931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcdQ-00034P-Fs for importer@patchew.org; Wed, 22 Feb 2017 14:31:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004d9-Ew for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNR-0000dG-7L for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39554) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNR-0000cu-28 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:01 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33AD01293 for ; Wed, 22 Feb 2017 19:15:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJExv3019384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:00 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5941F1138657; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:46 +0100 Message-Id: <1487790898-24921-5-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 22 Feb 2017 19:15:01 +0000 (UTC) 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] [PULL 04/16] check-qdict: Simplify qdict_crumple_test_recursive() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use qdict_get_qdict(), qdict_get_qlist() instead of qdict_get() followed by qobject_to_qdict(), qobject_to_qlist(). While there, drop some redundant code. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-3-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/check-qdict.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/tests/check-qdict.c b/tests/check-qdict.c index 07b1c79..14e942a 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -591,7 +591,7 @@ static void qdict_join_test(void) static void qdict_crumple_test_recursive(void) { QDict *src, *dst, *rule, *vnc, *acl, *listen; - QObject *child, *res; + QObject *res; QList *rules; =20 src =3D qdict_new(); @@ -613,23 +613,19 @@ static void qdict_crumple_test_recursive(void) =20 g_assert_cmpint(qdict_size(dst), =3D=3D, 1); =20 - child =3D qdict_get(dst, "vnc"); - g_assert_cmpint(qobject_type(child), =3D=3D, QTYPE_QDICT); - vnc =3D qobject_to_qdict(child); + vnc =3D qdict_get_qdict(dst, "vnc"); + g_assert(vnc); =20 - child =3D qdict_get(vnc, "listen"); - g_assert_cmpint(qobject_type(child), =3D=3D, QTYPE_QDICT); - listen =3D qobject_to_qdict(child); + listen =3D qdict_get_qdict(vnc, "listen"); + g_assert(listen); g_assert_cmpstr("127.0.0.1", =3D=3D, qdict_get_str(listen, "addr")); g_assert_cmpstr("5901", =3D=3D, qdict_get_str(listen, "port")); =20 - child =3D qdict_get(vnc, "acl"); - g_assert_cmpint(qobject_type(child), =3D=3D, QTYPE_QDICT); - acl =3D qobject_to_qdict(child); + acl =3D qdict_get_qdict(vnc, "acl"); + g_assert(acl); =20 - child =3D qdict_get(acl, "rules"); - g_assert_cmpint(qobject_type(child), =3D=3D, QTYPE_QLIST); - rules =3D qobject_to_qlist(child); + rules =3D qdict_get_qlist(acl, "rules"); + g_assert(rules); g_assert_cmpint(qlist_size(rules), =3D=3D, 2); =20 rule =3D qobject_to_qdict(qlist_pop(rules)); @@ -646,9 +642,6 @@ static void qdict_crumple_test_recursive(void) =20 /* With recursive crumpling, we should see all names unescaped */ g_assert_cmpstr("acl0", =3D=3D, qdict_get_str(vnc, "acl.name")); - child =3D qdict_get(vnc, "acl"); - g_assert_cmpint(qobject_type(child), =3D=3D, QTYPE_QDICT); - acl =3D qdict_get_qdict(vnc, "acl"); g_assert_cmpstr("acl0", =3D=3D, qdict_get_str(acl, "rule.name")); =20 QDECREF(src); --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487791035430410.3774513424588; Wed, 22 Feb 2017 11:17:15 -0800 (PST) Received: from localhost ([::1]:54852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcPZ-0005xP-Rx for importer@patchew.org; Wed, 22 Feb 2017 14:17:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004d4-EE for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNS-0000eS-NI for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000du-HC for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:02 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C02FF4DD62 for ; Wed, 22 Feb 2017 19:15:02 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF1Bb019410 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5C07A11386CE; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:47 +0100 Message-Id: <1487790898-24921-6-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 22 Feb 2017 19:15:02 +0000 (UTC) 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] [PULL 05/16] check-qdict: Tighten qdict_crumple_test_recursive() some 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Consistently check for unexpected QDict entries, and qdict_get_qdict() success. The latter doesn't tighten the test, it only makes it fail more nicely. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-4-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/check-qdict.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/check-qdict.c b/tests/check-qdict.c index 14e942a..ded3a26 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -615,26 +615,31 @@ static void qdict_crumple_test_recursive(void) =20 vnc =3D qdict_get_qdict(dst, "vnc"); g_assert(vnc); + g_assert_cmpint(qdict_size(vnc), =3D=3D, 3); =20 listen =3D qdict_get_qdict(vnc, "listen"); g_assert(listen); + g_assert_cmpint(qdict_size(listen), =3D=3D, 2); g_assert_cmpstr("127.0.0.1", =3D=3D, qdict_get_str(listen, "addr")); g_assert_cmpstr("5901", =3D=3D, qdict_get_str(listen, "port")); =20 acl =3D qdict_get_qdict(vnc, "acl"); g_assert(acl); + g_assert_cmpint(qdict_size(acl), =3D=3D, 3); =20 rules =3D qdict_get_qlist(acl, "rules"); g_assert(rules); g_assert_cmpint(qlist_size(rules), =3D=3D, 2); =20 rule =3D qobject_to_qdict(qlist_pop(rules)); + g_assert(rule); g_assert_cmpint(qdict_size(rule), =3D=3D, 2); g_assert_cmpstr("fred", =3D=3D, qdict_get_str(rule, "match")); g_assert_cmpstr("allow", =3D=3D, qdict_get_str(rule, "policy")); QDECREF(rule); =20 rule =3D qobject_to_qdict(qlist_pop(rules)); + g_assert(rule); g_assert_cmpint(qdict_size(rule), =3D=3D, 2); g_assert_cmpstr("bob", =3D=3D, qdict_get_str(rule, "match")); g_assert_cmpstr("deny", =3D=3D, qdict_get_str(rule, "policy")); --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487791029462471.89475593496024; Wed, 22 Feb 2017 11:17:09 -0800 (PST) Received: from localhost ([::1]:54851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcPT-0005sM-2P for importer@patchew.org; Wed, 22 Feb 2017 14:17:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004dC-RO for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNS-0000en-Oz for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57188) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000dv-Hd for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:02 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C37D024A for ; Wed, 22 Feb 2017 19:15:02 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF1ti019411 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5EF7311386DC; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:48 +0100 Message-Id: <1487790898-24921-7-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 22 Feb 2017 19:15:02 +0000 (UTC) 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] [PULL 06/16] check-qjson: Simplify around 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Make compare_litqobj_to_qobj() cope with null, and drop non-null assertions from callers. compare_litqobj_to_qobj() already checks the QType matches; drop the redundant assertions from callers. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-5-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/check-qjson.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 0b21a22..49e02591 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1110,7 +1110,7 @@ static void compare_helper(QObject *obj, void *opaque) =20 static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs) { - if (lhs->type !=3D qobject_type(rhs)) { + if (!rhs || lhs->type !=3D qobject_type(rhs)) { return 0; } =20 @@ -1184,18 +1184,12 @@ static void simple_dict(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QDICT); - g_assert(compare_litqobj_to_qobj(&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)); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QDICT); - g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) =3D= =3D 1); qobject_decref(obj); QDECREF(str); @@ -1299,18 +1293,12 @@ static void simple_list(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QLIST); - g_assert(compare_litqobj_to_qobj(&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)); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QLIST); - g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) =3D= =3D 1); qobject_decref(obj); QDECREF(str); @@ -1367,18 +1355,12 @@ static void simple_whitespace(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QLIST); - g_assert(compare_litqobj_to_qobj(&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)); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QLIST); - g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) =3D= =3D 1); =20 qobject_decref(obj); @@ -1403,8 +1385,6 @@ 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(obj !=3D NULL); - g_assert(compare_litqobj_to_qobj(&decoded, obj) =3D=3D 1); =20 qobject_decref(obj); --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 14877910265241009.6772780711158; Wed, 22 Feb 2017 11:17:06 -0800 (PST) Received: from localhost ([::1]:54849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcPO-0005pG-O2 for importer@patchew.org; Wed, 22 Feb 2017 14:17:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004d2-Cr for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNS-0000eT-Me for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000dx-Hk for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:02 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C26718123E for ; Wed, 22 Feb 2017 19:15:02 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF1Iq004705 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6371D11385E0; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:49 +0100 Message-Id: <1487790898-24921-8-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 22 Feb 2017 19:15:02 +0000 (UTC) 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] [PULL 07/16] libqtest: Clean up qmp_response() a bit 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use qobject_to_qdict() instead of a type cast. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-6-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/libqtest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index d8fba66..e54354d 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -379,9 +379,9 @@ static void qmp_response(JSONMessageParser *parser, GQu= eue *tokens) exit(1); } =20 - g_assert(qobject_type(obj) =3D=3D QTYPE_QDICT); g_assert(!qmp->response); - qmp->response =3D (QDict *)obj; + qmp->response =3D qobject_to_qdict(obj); + g_assert(qmp->response); } =20 QDict *qmp_fd_receive(int fd) --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487791299601331.1643883319723; Wed, 22 Feb 2017 11:21:39 -0800 (PST) Received: from localhost ([::1]:54875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcTp-0001s9-9N for importer@patchew.org; Wed, 22 Feb 2017 14:21:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004d7-Ed for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNS-0000ec-N9 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51444) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000dz-HT for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:02 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C2E6C4DD7C for ; Wed, 22 Feb 2017 19:15:02 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF1xD004707 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 651AE11385E1; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:50 +0100 Message-Id: <1487790898-24921-9-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 22 Feb 2017 19:15:02 +0000 (UTC) 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] [PULL 08/16] test-qmp-event: Simplify and tighten event_test_emit() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use qdict_get_qdict() and qdict_get_try_int() to simplify. While there, add a sanity check for seconds. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-7-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/test-qmp-event.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 633dc87..7bb621b 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -95,24 +95,18 @@ static bool qdict_cmp_simple(QDict *a, QDict *b) correctness. */ static void event_test_emit(test_QAPIEvent event, QDict *d, Error **errp) { - QObject *obj; QDict *t; int64_t s, ms; =20 /* Verify that we have timestamp, then remove it to compare other fiel= ds */ - obj =3D qdict_get(d, "timestamp"); - g_assert(obj); - t =3D qobject_to_qdict(obj); + t =3D qdict_get_qdict(d, "timestamp"); g_assert(t); - obj =3D qdict_get(t, "seconds"); - g_assert(obj && qobject_type(obj) =3D=3D QTYPE_QINT); - s =3D qint_get_int(qobject_to_qint(obj)); - obj =3D qdict_get(t, "microseconds"); - g_assert(obj && qobject_type(obj) =3D=3D QTYPE_QINT); - ms =3D qint_get_int(qobject_to_qint(obj)); + s =3D qdict_get_try_int(t, "seconds", -2); + ms =3D qdict_get_try_int(t, "microseconds", -2); if (s =3D=3D -1) { g_assert(ms =3D=3D -1); } else { + g_assert(s >=3D 0); g_assert(ms >=3D 0 && ms <=3D 999999); } g_assert(qdict_size(t) =3D=3D 2); --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487791796262877.122210891528; Wed, 22 Feb 2017 11:29:56 -0800 (PST) Received: from localhost ([::1]:54920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcbp-0001s3-NS for importer@patchew.org; Wed, 22 Feb 2017 14:29:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNV-0004dN-JD for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNT-0000f2-0Q for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49448) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000e6-Ns for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:02 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00892C04BD48 for ; Wed, 22 Feb 2017 19:15:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF1mE007251 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 681A611385ED; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:51 +0100 Message-Id: <1487790898-24921-10-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 22 Feb 2017 19:15:03 +0000 (UTC) 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] [PULL 09/16] Don't check qobject_type() before qobject_to_qdict() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qobject_to_qdict(obj) returns NULL when obj isn't a QDict. Check that instead of qobject_type(obj) =3D=3D QTYPE_QDICT. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-8-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- block.c | 4 ++-- hw/pci/pcie_aer.c | 2 +- monitor.c | 10 ++++----- qapi/qmp-dispatch.c | 5 ++--- tests/check-qdict.c | 9 ++------ tests/test-qobject-output-visitor.c | 41 +++++++++++----------------------= ---- 6 files changed, 24 insertions(+), 47 deletions(-) diff --git a/block.c b/block.c index 743c349..3c36af5 100644 --- a/block.c +++ b/block.c @@ -1169,13 +1169,13 @@ static QDict *parse_json_filename(const char *filen= ame, Error **errp) return NULL; } =20 - if (qobject_type(options_obj) !=3D QTYPE_QDICT) { + options =3D qobject_to_qdict(options_obj); + if (!options) { qobject_decref(options_obj); error_setg(errp, "Invalid JSON object given"); return NULL; } =20 - options =3D qobject_to_qdict(options_obj); qdict_flatten(options); =20 return options; diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index daf1f65..a8c1820 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -1025,8 +1025,8 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QD= ict *qdict) return; } =20 - assert(qobject_type(data) =3D=3D QTYPE_QDICT); qdict =3D qobject_to_qdict(data); + assert(qdict); =20 devfn =3D (int)qdict_get_int(qdict, "devfn"); monitor_printf(mon, "OK id: %s root bus: %s, bus: %x devfn: %x.%x\n", diff --git a/monitor.c b/monitor.c index 3cd72a9..493bed9 100644 --- a/monitor.c +++ b/monitor.c @@ -3686,12 +3686,12 @@ static QDict *qmp_check_input_obj(QObject *input_ob= j, Error **errp) int has_exec_key =3D 0; QDict *input_dict; =20 - if (qobject_type(input_obj) !=3D QTYPE_QDICT) { - error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "object"); - return NULL; - } - input_dict =3D qobject_to_qdict(input_obj); + if (!input_dict) { + error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "object"); + return NULL; + } + =20 for (ent =3D qdict_first(input_dict); ent; ent =3D qdict_next(input_di= ct, ent)){ const char *arg_name =3D qdict_entry_key(ent); diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 505eb41..48bec20 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -28,14 +28,13 @@ static QDict *qmp_dispatch_check_obj(const QObject *req= uest, Error **errp) bool has_exec_key =3D false; QDict *dict =3D NULL; =20 - if (qobject_type(request) !=3D QTYPE_QDICT) { + dict =3D qobject_to_qdict(request); + if (!dict) { error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "request is not a dictionary"); return NULL; } =20 - dict =3D qobject_to_qdict(request); - for (ent =3D qdict_first(dict); ent; ent =3D qdict_next(dict, ent)) { arg_name =3D qdict_entry_key(ent); diff --git a/tests/check-qdict.c b/tests/check-qdict.c index ded3a26..81162ee 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -591,7 +591,6 @@ static void qdict_join_test(void) static void qdict_crumple_test_recursive(void) { QDict *src, *dst, *rule, *vnc, *acl, *listen; - QObject *res; QList *rules; =20 src =3D qdict_new(); @@ -605,12 +604,8 @@ static void qdict_crumple_test_recursive(void) qdict_put(src, "vnc.acl..name", qstring_from_str("acl0")); qdict_put(src, "vnc.acl.rule..name", qstring_from_str("acl0")); =20 - res =3D qdict_crumple(src, &error_abort); - - g_assert_cmpint(qobject_type(res), =3D=3D, QTYPE_QDICT); - - dst =3D qobject_to_qdict(res); - + dst =3D qobject_to_qdict(qdict_crumple(src, &error_abort)); + g_assert(dst); g_assert_cmpint(qdict_size(dst), =3D=3D, 1); =20 vnc =3D qdict_get_qdict(dst, "vnc"); diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 4e2d79c..a874386 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -160,15 +160,12 @@ static void test_visitor_out_struct(TestOutputVisitor= Data *data, .boolean =3D false, .string =3D (char *) "foo"}; TestStruct *p =3D &test_struct; - QObject *obj; QDict *qdict; =20 visit_type_TestStruct(data->ov, NULL, &p, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QDICT); - - qdict =3D qobject_to_qdict(obj); + qdict =3D qobject_to_qdict(visitor_get(data)); + g_assert(qdict); g_assert_cmpint(qdict_size(qdict), =3D=3D, 3); g_assert_cmpint(qdict_get_int(qdict, "integer"), =3D=3D, 42); g_assert_cmpint(qdict_get_bool(qdict, "boolean"), =3D=3D, false); @@ -180,7 +177,6 @@ static void test_visitor_out_struct_nested(TestOutputVi= sitorData *data, { int64_t value =3D 42; UserDefTwo *ud2; - QObject *obj; QDict *qdict, *dict1, *dict2, *dict3, *userdef; const char *string =3D "user def string"; const char *strings[] =3D { "forty two", "forty three", "forty four", @@ -207,10 +203,8 @@ static void test_visitor_out_struct_nested(TestOutputV= isitorData *data, =20 visit_type_UserDefTwo(data->ov, "unused", &ud2, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QDICT); - - qdict =3D qobject_to_qdict(obj); + qdict =3D qobject_to_qdict(visitor_get(data)); + g_assert(qdict); g_assert_cmpint(qdict_size(qdict), =3D=3D, 2); g_assert_cmpstr(qdict_get_str(qdict, "string0"), =3D=3D, strings[0]); =20 @@ -296,8 +290,8 @@ static void test_visitor_out_list(TestOutputVisitorData= *data, QLIST_FOREACH_ENTRY(qlist, entry) { QDict *qdict; =20 - g_assert(qobject_type(entry->value) =3D=3D QTYPE_QDICT); qdict =3D qobject_to_qdict(entry->value); + g_assert(qdict); g_assert_cmpint(qdict_size(qdict), =3D=3D, 3); g_assert_cmpint(qdict_get_int(qdict, "integer"), =3D=3D, value_int= + i); g_assert_cmpint(qdict_get_bool(qdict, "boolean"), =3D=3D, value_bo= ol); @@ -362,8 +356,7 @@ static void test_visitor_out_any(TestOutputVisitorData = *data, qobj =3D QOBJECT(qdict); visit_type_any(data->ov, NULL, &qobj, &error_abort); qobject_decref(qobj); - obj =3D visitor_get(data); - qdict =3D qobject_to_qdict(obj); + qdict =3D qobject_to_qdict(visitor_get(data)); g_assert(qdict); qobj =3D qdict_get(qdict, "integer"); g_assert(qobj); @@ -385,7 +378,6 @@ static void test_visitor_out_any(TestOutputVisitorData = *data, static void test_visitor_out_union_flat(TestOutputVisitorData *data, const void *unused) { - QObject *arg; QDict *qdict; =20 UserDefFlatUnion *tmp =3D g_malloc0(sizeof(UserDefFlatUnion)); @@ -395,11 +387,8 @@ static void test_visitor_out_union_flat(TestOutputVisi= torData *data, tmp->u.value1.boolean =3D true; =20 visit_type_UserDefFlatUnion(data->ov, NULL, &tmp, &error_abort); - arg =3D visitor_get(data); - - g_assert(qobject_type(arg) =3D=3D QTYPE_QDICT); - qdict =3D qobject_to_qdict(arg); - + qdict =3D qobject_to_qdict(visitor_get(data)); + g_assert(qdict); g_assert_cmpstr(qdict_get_str(qdict, "enum1"), =3D=3D, "value1"); g_assert_cmpstr(qdict_get_str(qdict, "string"), =3D=3D, "str"); g_assert_cmpint(qdict_get_int(qdict, "integer"), =3D=3D, 41); @@ -449,10 +438,8 @@ static void test_visitor_out_alternate(TestOutputVisit= orData *data, tmp->u.udfu.u.value1.boolean =3D true; =20 visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort); - arg =3D visitor_get(data); - - g_assert_cmpint(qobject_type(arg), =3D=3D, QTYPE_QDICT); - qdict =3D qobject_to_qdict(arg); + qdict =3D qobject_to_qdict(visitor_get(data)); + g_assert(qdict); g_assert_cmpint(qdict_size(qdict), =3D=3D, 4); g_assert_cmpint(qdict_get_int(qdict, "integer"), =3D=3D, 1); g_assert_cmpstr(qdict_get_str(qdict, "string"), =3D=3D, "str"); @@ -465,7 +452,6 @@ static void test_visitor_out_alternate(TestOutputVisito= rData *data, static void test_visitor_out_null(TestOutputVisitorData *data, const void *unused) { - QObject *arg; QDict *qdict; QObject *nil; =20 @@ -473,9 +459,8 @@ static void test_visitor_out_null(TestOutputVisitorData= *data, visit_type_null(data->ov, "a", &error_abort); visit_check_struct(data->ov, &error_abort); visit_end_struct(data->ov, NULL); - arg =3D visitor_get(data); - g_assert(qobject_type(arg) =3D=3D QTYPE_QDICT); - qdict =3D qobject_to_qdict(arg); + qdict =3D qobject_to_qdict(visitor_get(data)); + g_assert(qdict); g_assert_cmpint(qdict_size(qdict), =3D=3D, 1); nil =3D qdict_get(qdict, "a"); g_assert(nil); @@ -618,8 +603,6 @@ static void check_native_list(QObject *qobj, QList *qlist; int i; =20 - g_assert(qobj); - g_assert(qobject_type(qobj) =3D=3D QTYPE_QDICT); qdict =3D qobject_to_qdict(qobj); g_assert(qdict); g_assert(qdict_haskey(qdict, "data")); --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487791711491119.62007823734018; Wed, 22 Feb 2017 11:28:31 -0800 (PST) Received: from localhost ([::1]:54913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcaU-0000WN-9K for importer@patchew.org; Wed, 22 Feb 2017 14:28:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004d1-Cp for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNS-0000ed-NE for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49984) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000e2-Hz for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:02 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C88E9C05681B for ; Wed, 22 Feb 2017 19:15:02 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF1FQ007253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6AFA611385F0; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:52 +0100 Message-Id: <1487790898-24921-11-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 22 Feb 2017 19:15:02 +0000 (UTC) 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] [PULL 10/16] tests: Don't check qobject_type() before qobject_to_qlist() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qobject_to_qlist(obj) returns NULL when obj isn't a QList. Check that instead of qobject_type(obj) =3D=3D QTYPE_QLIST. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-9-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/test-qobject-output-visitor.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index a874386..13a0a9b 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -261,7 +261,6 @@ static void test_visitor_out_list(TestOutputVisitorData= *data, bool value_bool =3D true; int value_int =3D 10; QListEntry *entry; - QObject *obj; QList *qlist; int i; =20 @@ -279,10 +278,8 @@ static void test_visitor_out_list(TestOutputVisitorDat= a *data, =20 visit_type_TestStructList(data->ov, NULL, &head, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QLIST); - - qlist =3D qobject_to_qlist(obj); + qlist =3D qobject_to_qlist(visitor_get(data)); + g_assert(qlist); g_assert(!qlist_empty(qlist)); =20 /* ...and ensure that the visitor sees it in order */ --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487792249262178.16446879965508; Wed, 22 Feb 2017 11:37:29 -0800 (PST) Received: from localhost ([::1]:54968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcj9-0007v1-V7 for importer@patchew.org; Wed, 22 Feb 2017 14:37:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNV-0004dI-6M for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNT-0000fJ-5d for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000eD-TC for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:03 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DF5D80B20 for ; Wed, 22 Feb 2017 19:15:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF1Gw023304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6DFDE11385FC; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:53 +0100 Message-Id: <1487790898-24921-12-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 22 Feb 2017 19:15:03 +0000 (UTC) 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] [PULL 11/16] tests: Don't check qobject_type() before qobject_to_qstring() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qobject_to_qstring(obj) returns NULL when obj isn't a QString. Check that instead of qobject_type(obj) =3D=3D QTYPE_QSTRING. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-10-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/check-qjson.c | 31 ++++++++----------------------- tests/test-qobject-output-visitor.c | 37 +++++++++++++++++----------------= ---- 2 files changed, 25 insertions(+), 43 deletions(-) diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 49e02591..dd080a8 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -54,11 +54,8 @@ static void escaped_string(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded); - - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QSTRING); - =20 str =3D qobject_to_qstring(obj); + g_assert(str); g_assert_cmpstr(qstring_get_str(str), =3D=3D, test_cases[i].decode= d); =20 if (test_cases[i].skip =3D=3D 0) { @@ -89,11 +86,8 @@ static void simple_string(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded); - - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QSTRING); - =20 str =3D qobject_to_qstring(obj); + g_assert(str); g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) =3D= =3D 0); =20 str =3D qobject_to_json(obj); @@ -123,11 +117,8 @@ static void single_quote_string(void) QString *str; =20 obj =3D qobject_from_json(test_cases[i].encoded); - - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QSTRING); - =20 str =3D qobject_to_qstring(obj); + g_assert(str); g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) =3D= =3D 0); =20 QDECREF(str); @@ -820,9 +811,8 @@ static void utf8_string(void) =20 obj =3D qobject_from_json(json_in); if (utf8_out) { - g_assert(obj); - g_assert(qobject_type(obj) =3D=3D QTYPE_QSTRING); str =3D qobject_to_qstring(obj); + g_assert(str); g_assert_cmpstr(qstring_get_str(str), =3D=3D, utf8_out); } else { g_assert(!obj); @@ -847,9 +837,8 @@ static void utf8_string(void) */ if (0 && json_out !=3D json_in) { obj =3D qobject_from_json(json_out); - g_assert(obj); - g_assert(qobject_type(obj) =3D=3D QTYPE_QSTRING); str =3D qobject_to_qstring(obj); + g_assert(str); g_assert_cmpstr(qstring_get_str(str), =3D=3D, utf8_out); } } @@ -867,15 +856,11 @@ static void vararg_string(void) }; =20 for (i =3D 0; test_cases[i].decoded; i++) { - QObject *obj; QString *str; =20 - obj =3D qobject_from_jsonf("%s", test_cases[i].decoded); - - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QSTRING); - =20 - str =3D qobject_to_qstring(obj); + str =3D qobject_to_qstring(qobject_from_jsonf("%s", + test_cases[i].decoded)= ); + g_assert(str); g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) =3D= =3D 0); =20 QDECREF(str); diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 13a0a9b..3e34aa5 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -97,42 +97,41 @@ static void test_visitor_out_string(TestOutputVisitorDa= ta *data, const void *unused) { char *string =3D (char *) "Q E M U"; - QObject *obj; + QString *qstr; =20 visit_type_str(data->ov, NULL, &string, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QSTRING); - g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), =3D=3D, stri= ng); + qstr =3D qobject_to_qstring(visitor_get(data)); + g_assert(qstr); + g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, string); } =20 static void test_visitor_out_no_string(TestOutputVisitorData *data, const void *unused) { char *string =3D NULL; - QObject *obj; + QString *qstr; =20 /* A null string should return "" */ visit_type_str(data->ov, NULL, &string, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QSTRING); - g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), =3D=3D, ""); + qstr =3D qobject_to_qstring(visitor_get(data)); + g_assert(qstr); + g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, ""); } =20 static void test_visitor_out_enum(TestOutputVisitorData *data, const void *unused) { - QObject *obj; EnumOne i; + QString *qstr; =20 for (i =3D 0; i < ENUM_ONE__MAX; i++) { visit_type_EnumOne(data->ov, "unused", &i, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QSTRING); - g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), =3D=3D, - EnumOne_lookup[i]); + qstr =3D qobject_to_qstring(visitor_get(data)); + g_assert(qstr); + g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, EnumOne_lookup[i]); visitor_reset(data); } } @@ -365,9 +364,7 @@ static void test_visitor_out_any(TestOutputVisitorData = *data, qbool =3D qobject_to_qbool(qobj); g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D true); - qobj =3D qdict_get(qdict, "string"); - g_assert(qobj); - qstring =3D qobject_to_qstring(qobj); + qstring =3D qobject_to_qstring(qdict_get(qdict, "string")); g_assert(qstring); g_assert_cmpstr(qstring_get_str(qstring), =3D=3D, "foo"); } @@ -399,6 +396,7 @@ static void test_visitor_out_alternate(TestOutputVisito= rData *data, { QObject *arg; UserDefAlternate *tmp; + QString *qstr; QDict *qdict; =20 tmp =3D g_new0(UserDefAlternate, 1); @@ -419,10 +417,9 @@ static void test_visitor_out_alternate(TestOutputVisit= orData *data, tmp->u.s =3D g_strdup("hello"); =20 visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort); - arg =3D visitor_get(data); - - g_assert(qobject_type(arg) =3D=3D QTYPE_QSTRING); - g_assert_cmpstr(qstring_get_str(qobject_to_qstring(arg)), =3D=3D, "hel= lo"); + qstr =3D qobject_to_qstring(visitor_get(data)); + g_assert(qstr); + g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, "hello"); =20 qapi_free_UserDefAlternate(tmp); =20 --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487791972622942.7738830334191; Wed, 22 Feb 2017 11:32:52 -0800 (PST) Received: from localhost ([::1]:54935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgceg-0004mn-6O for importer@patchew.org; Wed, 22 Feb 2017 14:32:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNY-0004gM-80 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNT-0000fC-33 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54268) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000eA-QA for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:03 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08DC83A76B7 for ; Wed, 22 Feb 2017 19:15:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF14N023306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 70DB51138604; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:54 +0100 Message-Id: <1487790898-24921-13-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 22 Feb 2017 19:15:03 +0000 (UTC) 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] [PULL 12/16] tests: Don't check qobject_type() before qobject_to_qint() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qobject_to_qint(obj) returns NULL when obj isn't a QInt. Check that instead of qobject_type(obj) =3D=3D QTYPE_QINT. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-11-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/check-qjson.c | 24 +++++------------------- tests/test-qobject-output-visitor.c | 28 ++++++++++++---------------- 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/tests/check-qjson.c b/tests/check-qjson.c index dd080a8..aab4e0a 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -884,19 +884,15 @@ static void simple_number(void) }; =20 for (i =3D 0; test_cases[i].encoded; i++) { - QObject *obj; QInt *qint; =20 - obj =3D qobject_from_json(test_cases[i].encoded); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QINT); - - qint =3D qobject_to_qint(obj); + qint =3D qobject_to_qint(qobject_from_json(test_cases[i].encoded)); + g_assert(qint); g_assert(qint_get_int(qint) =3D=3D test_cases[i].decoded); if (test_cases[i].skip =3D=3D 0) { QString *str; =20 - str =3D qobject_to_json(obj); + str =3D qobject_to_json(QOBJECT(qint)); g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) = =3D=3D 0); QDECREF(str); } @@ -952,22 +948,12 @@ static void vararg_number(void) long long value_ll =3D 0x2342342343LL; double valuef =3D 2.323423423; =20 - obj =3D qobject_from_jsonf("%d", value); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QINT); - - qint =3D qobject_to_qint(obj); + qint =3D qobject_to_qint(qobject_from_jsonf("%d", value)); g_assert(qint_get_int(qint) =3D=3D value); - QDECREF(qint); =20 - obj =3D qobject_from_jsonf("%lld", value_ll); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QINT); - - qint =3D qobject_to_qint(obj); + qint =3D qobject_to_qint(qobject_from_jsonf("%lld", value_ll)); g_assert(qint_get_int(qint) =3D=3D value_ll); - QDECREF(qint); =20 obj =3D qobject_from_jsonf("%f", valuef); diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 3e34aa5..50b807e 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -58,13 +58,13 @@ static void test_visitor_out_int(TestOutputVisitorData = *data, const void *unused) { int64_t value =3D -42; - QObject *obj; + QInt *qint; =20 visit_type_int(data->ov, NULL, &value, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QINT); - g_assert_cmpint(qint_get_int(qobject_to_qint(obj)), =3D=3D, value); + qint =3D qobject_to_qint(visitor_get(data)); + g_assert(qint); + g_assert_cmpint(qint_get_int(qint), =3D=3D, value); } =20 static void test_visitor_out_bool(TestOutputVisitorData *data, @@ -335,13 +335,12 @@ static void test_visitor_out_any(TestOutputVisitorDat= a *data, QBool *qbool; QString *qstring; QDict *qdict; - QObject *obj; =20 qobj =3D QOBJECT(qint_from_int(-42)); visit_type_any(data->ov, NULL, &qobj, &error_abort); - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QINT); - g_assert_cmpint(qint_get_int(qobject_to_qint(obj)), =3D=3D, -42); + qint =3D qobject_to_qint(visitor_get(data)); + g_assert(qint); + g_assert_cmpint(qint_get_int(qint), =3D=3D, -42); qobject_decref(qobj); =20 visitor_reset(data); @@ -354,9 +353,7 @@ static void test_visitor_out_any(TestOutputVisitorData = *data, qobject_decref(qobj); qdict =3D qobject_to_qdict(visitor_get(data)); g_assert(qdict); - qobj =3D qdict_get(qdict, "integer"); - g_assert(qobj); - qint =3D qobject_to_qint(qobj); + qint =3D qobject_to_qint(qdict_get(qdict, "integer")); g_assert(qint); g_assert_cmpint(qint_get_int(qint), =3D=3D, -42); qobj =3D qdict_get(qdict, "boolean"); @@ -394,8 +391,8 @@ static void test_visitor_out_union_flat(TestOutputVisit= orData *data, static void test_visitor_out_alternate(TestOutputVisitorData *data, const void *unused) { - QObject *arg; UserDefAlternate *tmp; + QInt *qint; QString *qstr; QDict *qdict; =20 @@ -404,10 +401,9 @@ static void test_visitor_out_alternate(TestOutputVisit= orData *data, tmp->u.i =3D 42; =20 visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort); - arg =3D visitor_get(data); - - g_assert(qobject_type(arg) =3D=3D QTYPE_QINT); - g_assert_cmpint(qint_get_int(qobject_to_qint(arg)), =3D=3D, 42); + qint =3D qobject_to_qint(visitor_get(data)); + g_assert(qint); + g_assert_cmpint(qint_get_int(qint), =3D=3D, 42); =20 qapi_free_UserDefAlternate(tmp); =20 --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487791512441781.8814852509; Wed, 22 Feb 2017 11:25:12 -0800 (PST) Received: from localhost ([::1]:54890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcXE-0005WK-UE for importer@patchew.org; Wed, 22 Feb 2017 14:25:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004dD-S8 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNS-0000eu-UT for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000e5-Ot for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:02 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 011AC3D95D for ; Wed, 22 Feb 2017 19:15:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF1Fc025335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 73B501138607; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:55 +0100 Message-Id: <1487790898-24921-14-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 22 Feb 2017 19:15:03 +0000 (UTC) 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] [PULL 13/16] tests: Don't check qobject_type() before qobject_to_qfloat() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qobject_to_qfloat(obj) returns NULL when obj isn't a QFloat. Check that instead of qobject_type(obj) =3D=3D QTYPE_QFLOAT. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-12-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/check-qjson.c | 12 ++---------- tests/test-qobject-output-visitor.c | 8 ++++---- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/check-qjson.c b/tests/check-qjson.c index aab4e0a..591b70a 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -921,10 +921,8 @@ static void float_number(void) QFloat *qfloat; =20 obj =3D qobject_from_json(test_cases[i].encoded); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QFLOAT); - qfloat =3D qobject_to_qfloat(obj); + g_assert(qfloat); g_assert(qfloat_get_double(qfloat) =3D=3D test_cases[i].decoded); =20 if (test_cases[i].skip =3D=3D 0) { @@ -941,7 +939,6 @@ static void float_number(void) =20 static void vararg_number(void) { - QObject *obj; QInt *qint; QFloat *qfloat; int value =3D 0x2342; @@ -956,13 +953,8 @@ static void vararg_number(void) g_assert(qint_get_int(qint) =3D=3D value_ll); QDECREF(qint); =20 - obj =3D qobject_from_jsonf("%f", valuef); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QFLOAT); - - qfloat =3D qobject_to_qfloat(obj); + qfloat =3D qobject_to_qfloat(qobject_from_jsonf("%f", valuef)); g_assert(qfloat_get_double(qfloat) =3D=3D valuef); - QDECREF(qfloat); } =20 diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 50b807e..5617fd3 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -84,13 +84,13 @@ static void test_visitor_out_number(TestOutputVisitorDa= ta *data, const void *unused) { double value =3D 3.14; - QObject *obj; + QFloat *qfloat; =20 visit_type_number(data->ov, NULL, &value, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QFLOAT); - g_assert(qfloat_get_double(qobject_to_qfloat(obj)) =3D=3D value); + qfloat =3D qobject_to_qfloat(visitor_get(data)); + g_assert(qfloat); + g_assert(qfloat_get_double(qfloat) =3D=3D value); } =20 static void test_visitor_out_string(TestOutputVisitorData *data, --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 1487792423731891.7769511556403; Wed, 22 Feb 2017 11:40:23 -0800 (PST) Received: from localhost ([::1]:54985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgclw-0002J1-Bz for importer@patchew.org; Wed, 22 Feb 2017 14:40:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNZ-0004iI-U2 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNT-0000f3-0z for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41184) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000e9-P7 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:02 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06B196AADE for ; Wed, 22 Feb 2017 19:15:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF14h025339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 76B65113860A; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:56 +0100 Message-Id: <1487790898-24921-15-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 22 Feb 2017 19:15:03 +0000 (UTC) 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] [PULL 14/16] tests: Don't check qobject_type() before qobject_to_qbool() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qobject_to_qbool(obj) returns NULL when obj isn't a QBool. Check that instead of qobject_type(obj) =3D=3D QTYPE_QBOOL. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-13-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/check-qjson.c | 24 ++++++------------------ tests/test-qobject-output-visitor.c | 12 +++++------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 591b70a..e6d6935 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -966,10 +966,8 @@ static void keyword_literal(void) QString *str; =20 obj =3D qobject_from_json("true"); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - qbool =3D qobject_to_qbool(obj); + g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D true); =20 str =3D qobject_to_json(obj); @@ -979,10 +977,8 @@ static void keyword_literal(void) QDECREF(qbool); =20 obj =3D qobject_from_json("false"); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - qbool =3D qobject_to_qbool(obj); + g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D false); =20 str =3D qobject_to_json(obj); @@ -991,23 +987,15 @@ static void keyword_literal(void) =20 QDECREF(qbool); =20 - obj =3D qobject_from_jsonf("%i", false); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - - qbool =3D qobject_to_qbool(obj); + qbool =3D qobject_to_qbool(qobject_from_jsonf("%i", false)); + g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D false); - QDECREF(qbool); =20 /* Test that non-zero values other than 1 get collapsed to true */ - obj =3D qobject_from_jsonf("%i", 2); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - - qbool =3D qobject_to_qbool(obj); + qbool =3D qobject_to_qbool(qobject_from_jsonf("%i", 2)); + g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D true); - QDECREF(qbool); =20 obj =3D qobject_from_json("null"); diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 5617fd3..500b452 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -71,13 +71,13 @@ static void test_visitor_out_bool(TestOutputVisitorData= *data, const void *unused) { bool value =3D true; - QObject *obj; + QBool *qbool; =20 visit_type_bool(data->ov, NULL, &value, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - g_assert(qbool_get_bool(qobject_to_qbool(obj)) =3D=3D value); + qbool =3D qobject_to_qbool(visitor_get(data)); + g_assert(qbool); + g_assert(qbool_get_bool(qbool) =3D=3D value); } =20 static void test_visitor_out_number(TestOutputVisitorData *data, @@ -356,9 +356,7 @@ static void test_visitor_out_any(TestOutputVisitorData = *data, qint =3D qobject_to_qint(qdict_get(qdict, "integer")); g_assert(qint); g_assert_cmpint(qint_get_int(qint), =3D=3D, -42); - qobj =3D qdict_get(qdict, "boolean"); - g_assert(qobj); - qbool =3D qobject_to_qbool(qobj); + qbool =3D qobject_to_qbool(qdict_get(qdict, "boolean")); g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D true); qstring =3D qobject_to_qstring(qdict_get(qdict, "string")); --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 148779207611094.11714608288776; Wed, 22 Feb 2017 11:34:36 -0800 (PST) Received: from localhost ([::1]:54943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcgL-0005wd-O6 for importer@patchew.org; Wed, 22 Feb 2017 14:34:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNW-0004du-7r for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNU-0000g1-Aw for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNU-0000fY-4k for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61A997FB76 for ; Wed, 22 Feb 2017 19:15:04 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27F60B122B for ; Wed, 22 Feb 2017 19:15:04 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 79689113860D; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:57 +0100 Message-Id: <1487790898-24921-16-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 22 Feb 2017 19:15:04 +0000 (UTC) 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] [PULL 15/16] monitor: Clean up handle_hmp_command() a bit 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Leave checking qobject_type(req) to qmp_check_input_obj(). Rework handling of json_parser_parse_err() failing without setting an error. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-14-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- monitor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index 493bed9..1e352a6 100644 --- a/monitor.c +++ b/monitor.c @@ -3735,10 +3735,11 @@ static void handle_qmp_command(JSONMessageParser *p= arser, GQueue *tokens) Error *err =3D NULL; =20 req =3D json_parser_parse_err(tokens, NULL, &err); - if (err || !req || qobject_type(req) !=3D QTYPE_QDICT) { - if (!err) { - error_setg(&err, QERR_JSON_PARSING); - } + if (!req && !err) { + /* json_parser_parse_err() sucks: can fail without setting @err */ + error_setg(&err, QERR_JSON_PARSING); + } + if (err) { goto err_out; } =20 --=20 2.7.4 From nobody Sun May 5 20:08:35 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.zoho.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 14877915985661021.3058555656868; Wed, 22 Feb 2017 11:26:38 -0800 (PST) Received: from localhost ([::1]:54904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcYe-0006iN-5M for importer@patchew.org; Wed, 22 Feb 2017 14:26:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNV-0004dY-Sr for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNU-0000fw-9X for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39000) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNU-0000fX-4X for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6155E3D95F for ; Wed, 22 Feb 2017 19:15:04 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF3FW023373 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:04 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7C3EB1138610; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:58 +0100 Message-Id: <1487790898-24921-17-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 22 Feb 2017 19:15:04 +0000 (UTC) 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] [PULL 16/16] block: Don't bother asserting type of output visitor's output 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After a visit of a complex QAPI type FOO ov =3D qobject_output_visitor_new(&foo); visit_type_FOO(ov, NULL, expr, &error_abort); visit_complete(ov, &foo); we can safely assume qobject_type(foo) is QTYPE_QDICT. We do in many places, but occasionally assert qobject_type(obj) =3D=3D QTYPE_QDICT. Don't. The appropriate place to check such fundamental properties of QAPI visitors is the test suite. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-15-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- block/nbd.c | 2 -- block/nfs.c | 2 -- block/qapi.c | 1 - 3 files changed, 5 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index 35f24be..a7f9108 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -537,8 +537,6 @@ static void nbd_refresh_filename(BlockDriverState *bs, = QDict *options) visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort); visit_complete(ov, &saddr_qdict); visit_free(ov); - assert(qobject_type(saddr_qdict) =3D=3D QTYPE_QDICT); - qdict_put_obj(opts, "server", saddr_qdict); =20 if (s->export) { diff --git a/block/nfs.c b/block/nfs.c index 08b43dd..0cf115e 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -805,8 +805,6 @@ static void nfs_refresh_filename(BlockDriverState *bs, = QDict *options) ov =3D qobject_output_visitor_new(&server_qdict); visit_type_NFSServer(ov, NULL, &client->server, &error_abort); visit_complete(ov, &server_qdict); - assert(qobject_type(server_qdict) =3D=3D QTYPE_QDICT); - qdict_put_obj(opts, "server", server_qdict); qdict_put(opts, "path", qstring_from_str(client->path)); =20 diff --git a/block/qapi.c b/block/qapi.c index ac480aa..a40922e 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -682,7 +682,6 @@ void bdrv_image_info_specific_dump(fprintf_function fun= c_fprintf, void *f, =20 visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort); visit_complete(v, &obj); - assert(qobject_type(obj) =3D=3D QTYPE_QDICT); data =3D qdict_get(qobject_to_qdict(obj), "data"); dump_qobject(func_fprintf, f, 1, data); qobject_decref(obj); --=20 2.7.4