From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGVwk-0004bm-GF for qemu-devel@nongnu.org; Tue, 05 Jan 2016 13:03:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aGVwf-000246-Gt for qemu-devel@nongnu.org; Tue, 05 Jan 2016 13:03:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGVwf-000242-8g for qemu-devel@nongnu.org; Tue, 05 Jan 2016 13:02:57 -0500 References: <1450717720-9627-1-git-send-email-eblake@redhat.com> <1450717720-9627-35-git-send-email-eblake@redhat.com> From: Eric Blake Message-ID: <568C0549.5050101@redhat.com> Date: Tue, 5 Jan 2016 11:02:49 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="SLbvjfn8E3RHHlALmG07qHWa6g0laRf65" Subject: Re: [Qemu-devel] [PATCH v8 34/35] qapi: Change visit_type_FOO() to no longer return partial objects List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= Cc: Michael Roth , QEMU , Markus Armbruster This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --SLbvjfn8E3RHHlALmG07qHWa6g0laRf65 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/05/2016 10:22 AM, Marc-Andr=C3=A9 Lureau wrote: > Hi >=20 > On Mon, Dec 21, 2015 at 6:08 PM, Eric Blake wrote: >> Returning a partial object on error is an invitation for a careless >> caller to leak memory. As no one outside the testsuite was actually >> relying on these semantics, it is cleaner to just document and >> guarantee that ALL pointer-based visit_type_FOO() functions always >> leave a safe value in *obj during an input visitor (either the new >> object on success, or NULL if an error is encountered). >> >> Since input visitors have blind assignment semantics, we have to >> track the result of whether an assignment is made all the way down >> to each visitor callback implementation, to avoid making decisions >> based on potentially uninitialized storage. >> >> Note that we still leave *obj unchanged after a scalar-based >> visit_type_FOO(); I did not feel like auditing all uses of >> visit_type_Enum() to see if the callers would tolerate a specific >> sentinel value (not to mention having to decide whether it would >> be better to use 0 or ENUM__MAX as that sentinel). >> >> Signed-off-by: Eric Blake >> >=20 > nice cleanup, few issues: >=20 >> @@ -237,6 +254,10 @@ void visit_type_str(Visitor *v, const char *name,= char **obj, Error **errp) >> } >> */ >> v->type_str(v, name, obj, errp); >> + if (!visit_is_output(v) && err) { >> + *obj =3D NULL; >> + } >=20 > This will always evelatute to false, you need to change the line above = I suppose >=20 >> + error_propagate(errp, err); Oh right, that needs to be v->type_str(..., &err). I'll have to double-check that no assertions trigger with the fixed code, and provide the fixup patch. I don't know if Markus will want me to spin a v9, but I'll wait for his comments before deciding if a full respin is needed. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --SLbvjfn8E3RHHlALmG07qHWa6g0laRf65 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/ iQEcBAEBCAAGBQJWjAVJAAoJEKeha0olJ0Nqw8IH/3SBzHmpW8mDwD/ib5OvHFNA wWhuNNEIk8R9GKqfXiwa6b0f7JfDPAEh9qGoNp7HwCRBjPF7VkX9S9OakUEsA+vE gqRrNev/SUPbV8VGI3TKOnkJon6b9g7W0YPMlESZf2U8f2LQP1sWSLwGfJ0AOw1w 8AWtVPMLSf1Dj3gfq2l7DQY+WvZYTkNpxcLR7CJ2a9R1PctZ8hGgYrPsn5qGoSGJ hJnxSAcBumyG0nq78uwjXm2bcMx+en7ifaZdlMQYhskShjIM+QAlkob4FbX+7tY4 Gvffz9PpFCX10Q+pl7dIrxK5gIeaWPQnEga+gD55Lq3knAjo0+n9H7zWDxTLZOM= =1Zhw -----END PGP SIGNATURE----- --SLbvjfn8E3RHHlALmG07qHWa6g0laRf65--