From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4sRQ-0001of-O5 for qemu-devel@nongnu.org; Tue, 16 Jun 2015 11:06:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4sRM-0003Ek-JH for qemu-devel@nongnu.org; Tue, 16 Jun 2015 11:06:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4sRM-0003EY-CG for qemu-devel@nongnu.org; Tue, 16 Jun 2015 11:06:16 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 0E450C1F71 for ; Tue, 16 Jun 2015 15:06:16 +0000 (UTC) Message-ID: <55803B66.5000300@redhat.com> Date: Tue, 16 Jun 2015 09:06:14 -0600 From: Eric Blake MIME-Version: 1.0 References: <1434458200-23440-1-git-send-email-mst@redhat.com> <1434458200-23440-3-git-send-email-mst@redhat.com> In-Reply-To: <1434458200-23440-3-git-send-email-mst@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Pjkh8FDc2nAr36GXIUeCTV4nJgO4XgFsg" Subject: Re: [Qemu-devel] [PATCH RFC 2/3] error: allow local errors to trigger abort List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, dgilbert@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Pjkh8FDc2nAr36GXIUeCTV4nJgO4XgFsg Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/16/2015 06:53 AM, Michael S. Tsirkin wrote: > It's a common idiom: >=20 > Error *local_err =3D NULL; > .... > foo(&local_err); > ... > if (local_err) { > error_propagate(errp, local_err); > return; > } >=20 > Unfortunately it means that call to foo(&local_err) will > not abort even if errp is set to error_abort. >=20 > Instead, we get an abort at error_propagate which is too late. That is, the quality of the stack trace is degraded in that it no longer pinpoints the actual cause of failure. >=20 > To fix, add an API to check errp and set local_err to error_abort > if errp is error_abort. >=20 > Signed-off-by: Michael S. Tsirkin > --- > include/qapi/error.h | 5 +++++ > util/error.c | 5 +++++ > 2 files changed, 10 insertions(+) I like the idea. > +++ b/util/error.c > @@ -28,6 +28,11 @@ static bool error_is_abort(Error **errp) > return errp && *errp && (*errp)->err_class =3D=3D ERROR_CLASS_MAX;= > } > =20 > +Error *error_init_local(Error **errp) > +{ > + return error_is_abort(errp) ? *errp : NULL; What you have works, but see also my ideas in my (latest) reply to 1/3 where you could use pointer equality on error_abort (rather than on &error_abort) as the key factor. After all, the way you have implemented things so far, when taking the *errp branch, you are still effectively returning the error_abort global pointer (you haven't yet used anything that required struct copying of the contents of error_abort= ). Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Pjkh8FDc2nAr36GXIUeCTV4nJgO4XgFsg 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/ iQEcBAEBCAAGBQJVgDtnAAoJEKeha0olJ0NqqpoH/1FT9iseW5ZocpP2Y3tUFCJt 0C5y1BTDLbOTwOx5nCB2Jh0PThlisg/W03A6m1Ausn7QQnP6vZnCTijdD9GL1xzz r93JkD14Un7sHqkyB3ibC2YlCso2xV0UoC8zerVg5/35qTDntQiatXpo3fypNAgE RRfP9jVkNy1+NhtadjJhpAbJcqPXIQrQdPbvM1fFlsbqaAvtl3S0qIY23k0WoZqa hThGTlVIyqxVKTaMKUETzv/FZ0dO9fMKLSZhtxck5g2en1rNM3Lf95Szrv3v4NLG +CHthOzMuFNvwxExFHtYlDO7oaqaUvNszwpWmH65FpaU9qPFjcru1+qXxtGBcqg= =mbCf -----END PGP SIGNATURE----- --Pjkh8FDc2nAr36GXIUeCTV4nJgO4XgFsg--