From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfxDb-0007Oq-Dd for qemu-devel@nongnu.org; Sat, 26 Sep 2015 17:41:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfxDY-00061f-7t for qemu-devel@nongnu.org; Sat, 26 Sep 2015 17:41:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46684) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfxDX-00060m-W0 for qemu-devel@nongnu.org; Sat, 26 Sep 2015 17:41:16 -0400 References: <1442872682-6523-1-git-send-email-eblake@redhat.com> <1442872682-6523-8-git-send-email-eblake@redhat.com> <87r3lneuet.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <560710F4.40003@redhat.com> Date: Sat, 26 Sep 2015 15:41:08 -0600 MIME-Version: 1.0 In-Reply-To: <87r3lneuet.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pcJ4MHBciRsww17d6W7fS3VG8vpmgHD8M" Subject: Re: [Qemu-devel] [PATCH v5 07/46] qapi: Don't pass pre-existing error to later call List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: marcandre.lureau@redhat.com, DirtY.iCE.hu@gmail.com, qemu-devel@nongnu.org, ehabkost@redhat.com, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pcJ4MHBciRsww17d6W7fS3VG8vpmgHD8M Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/24/2015 08:58 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> Due to the existing semantics of the error_set() family, >> generated sequences in the qapi visitors such as: >> >> visit_start_implicit_struct(m, (void **)obj, sizeof(FOO), &err); >> if (!err) { >> visit_type_FOO_fields(m, obj, errp); >> visit_end_implicit_struct(m, &err); >> } >> error_propagate(errp, err); >=20 > Indentation seems off. Intentional? >=20 >> >> are risky: if visit_type_FOO_fields() sets errp, and then >> visit_end_implicit_struct() also encounters an error, the >> attempt to overwrite the first error will cause an abort(). I didn't even read error_propagate()'s contract correctly. It specifically specifies that if errp is already set, then err is ignored. So the above sequence is actually just fine, because only the following paths exist: visit_start_implicit_struct() fails into &err, error_propagate() passes err into caller's errp visit_start_implicit_struct() succeeds, visit_type_FOO_fields() fails into caller's errp, visit_end_implicit_struct() succeeds, error_propagate() does nothing visit_start_implicit_struct() succeeds, visit_type_FOO_fields() fails into caller's errp, visit_end_implicit_struct() fails int &err, error_propagate() does nothing (errp trumps err) visit_start_implicit_struct() succeeds, visit_type_FOO_fields() succeeds, visit_end_implicit_struct() fails int &err, error_propagate() passes err into caller's errp visit_start_implicit_struct() succeeds, visit_type_FOO_fields() succeeds, visit_end_implicit_struct() succeeds, error_propagate() does nothing As such, I'm revisiting if anything is needed at all, other than making the various visit_start/visit_end patterns consistent with one another using existing idioms, and it may turn out we don't need the ternary after all. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --pcJ4MHBciRsww17d6W7fS3VG8vpmgHD8M 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/ iQEcBAEBCAAGBQJWBxD0AAoJEKeha0olJ0NqdX8H/2yKEcq8DdYVS/X+GuPTKEOB sYLdwMl721bLNJtgUSEAOg2M2yrOinX9YcrWbBObAaAv3JsKM5c0qgef91RYYXX4 RsaZiOuR0EJiWOakNyJtq+GM5BVrN6LjW3G02o0zqXzPBInNlWPe0hYNBlo8nnDk kSL9obqOGPQl49Z84EkVizaOzBeByT4AcL6aGhf/NJ9uf/zGrtiOiV1fBPMRMer0 wvDzWq6HdAtTztxNNbpm5UfFKK9E4DGeTZQAPOlq9FuIPr0iigb40fkwGlMrNReB /ytXwXNuBnLDQApa6hOOhkGmcdY0XH5NklLWoBO9yI+h3FC9cyZLAR+8b9OiyHI= =VBxc -----END PGP SIGNATURE----- --pcJ4MHBciRsww17d6W7fS3VG8vpmgHD8M--