Received: from eggs.gnu.org ([2001:4830:134:3::10]:33966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYWJ5-0001W5-5y for qemu-devel@nongnu.org; Mon, 29 Sep 2014 04:27:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XYWIz-0008Ds-16 for qemu-devel@nongnu.org; Mon, 29 Sep 2014 04:27:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYWIy-0008DY-O4 for qemu-devel@nongnu.org; Mon, 29 Sep 2014 04:27:36 -0400 From: Markus Armbruster References: <1411165504-18198-1-git-send-email-eblake@redhat.com> <1411165504-18198-14-git-send-email-eblake@redhat.com> <87r3yyohpq.fsf@blackfin.pond.sub.org> Date: Mon, 29 Sep 2014 10:27:27 +0200 In-Reply-To: <87r3yyohpq.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Fri, 26 Sep 2014 11:26:41 +0200") Message-ID: <87vbo6sufk.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 13/19] qapi: More rigourous checking of types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Fam Zheng , qemu-devel@nongnu.org, wenchaoqemu@gmail.com, Luiz Capitulino Markus Armbruster writes: > Eric Blake writes: > >> Now that we know every expression is valid with regards to >> its keys, we can add further tests that those keys refer to >> valid types. With this patch, all references to a type (the >> 'data': of command, type, union, and event, and the 'returns': >> of command) must resolve to a builtin or another type declared >> by the current qapi parse; this includes recursing into each >> member of a data dictionary. Dealing with '**' and nested >> sub-structs will be done in later patches. >> >> Update the testsuite to match improved output. >> >> Signed-off-by: Eric Blake [...] >> @@ -262,6 +308,15 @@ def check_command(expr, expr_info): >> raise QAPIExprError(expr_info, >> "command '%s' is already defined" % name) >> commands.append(name) >> + check_type(expr_info, "'data' for command '%s'" % name, >> + expr.get('data'), allow_array=True, >> + allowed_names=['union', 'struct']) >> + check_type(expr_info, "'base' for command '%s'" % name, >> + expr.get('base'), allowed_names=['struct'], >> + allow_dict=False) >> + check_type(expr_info, "'returns' for command '%s'" % name, >> + expr.get('returns'), allow_array=True, >> + allowed_names=['built-in', 'union', 'struct', 'enum']) >> > > Nicely done. Wait a sec! What's a command's 'base'? [...]