From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAOWs-0003My-IX for qemu-devel@nongnu.org; Wed, 01 Jul 2015 16:22:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAOWp-00063A-7j for qemu-devel@nongnu.org; Wed, 01 Jul 2015 16:22:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAOWp-00062t-1e for qemu-devel@nongnu.org; Wed, 01 Jul 2015 16:22:43 -0400 From: Markus Armbruster Date: Wed, 1 Jul 2015 22:22:03 +0200 Message-Id: <1435782155-31412-16-git-send-email-armbru@redhat.com> In-Reply-To: <1435782155-31412-1-git-send-email-armbru@redhat.com> References: <1435782155-31412-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH RFC v2 15/47] qapi: Fix to reject union command arguments List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, berto@igalia.com, mdroth@linux.vnet.ibm.com A command's 'data' must be a struct type, given either as a dictionary, or as struct type name. Commit dd883c6 tightened the checking there, but not enough: we still accept 'union'. Fix to reject it. We may want to support union types there, but we'll have to extend qapi-commands.py for it. Signed-off-by: Markus Armbruster --- scripts/qapi.py | 2 +- tests/qapi-schema/args-union.err | 1 + tests/qapi-schema/args-union.exit | 2 +- tests/qapi-schema/args-union.json | 2 +- tests/qapi-schema/args-union.out | 4 ---- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 99e04f6..bebaecc 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -495,7 +495,7 @@ def check_command(expr, expr_info): check_type(expr_info, "'data' for command '%s'" % name, expr.get('data'), allow_dict=True, allow_optional=True, - allow_metas=['union', 'struct'], allow_star=allow_star) + allow_metas=['struct'], allow_star=allow_star) returns_meta = ['union', 'struct'] if name in returns_whitelist: returns_meta += ['built-in', 'alternate', 'enum'] diff --git a/tests/qapi-schema/args-union.err b/tests/qapi-schema/args-union.err index e69de29..1d693d7 100644 --- a/tests/qapi-schema/args-union.err +++ b/tests/qapi-schema/args-union.err @@ -0,0 +1 @@ +tests/qapi-schema/args-union.json:4: 'data' for command 'oops' cannot use union type 'Uni' diff --git a/tests/qapi-schema/args-union.exit b/tests/qapi-schema/args-union.exit index 573541a..d00491f 100644 --- a/tests/qapi-schema/args-union.exit +++ b/tests/qapi-schema/args-union.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/qapi-schema/args-union.json b/tests/qapi-schema/args-union.json index db97ef6..7bdcbb7 100644 --- a/tests/qapi-schema/args-union.json +++ b/tests/qapi-schema/args-union.json @@ -1,4 +1,4 @@ -# FIXME we should reject union arguments +# we do not allow union arguments # TODO should we support this? { 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } } { 'command': 'oops', 'data': 'Uni' } diff --git a/tests/qapi-schema/args-union.out b/tests/qapi-schema/args-union.out index 907080c..e69de29 100644 --- a/tests/qapi-schema/args-union.out +++ b/tests/qapi-schema/args-union.out @@ -1,4 +0,0 @@ -[OrderedDict([('union', 'Uni'), ('data', OrderedDict([('case1', 'int'), ('case2', 'str')]))]), - OrderedDict([('command', 'oops'), ('data', 'Uni')])] -[{'enum_name': 'UniKind', 'enum_values': None}] -[] -- 1.9.3