Received: from eggs.gnu.org ([2001:4830:134:3::10]:36009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHrUL-0004NO-Rh for qemu-devel@nongnu.org; Thu, 14 Aug 2014 05:38:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHrUG-0008ON-D8 for qemu-devel@nongnu.org; Thu, 14 Aug 2014 05:38:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53724) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHrUG-0008OG-4E for qemu-devel@nongnu.org; Thu, 14 Aug 2014 05:38:24 -0400 From: Markus Armbruster References: <1407287673-20308-1-git-send-email-eblake@redhat.com> <1407287673-20308-7-git-send-email-eblake@redhat.com> Date: Thu, 14 Aug 2014 11:38:18 +0200 In-Reply-To: <1407287673-20308-7-git-send-email-eblake@redhat.com> (Eric Blake's message of "Tue, 5 Aug 2014 19:14:25 -0600") Message-ID: <87k36bjtrp.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v3 06/14] qapi: require valid expressions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Luiz Capitulino , Fam Zheng , qemu-devel@nongnu.org, wenchaoqemu@gmail.com Eric Blake writes: > The previous patch demonstrated that the generator could get > confused if an expression had conflicting meta-types, and > silently ignored expressions that lacked a known meta-type. > Fix both cases to give a sane error message. > > * scripts/qapi.py (check_exprs): Require a valid meta-type for > every expression. > * tests/qapi-schema/indented-expr.*: Use valid types. > * tests/qapi-schema/missing-type.*: Update expected output. > * tests/qapi-schema/double-type.*: Likewise. Conventional git commit message followed by GNU change log. Unusual in QEMU. Same elsewhere. Explanation of the change to indented-expr.json hides in the change log part, where I promptly missed it :) > Signed-off-by: Eric Blake > --- > scripts/qapi.py | 12 ++++++++++++ > tests/qapi-schema/double-type.err | 1 + > tests/qapi-schema/double-type.exit | 2 +- > tests/qapi-schema/double-type.out | 3 --- > tests/qapi-schema/indented-expr.json | 4 ++-- > tests/qapi-schema/indented-expr.out | 2 +- > tests/qapi-schema/missing-type.err | 1 + > tests/qapi-schema/missing-type.exit | 2 +- > tests/qapi-schema/missing-type.out | 3 --- > 9 files changed, 19 insertions(+), 11 deletions(-) > > diff --git a/scripts/qapi.py b/scripts/qapi.py > index 1082416..910e422 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -322,6 +322,18 @@ def check_exprs(schema): > info = expr_elem['info'] > members = expr.get('data') > > + # 'include' has already been flattened; at this point, all exprs > + # should have one of the remaining keys > + keys = (expr.has_key('enum') + expr.has_key('union') + > + expr.has_key('type') + expr.has_key('command') + > + expr.has_key('event')) > + if keys < 1: > + raise QAPIExprError(info, > + "Missing expression meta-type") > + if keys > 1: > + raise QAPIExprError(info, > + "Conflicting expression meta-types") > + > if expr.has_key('union'): > check_union(expr, info) > if expr.has_key('event'): Not the friendliest error messages, but they'll do.