From patchwork Thu Feb 18 20:11:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8354191 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 CC88C9F38B for ; Thu, 18 Feb 2016 20:17:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 644B220382 for ; Thu, 18 Feb 2016 20:17:28 +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 5437420138 for ; Thu, 18 Feb 2016 20:17:27 +0000 (UTC) Received: from localhost ([::1]:45186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWV0w-0002Ed-NI for patchwork-qemu-devel@patchwork.kernel.org; Thu, 18 Feb 2016 15:17:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWUvQ-0001qw-Gk for qemu-devel@nongnu.org; Thu, 18 Feb 2016 15:11:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWUvK-0002XP-HX for qemu-devel@nongnu.org; Thu, 18 Feb 2016 15:11:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53355) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWUvK-0002XB-9y for qemu-devel@nongnu.org; Thu, 18 Feb 2016 15:11:38 -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 EBCE08F4FE; Thu, 18 Feb 2016 20:11:37 +0000 (UTC) Received: from [10.3.113.75] (ovpn-113-75.phx2.redhat.com [10.3.113.75]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1IKBbJr019227; Thu, 18 Feb 2016 15:11:37 -0500 To: Markus Armbruster References: <1455778109-6278-1-git-send-email-eblake@redhat.com> <1455778109-6278-4-git-send-email-eblake@redhat.com> <87si0qgr5u.fsf@blackfin.pond.sub.org> <56C5D7C8.1020701@redhat.com> <87povu7xyu.fsf@blackfin.pond.sub.org> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <56C62579.40809@redhat.com> Date: Thu, 18 Feb 2016 13:11:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <87povu7xyu.fsf@blackfin.pond.sub.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, Michael Roth Subject: Re: [Qemu-devel] [PATCH v11 03/15] qapi: Forbid 'any' inside an alternate 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 On 02/18/2016 10:03 AM, Markus Armbruster wrote: >>> Could use a test for alternate member of alternate type. >> >> One step ahead of you: commit 3d0c4829 added the test >> alternate-nested.json, and commits 44bd1276 and dd883c6f fixed the >> parser to reject it (first by a hard-coded check, then via allow_metas[] >> excluding alternates). 'any' is the only value that could sneak >> through, because it is a subset of 'built-in' which allow_metas[] >> whitelisted. > > Then find_alternate_member_qtype()'s final return None is unreachable, > correct? Indeed, the testsuite still passes with: That said, even though we currently filter out unknown types before deciding to call find_alternate_member_qtype, it's not out of the question that future work to move ad hoc front-end tests into formal QAPISchema .check() methods may cause us to call find_alternate_member_qtype('unknown'). Leaving it as return None instead of asserting would make the error message added in this patch nicer. Then again, refactoring would move the error message of this patch to the .check() methods. So I won't worry about it for now. diff --git i/scripts/qapi.py w/scripts/qapi.py index 8497777..81d435f 100644 --- i/scripts/qapi.py +++ w/scripts/qapi.py @@ -345,7 +345,7 @@ def find_alternate_member_qtype(qapi_type): return "QTYPE_QSTRING" elif find_union(qapi_type): return "QTYPE_QDICT" - return None + assert False # Return the discriminator enum define if discriminator is specified as an