From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdmH3-0001SY-3B for qemu-devel@nongnu.org; Tue, 05 Nov 2013 14:26:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdmGy-0005zi-6d for qemu-devel@nongnu.org; Tue, 05 Nov 2013 14:26:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdmGx-0005zd-Ta for qemu-devel@nongnu.org; Tue, 05 Nov 2013 14:26:44 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA5JQhXR026079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 5 Nov 2013 14:26:43 -0500 Message-ID: <52794671.7000001@redhat.com> Date: Tue, 05 Nov 2013 12:26:41 -0700 From: Eric Blake MIME-Version: 1.0 References: <1383678213-2497-1-git-send-email-mreitz@redhat.com> In-Reply-To: <1383678213-2497-1-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cTV8fRQk9V9AxtgkVCFVlRegHisbsg0AM" Subject: Re: [Qemu-devel] [PATCH] block: Save errno before error_setg_errno List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --cTV8fRQk9V9AxtgkVCFVlRegHisbsg0AM Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/05/2013 12:03 PM, Max Reitz wrote: > error_setg_errno() may overwrite errno; therefore, its value should be > read before calling that function and not afterwards. >=20 > Signed-off-by: Max Reitz > --- > block.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Eric Blake Still, wouldn't it be easier to patch error_setg_errno (and friends) to guarantee that errno is unchanged on exit compared to its value on entrance, rather than having to audit for other mistakes like this? >=20 > diff --git a/block.c b/block.c > index 58efb5b..0e96a22 100644 > --- a/block.c > +++ b/block.c > @@ -1084,8 +1084,8 @@ int bdrv_open(BlockDriverState *bs, const char *f= ilename, QDict *options, > snprintf(backing_filename, sizeof(backing_filename), > "%s", filename); > } else if (!realpath(filename, backing_filename)) { > - error_setg_errno(errp, errno, "Could not resolve path '%s'= ", filename); > ret =3D -errno; > + error_setg_errno(errp, errno, "Could not resolve path '%s'= ", filename); > goto fail; > } > =20 >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --cTV8fRQk9V9AxtgkVCFVlRegHisbsg0AM 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.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSeUZxAAoJEKeha0olJ0NqfE8H/38iVDaGdw245a7YHw4bCqnN HjGOrwnXWoJFaAiapxDjikBl8CKCc4J8jcidgNHhSvaI7uL5wK8ljQC03HiWjPi3 O+0CMMgxbWRtE0Z7uhfPWJ1+UJF1+reE5c38E48LMApGBhE61YOtbIEqT/w1to6U e+rXjQ0NsJuSJxbUsjMpVpO2AvRT43NbkF2tdWhYx35z+1bRkyVRyY8IdfkUT+wl n/P8NMVOqMt5W5E5hVJ4IJjvoVou+SOYkELBDXShYzF59/TAX5noxiOQ5anvIv37 1bOzEoCtUYd2Soub7Fbio8ao6gPxL4PTrK9DpyROhmHcO++Zk/W1tJz9pMR0yys= =hsQD -----END PGP SIGNATURE----- --cTV8fRQk9V9AxtgkVCFVlRegHisbsg0AM--