From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS5Tv-0007QH-6y for qemu-devel@nongnu.org; Thu, 11 Sep 2014 10:36:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XS5Tn-0005GT-H7 for qemu-devel@nongnu.org; Thu, 11 Sep 2014 10:36:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS5Tn-0005Ft-9p for qemu-devel@nongnu.org; Thu, 11 Sep 2014 10:36:11 -0400 Message-ID: <5411B34E.2080202@redhat.com> Date: Thu, 11 Sep 2014 16:35:58 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1410352239-8705-1-git-send-email-famz@redhat.com> <54104BA9.4040308@redhat.com> <20140910150200.GA4883@fam-t430.nay.redhat.com> <54106F28.5080203@redhat.com> <20140911005328.GB2554@fam-t430.nay.redhat.com> <54112247.40303@redhat.com> <20140911043803.GA28795@fam-t430.nay.redhat.com> <20140911142649.32021.42205@loki> In-Reply-To: <20140911142649.32021.42205@loki> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] qapi: Fix crash with enum dealloc when kind is invalid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth , Fam Zheng , Eric Blake Cc: Kevin Wolf , Hu Tao , Markus Armbruster , qemu-devel@nongnu.org, Stefan Hajnoczi , Luiz Capitulino Il 11/09/2014 16:26, Michael Roth ha scritto: > Also, the .kind field of a QAPI Union type is something we generate for use > by the generated visitor code. In the case of an unspecified discriminator > we generated the enum type for that field internally. In the case where it's > specified, we use an existing enum instead... > > But nothing stops us from generating a new "shadow" enum in this case as well, > with the indexes/integer values of the corresponding strings shifted by one so > we can reserve the 0 index for _INVALID. I think we can reasonably expect that > nothing outside the generated code makes use of those integer values in this > special case, and don't have to change all enum types to make that work. But how would users fill in structs if you have to use a different enum? What about making adding visit_start_union/visit_end_union? visit_start_union can return false if the visit of the union has to be skipped. The dealloc visitor can skip it if the data field is NULL; everything else can just use a default implementation which always returns true. Paolo