From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axZf6-0008WL-LP for qemu-devel@nongnu.org; Tue, 03 May 2016 08:42:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axZeu-0004FB-Sf for qemu-devel@nongnu.org; Tue, 03 May 2016 08:42:43 -0400 References: <1461903820-3092-1-git-send-email-eblake@redhat.com> <1461903820-3092-19-git-send-email-eblake@redhat.com> <87y47se2yy.fsf@dusky.pond.sub.org> <5727AB18.2010809@redhat.com> <87h9ef8ij5.fsf@dusky.pond.sub.org> From: Eric Blake Message-ID: <57289C91.9020203@redhat.com> Date: Tue, 3 May 2016 06:41:53 -0600 MIME-Version: 1.0 In-Reply-To: <87h9ef8ij5.fsf@dusky.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XaFU1l328JRepslqObSvUTLOuLAiwxTVd" Subject: Re: [Qemu-devel] [PATCH v3 18/18] qapi: Add parameter to visit_end_* List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , famz@redhat.com, Michael Roth , "open list:Block layer core" , "Michael S. Tsirkin" , Juan Quintela , qemu-devel@nongnu.org, Alexander Graf , "open list:sPAPR" , Amit Shah , Max Reitz , =?UTF-8?Q?Andreas_F=c3=a4rber?= , David Gibson This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --XaFU1l328JRepslqObSvUTLOuLAiwxTVd Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/03/2016 05:53 AM, Markus Armbruster wrote: > Okay, I'm confused. >=20 > Consider BlockdevRef, defined as >=20 > { 'alternate': 'BlockdevRef', > 'data': { 'definition': 'BlockdevOptions', > 'reference': 'str' } } >=20 > where BlockdevOptions is a (flat) union. Let's clone a BlockdevRef > holding a str. Sequence of calls: >=20 > qapi_BlockdevRef_clone(src) > qapi_clone_visitor_new(src) > // qcv->depth is now 0 > visit_type_BlockdevRef(v, NULL, &dst, &error_abort) > visit_start_alternate(v, NULL, &dst, > sizeof(BlockdevRef), true, &error_abo= rt) > qapi_clone_start_alternate(v, NULL, &dst, > sizeof(BlockdevRef), true, &error_abo= rt) so far, so good, > qapi_clone_start_struct(v, NULL, &dst, > sizeof(BlockdevRef), &error_abort) Not reached if it holds a string. qapi_clone_start_alternate() sets dst->type to QTYPE_QSTRING, but qapi_clone_start_struct() is only used for QTYPE_QDICT. > // does not increment qcv->depth > visit_type_str(v, NULL, &dst->u.references, &error_abort) > qapi_clone_type_str(v, NULL, &dst->u.references, &error_abo= rt) > assert(qcv->depth) // why does this hold? Either we call: visit_start_alternate() visit_start_struct(NULL) visit_end_struct() visit_end_alternate() or we elide the inner struct visit because the alternate's branch is scalar. Either way, we only need +1 to the depth over the entire alternate, because we only need 1 level of g_memdup() at the time we first enter the alternate. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --XaFU1l328JRepslqObSvUTLOuLAiwxTVd 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/ iQEcBAEBCAAGBQJXKJyRAAoJEKeha0olJ0Nq9vkH/3Km5HwsYZhKF9cIynzoKnFL BstqYBJRFkJL4YQ0h9RPPlfRCdsGbkQdxGhuEPJbjNpyGGF6nzFUOZGKJra7xbt6 2Zou92o5+1GRUEFdliil+YZ2DNj3d/m9Ji5qAbasGI7eQgP+OyA7Jgv8YGeMI9hb W4VsHjJVSF0IhC5JL/OkuWd0G0KrEyBQumfW2Nvs7LJoN0KM/eyCJIFU50NWmVDi wzS5+l2nool/X9c957RSsUZzfYaecm84um022nYmcTEvcjS/G4mURAmRrD2DaH0f NhJFXZV39Zadl8G1hu21XiVX8WlMXyeKfGAnEDc5A1S6VgZBuhfspD+g7YwEkXk= =vI56 -----END PGP SIGNATURE----- --XaFU1l328JRepslqObSvUTLOuLAiwxTVd--