From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKww5-0006QJ-Ac for qemu-devel@nongnu.org; Thu, 30 Jul 2015 19:08:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKww0-0004d5-B1 for qemu-devel@nongnu.org; Thu, 30 Jul 2015 19:08:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKww0-0004cu-5j for qemu-devel@nongnu.org; Thu, 30 Jul 2015 19:08:20 -0400 References: <1435782155-31412-1-git-send-email-armbru@redhat.com> <1435782155-31412-8-git-send-email-armbru@redhat.com> <55B7E15D.50902@redhat.com> <87lhdzju4i.fsf@blackfin.pond.sub.org> <55B93445.9060104@redhat.com> <87io923ysb.fsf@blackfin.pond.sub.org> <55BA3157.2070806@redhat.com> <87zj2dy7ik.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <55BAAE5F.2090904@redhat.com> Date: Thu, 30 Jul 2015 17:08:15 -0600 MIME-Version: 1.0 In-Reply-To: <87zj2dy7ik.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fBDIf31Ks32wnNEScU1nJkb9L7AmwNslK" Subject: Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --fBDIf31Ks32wnNEScU1nJkb9L7AmwNslK Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/30/2015 09:44 AM, Markus Armbruster wrote: >>>> which means that if we name any of the branches 'data' (that is, if >>>> 'data' is a member of the enum discriminator), things fail to compil= e. >>>> We could probably fix that by naming our dummy branch '_data'. >>> >>> I wonder whether member data is actually used. I'll find out. >> >> The dealloc visitor uses 'data' being non-null as a flag on whether to= >> deallocate the union even if the tag was invalid for some reason; or >> more importantly, if parsing consumed the tag but then detected an err= or >> while parsing the union, leaving the union branch partially allocated.= >> To avoid a leak, we have to deallocate the branch. >> >> But if the tag was invalid, then why did we ever allocate the union in= >> the first place, and how do we prove we are calling the correct free-i= ng >> function? And if the tag is valid, why can't we just guarantee that t= he >> union is 0-initialized and that deleting the branch will work through >> the correct branch type instead of worrying about 'data'? >=20 > Good questions. Someone will have to review and fix this code. Let's > add a FIXME so we don't forget. Care to propose one? Sure; see 12.6/47 (since that is close to several other patches adding FIXME comments). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --fBDIf31Ks32wnNEScU1nJkb9L7AmwNslK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVuq5fAAoJEKeha0olJ0NquMgH/3ChdCcVyMu6E2R59MXsvLem jBDeKxZb/aqjLnYm/djWKKPoHCylEIzmHRxTIH9F7c9Ihcr3tAjzLQv94DX1V8tu aAxLOgPdKlzF6kT9Fs7AeyYP2ZvJ4TqDIu64Rps5PH/0LhBcdJy+L8wCS0XWA23u 3KmKMwxbmPl5jmGEOX+QHoH3vktpTZ2X6Az4hx5gyPG2d5c3+NqT8OkipzcwgdZ2 5R9F0nkTaR/WKGGqeEvxmT1D+WwIi9cj9XKs7AO/kgLHNsnNIOAS0pH/pMtPVvoA 1aQzs5Fko1pfY18hZiFQhshR4Kvs+wtMOR2pduN0uLDa/mAWoHGyAxxtZYDwtQA= =OkPO -----END PGP SIGNATURE----- --fBDIf31Ks32wnNEScU1nJkb9L7AmwNslK--