From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXvSP-0005gR-9r for qemu-devel@nongnu.org; Wed, 09 Apr 2014 12:34:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXvSK-0004Cw-7S for qemu-devel@nongnu.org; Wed, 09 Apr 2014 12:34:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXvSJ-0004Cm-UV for qemu-devel@nongnu.org; Wed, 09 Apr 2014 12:34:32 -0400 Message-ID: <53457690.8010009@redhat.com> Date: Wed, 09 Apr 2014 10:34:24 -0600 From: Eric Blake MIME-Version: 1.0 References: <871tx6zeoz.fsf@blackfin.pond.sub.org> In-Reply-To: <871tx6zeoz.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vvMIeLxHoI8xoh59JfGjUeiVm5E0HKPBe" Subject: Re: [Qemu-devel] Error propagation in generated visitors and command marshallers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: Paolo Bonzini , Luiz Capitulino , Michael Roth , Anthony Liguori , Cole Robinson This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vvMIeLxHoI8xoh59JfGjUeiVm5E0HKPBe Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 04/09/2014 09:48 AM, Markus Armbruster wrote: > I stumbled over this while trying to purge error_is_set() from the code= =2E >=20 > But: is it a good idea to have both patterns in the code? Should we > perhaps use the common pattern for visiting, too? Like this: >=20 > visit_type_str(v, &foo, "foo", &err); > if (err) { > goto out; > } > visit_type_str(v, &bar, "bar", &err); > if (err) { > goto out; > } >=20 > Then we can assume *errp is clear on function entry, like this: >=20 > void visit_type_str(Visitor *v, char **obj, const char *name, Error= **errp) > { > v->type_str(v, obj, name, errp); > } >=20 > Should execute roughly the same number of conditional branches. >=20 > Tedious repetition of "if (err) goto out" in the caller, but that's wha= t > we do elsewhere, and unlike elsewhere, these one's are generated. >=20 > Opinions? Putting the tedium into the generated code is WHY we have generated code; so that the rest of the code that is hand-written can be concise. I like this latter idea of letting the visitors assume that errp is clean on entry with the caller responsible for checking err after each st= ep. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --vvMIeLxHoI8xoh59JfGjUeiVm5E0HKPBe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTRXaQAAoJEKeha0olJ0NqfUAH/A5LFpC+l4bCanId4oRi9GU1 jiU8s7DtnUQzsIXiMc/DuWE+8+aTSqBntq9+hKib3VSCRfPrzewlWxa2xFLAYbdl swC6EJuTMNzNQw6RQdDqE9iKVD+G54mAeqXdhs6dvQqPBth5fMpuH3eVyzk8trIL 2KLnuX1pBnQx/dmbc2C1MiyBZJHXmC9YE//awFf6P7AbzrmcoQ86ZWNo9Ro7JZaT Odp+fC54LC6FCAR3YJE/rfHrhITWAbOzd9NVCtiuf/UXFBlHA63G3wkazluVzH6I SGohHFBeaL4RYU2Ve1VEq6YafZEQxit/OgA3yWWancneOYWxPvTT2VeDmujthzY= =IGJQ -----END PGP SIGNATURE----- --vvMIeLxHoI8xoh59JfGjUeiVm5E0HKPBe--