From patchwork Thu Feb 25 23:38:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8427681 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 DDFA79F52D for ; Thu, 25 Feb 2016 23:42:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 204A320389 for ; Thu, 25 Feb 2016 23:42:59 +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 50BC82025B for ; Thu, 25 Feb 2016 23:42:58 +0000 (UTC) Received: from localhost ([::1]:46455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ5Yf-0001ZS-OL for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Feb 2016 18:42:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ5Uz-0002mw-Lm for qemu-devel@nongnu.org; Thu, 25 Feb 2016 18:39:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZ5Uy-0005Ru-Pn for qemu-devel@nongnu.org; Thu, 25 Feb 2016 18:39:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ5Uy-0005RU-IA for qemu-devel@nongnu.org; Thu, 25 Feb 2016 18:39:08 -0500 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 2F3956020; Thu, 25 Feb 2016 23:39:08 +0000 (UTC) Received: from red.redhat.com (ovpn-113-105.phx2.redhat.com [10.3.113.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1PNd2Nh002433; Thu, 25 Feb 2016 18:39:07 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 25 Feb 2016 16:38:38 -0700 Message-Id: <1456443528-13901-10-git-send-email-eblake@redhat.com> In-Reply-To: <1456443528-13901-1-git-send-email-eblake@redhat.com> References: <1456443528-13901-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Feb 2016 23:39:08 +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 v2 09/19] qapi: Drop useless 'data' member of unions 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=-1.9 required=5.0 tests=BAYES_00, 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 Now that we no longer have any clients of the 'void *data' member injected into unions, we can drop it. Update the testsuite to drop the negative test union-clash-data, and replace it with a positive test in qapi-schema-test that proves that we no longer have a name collision. Signed-off-by: Eric Blake Reviewed-by: Daniel P. Berrange --- v2: add R-b v1: drop patch that forced :empty as base to all structs Previously posted as part of qapi cleanup subset F: v6: rebase to earlier changes --- scripts/qapi-types.py | 9 --------- tests/Makefile | 1 - tests/qapi-schema/qapi-schema-test.json | 2 +- tests/qapi-schema/qapi-schema-test.out | 4 ++-- tests/qapi-schema/union-clash-data.err | 0 tests/qapi-schema/union-clash-data.exit | 1 - tests/qapi-schema/union-clash-data.json | 7 ------- tests/qapi-schema/union-clash-data.out | 9 --------- 8 files changed, 3 insertions(+), 30 deletions(-) delete mode 100644 tests/qapi-schema/union-clash-data.err delete mode 100644 tests/qapi-schema/union-clash-data.exit delete mode 100644 tests/qapi-schema/union-clash-data.json delete mode 100644 tests/qapi-schema/union-clash-data.out diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 19d1fff..0306a88 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -116,17 +116,8 @@ static inline %(base)s *qapi_%(c_name)s_base(const %(c_name)s *obj) def gen_variants(variants): - # FIXME: What purpose does data serve, besides preventing a union that - # has a branch named 'data'? We use it in qapi-visit.py to decide - # whether to bypass the switch statement if visiting the discriminator - # failed; but since we 0-initialize structs, and cannot tell what - # branch of the union is in use if the discriminator is invalid, there - # should not be any data leaks even without a data pointer. Or, if - # 'data' is merely added to guarantee we don't have an empty union, - # shouldn't we enforce that at .json parse time? ret = mcgen(''' union { /* union tag is @%(c_name)s */ - void *data; ''', c_name=c_name(variants.tag_member.name)) diff --git a/tests/Makefile b/tests/Makefile index 04e34b5..cd4bbd4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -358,7 +358,6 @@ qapi-schema += unicode-str.json qapi-schema += union-base-no-discriminator.json qapi-schema += union-branch-case.json qapi-schema += union-clash-branches.json -qapi-schema += union-clash-data.json qapi-schema += union-empty.json qapi-schema += union-invalid-base.json qapi-schema += union-optional-branch.json diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index 632964a..b5d0c53 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -115,7 +115,7 @@ 'number': ['number'], 'boolean': ['bool'], 'string': ['str'], - 'sizes': ['size'], + 'data': ['size'], 'any': ['any'] } } # testing commands diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index f5e2a73..225e2db 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -139,9 +139,9 @@ object UserDefNativeListUnion case number: :obj-numberList-wrapper case boolean: :obj-boolList-wrapper case string: :obj-strList-wrapper - case sizes: :obj-sizeList-wrapper + case data: :obj-sizeList-wrapper case any: :obj-anyList-wrapper -enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8', 'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'sizes', 'any'] +enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8', 'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'data', 'any'] object UserDefOne base UserDefZero member string: str optional=False diff --git a/tests/qapi-schema/union-clash-data.err b/tests/qapi-schema/union-clash-data.err deleted file mode 100644 index e69de29..0000000 diff --git a/tests/qapi-schema/union-clash-data.exit b/tests/qapi-schema/union-clash-data.exit deleted file mode 100644 index 573541a..0000000 --- a/tests/qapi-schema/union-clash-data.exit +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/qapi-schema/union-clash-data.json b/tests/qapi-schema/union-clash-data.json deleted file mode 100644 index 7308e69..0000000 --- a/tests/qapi-schema/union-clash-data.json +++ /dev/null @@ -1,7 +0,0 @@ -# Union branch 'data' -# FIXME: this parses, but then fails to compile due to a duplicate 'data' -# (one from the branch name, another as a filler to avoid an empty union). -# we should either detect the collision at parse time, or change the -# generated struct to allow this to compile. -{ 'union': 'TestUnion', - 'data': { 'data': 'int' } } diff --git a/tests/qapi-schema/union-clash-data.out b/tests/qapi-schema/union-clash-data.out deleted file mode 100644 index f5752f4..0000000 --- a/tests/qapi-schema/union-clash-data.out +++ /dev/null @@ -1,9 +0,0 @@ -object :empty -object :obj-int-wrapper - member data: int optional=False -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool'] - prefix QTYPE -object TestUnion - member type: TestUnionKind optional=False - case data: :obj-int-wrapper -enum TestUnionKind ['data']