From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPAjl-0006HE-TF for qemu-devel@nongnu.org; Fri, 29 Jan 2016 10:13:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPAjk-000062-GZ for qemu-devel@nongnu.org; Fri, 29 Jan 2016 10:13:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34710) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPAjk-00005s-90 for qemu-devel@nongnu.org; Fri, 29 Jan 2016 10:13:24 -0500 References: <1453219845-30939-1-git-send-email-eblake@redhat.com> <1453219845-30939-36-git-send-email-eblake@redhat.com> <87h9hxiv66.fsf@blackfin.pond.sub.org> <56AA4A4A.60703@redhat.com> <87lh78a8zk.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <56AB8192.6060807@redhat.com> Date: Fri, 29 Jan 2016 08:13:22 -0700 MIME-Version: 1.0 In-Reply-To: <87lh78a8zk.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kQBwechX33xO4XQuJGLvrwGomCuDbdl0F" Subject: Re: [Qemu-devel] [PATCH v9 35/37] qapi: Change visit_type_FOO() to no longer return partial objects List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --kQBwechX33xO4XQuJGLvrwGomCuDbdl0F Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/29/2016 05:03 AM, Markus Armbruster wrote: >=20 > With (1) don't assign, the caller can pick an error value by assigning > it before the visit, and it must not access the value on error unless i= t > does. >=20 > With (2) assign zero, the caller can't pick an error value, but may > safely access the value even on error. >=20 > Tradeoff. I figure either can work for us. >=20 >>> (3) Assign null pointer, else don't assign anything >>> >>> CON: inconsistent >>> CON: mix of (1)'s and (2)'s CON >> >> Which I think is what I did in this patch. >=20 > I don't like the inconsistency. It complicates the interface. I'll go ahead and audit to see whether more scalar visits were relying on (1) and would have to be rewritten to use style (2); vs. whether more pointer visits were passing in uninitialized obj and would have to be rewritten to use style (1). > I think behavior (1) don't assign and (2) assign zero both work, we jus= t > have to pick one and run with it. >=20 > If we pick behavior (1) don't assign, then we should assert something > like !obj || !*obj on entry. With such assertions in place, I think (1= ) > should be roughly as safe as (2). I think your assessment is right, and it's now just a matter of seeing which way to get to a consistent state is less effort (I may still end up doing both ways as competing patches, for comparison purposes). > or maybe returns whether something was allocated: >=20 > out_obj: > if (visit_end_struct(v) && err) { > qapi_free_T(*obj); > } I'm liking that. Dealloc and output visitors always return false, and input visitors may need to track something on their stack for whether they allocated or returned error earlier on, but it results in less generated output. Basically, it's lowering the 'bool allocated' that I added in this attempt out of the generated code and into the visitors. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --kQBwechX33xO4XQuJGLvrwGomCuDbdl0F 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/ iQEcBAEBCAAGBQJWq4GTAAoJEKeha0olJ0NquPUH/RZzmHUW86M73a9H7YpxlOTT u7FHT/qjGRRwpIsKHh+zTD9xYNKEjZPkSLULsS2zz2131UZtX3CH4pKTsHdWUQW/ QQzpYATLffV+b6NyDgOHg7I1JM967+i7/zPbKSLIxTnaG4q+xU2raLYSP/suJTmi Gq82hPLouVvhX80EBr//GtLiUoB+54Uiqx8DAQ8q9Xv06QlvsmP10YArDvyEtUwj 2H6ZHScThZoHCIq6GYuz0QtXsxgIwvHAFTOSS6wrJIdmO/qchCLrm40hJ//cUMjw oYSR5EIdc8AaSgigzzv8wEeYRlFmMEZNfpxGpNR5oDs+AgaJbHxMv69B+G3Df8M= =UUTe -----END PGP SIGNATURE----- --kQBwechX33xO4XQuJGLvrwGomCuDbdl0F--