From patchwork Sat Mar 5 16:16:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8510901 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 111029F659 for ; Sat, 5 Mar 2016 16:16:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67E31201C7 for ; Sat, 5 Mar 2016 16:16:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A2FD02022A for ; Sat, 5 Mar 2016 16:16:56 +0000 (UTC) Received: from localhost ([::1]:47062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acEsx-0001FW-TC for patchwork-qemu-devel@patchwork.kernel.org; Sat, 05 Mar 2016 11:16:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acEsl-0001E1-15 for qemu-devel@nongnu.org; Sat, 05 Mar 2016 11:16:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1acEsh-0002ch-Fc for qemu-devel@nongnu.org; Sat, 05 Mar 2016 11:16:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acEsh-0002cQ-9z for qemu-devel@nongnu.org; Sat, 05 Mar 2016 11:16:39 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 05AB56436E; Sat, 5 Mar 2016 16:16:39 +0000 (UTC) Received: from red.redhat.com (ovpn-113-165.phx2.redhat.com [10.3.113.165]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u25GGb59019060; Sat, 5 Mar 2016 11:16:38 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Sat, 5 Mar 2016 09:16:26 -0700 Message-Id: <1457194595-16189-2-git-send-email-eblake@redhat.com> In-Reply-To: <1457194595-16189-1-git-send-email-eblake@redhat.com> References: <1457194595-16189-1-git-send-email-eblake@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.39]); Sat, 05 Mar 2016 16:16:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, Michael Roth Subject: [Qemu-devel] [PATCH v4 01/10] qapi: Assert in places where variants are not handled X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We are getting closer to the point where we could use one union as the base or variant type within another union type (as long as there are no collisions between any possible combination of member names allowed across all discriminator choices). But until we get to that point, it is worth asserting that variants are not present in places where we are not prepared to handle them: base types must still be plain structs, and anywhere we explode a struct into a parameter list (events and command marshalling), we don't support variants in that explosion. Signed-off-by: Eric Blake --- v4: new patch, split out from .is_empty() patch --- scripts/qapi.py | 1 + scripts/qapi-commands.py | 3 ++- scripts/qapi-event.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 6b2aa6e..dc26ef9 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -960,6 +960,7 @@ class QAPISchemaObjectType(QAPISchemaType): assert isinstance(self.base, QAPISchemaObjectType) self.base.check(schema) self.base.check_clash(schema, self.info, seen) + assert not self.base.variants for m in self.local_members: m.check(schema) m.check_clash(self.info, seen) diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index f44e01f..edcbd10 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -2,7 +2,7 @@ # QAPI command marshaller generator # # Copyright IBM, Corp. 2011 -# Copyright (C) 2014-2015 Red Hat, Inc. +# Copyright (C) 2014-2016 Red Hat, Inc. # # Authors: # Anthony Liguori @@ -30,6 +30,7 @@ def gen_call(name, arg_type, ret_type): argstr = '' if arg_type: + assert not arg_type.variants for memb in arg_type.members: if memb.optional: argstr += 'has_%s, ' % c_name(memb.name) diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index fb579dd..c03cb78 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -59,6 +59,7 @@ def gen_event_send(name, arg_type): name=name) if arg_type and arg_type.members: + assert not arg_type.variants ret += mcgen(''' qov = qmp_output_visitor_new(); v = qmp_output_get_visitor(qov);