From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXrsG-0004DS-Na for qemu-devel@nongnu.org; Fri, 04 Sep 2015 10:21:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXrsE-0001Wz-Ja for qemu-devel@nongnu.org; Fri, 04 Sep 2015 10:21:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXrsE-0001Tp-37 for qemu-devel@nongnu.org; Fri, 04 Sep 2015 10:21:50 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id A6950C0AB67D for ; Fri, 4 Sep 2015 14:21:49 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-25.ams2.redhat.com [10.36.116.25]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84ELkFS024652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 4 Sep 2015 10:21:48 -0400 From: Markus Armbruster Date: Fri, 4 Sep 2015 16:21:37 +0200 Message-Id: <1441376500-14784-31-git-send-email-armbru@redhat.com> In-Reply-To: <1441376500-14784-1-git-send-email-armbru@redhat.com> References: <1441376500-14784-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PULL 30/33] qapi: Fix errors for non-string, non-dictionary members List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Fixes the errors demonstrated by the previous commit. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi.py | 10 ++++++---- tests/qapi-schema/args-invalid.err | 2 +- tests/qapi-schema/args-invalid.json | 1 - tests/qapi-schema/struct-data-invalid.err | 2 +- tests/qapi-schema/struct-data-invalid.json | 1 - tests/qapi-schema/struct-member-invalid.err | 2 +- tests/qapi-schema/struct-member-invalid.json | 1 - 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 197db77..3656059 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -462,13 +462,15 @@ def check_type(expr_info, source, value, allow_array = False, % (source, all_names[value], orig_value)) return - # value is a dictionary, check that each member is okay - if not isinstance(value, OrderedDict): - raise QAPIExprError(expr_info, - "%s should be a dictionary" % source) if not allow_dict: raise QAPIExprError(expr_info, "%s should be a type name" % source) + + if not isinstance(value, OrderedDict): + raise QAPIExprError(expr_info, + "%s should be a dictionary or type name" % source) + + # value is a dictionary, check that each member is okay for (key, arg) in value.items(): check_name(expr_info, "Member of %s" % source, key, allow_optional=allow_optional) diff --git a/tests/qapi-schema/args-invalid.err b/tests/qapi-schema/args-invalid.err index 6d0fa05..fe1e949 100644 --- a/tests/qapi-schema/args-invalid.err +++ b/tests/qapi-schema/args-invalid.err @@ -1 +1 @@ -tests/qapi-schema/args-invalid.json:2: 'data' for command 'foo' should be a dictionary +tests/qapi-schema/args-invalid.json:1: 'data' for command 'foo' should be a dictionary or type name diff --git a/tests/qapi-schema/args-invalid.json b/tests/qapi-schema/args-invalid.json index 4a64135..db09813 100644 --- a/tests/qapi-schema/args-invalid.json +++ b/tests/qapi-schema/args-invalid.json @@ -1,3 +1,2 @@ -# FIXME error "should be a dictionary" is misleading, type name is also fine { 'command': 'foo', 'data': false } diff --git a/tests/qapi-schema/struct-data-invalid.err b/tests/qapi-schema/struct-data-invalid.err index a40e23a..6644f4c 100644 --- a/tests/qapi-schema/struct-data-invalid.err +++ b/tests/qapi-schema/struct-data-invalid.err @@ -1 +1 @@ -tests/qapi-schema/struct-data-invalid.json:2: 'data' for struct 'foo' should be a dictionary +tests/qapi-schema/struct-data-invalid.json:1: 'data' for struct 'foo' should be a dictionary or type name diff --git a/tests/qapi-schema/struct-data-invalid.json b/tests/qapi-schema/struct-data-invalid.json index b76de82..9adbc3b 100644 --- a/tests/qapi-schema/struct-data-invalid.json +++ b/tests/qapi-schema/struct-data-invalid.json @@ -1,3 +1,2 @@ -# FIXME error "should be a dictionary" is misleading, type name is also fine { 'struct': 'foo', 'data': false } diff --git a/tests/qapi-schema/struct-member-invalid.err b/tests/qapi-schema/struct-member-invalid.err index 9e4c7b8..69a326d 100644 --- a/tests/qapi-schema/struct-member-invalid.err +++ b/tests/qapi-schema/struct-member-invalid.err @@ -1 +1 @@ -tests/qapi-schema/struct-member-invalid.json:2: Member 'a' of 'data' for struct 'foo' should be a dictionary +tests/qapi-schema/struct-member-invalid.json:1: Member 'a' of 'data' for struct 'foo' should be a type name diff --git a/tests/qapi-schema/struct-member-invalid.json b/tests/qapi-schema/struct-member-invalid.json index 968e63c..8f172f7 100644 --- a/tests/qapi-schema/struct-member-invalid.json +++ b/tests/qapi-schema/struct-member-invalid.json @@ -1,3 +1,2 @@ -# FIXME error message "should be a dictionary" is wrong, must be type name { 'struct': 'foo', 'data': { 'a': false } } -- 2.4.3