Received: from eggs.gnu.org ([2001:4830:134:3::10]:37043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWgU2-0003LF-Rt for qemu-devel@nongnu.org; Fri, 19 Feb 2016 03:32:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWgTz-0001uY-MO for qemu-devel@nongnu.org; Fri, 19 Feb 2016 03:32:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWgTz-0001uS-Gu for qemu-devel@nongnu.org; Fri, 19 Feb 2016 03:32:11 -0500 From: 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> <56C62579.40809@redhat.com> Date: Fri, 19 Feb 2016 09:32:08 +0100 In-Reply-To: <56C62579.40809@redhat.com> (Eric Blake's message of "Thu, 18 Feb 2016 13:11:37 -0700") Message-ID: <87twl5umlz.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v11 03/15] qapi: Forbid 'any' inside an alternate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Michael Roth Eric Blake writes: > 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: > > 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 > > > 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. Makes sense. I was just making sure I understand how this works. Thanks!