Received: from eggs.gnu.org ([2001:4830:134:3::10]:35821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS6Yi-00078S-2S for qemu-devel@nongnu.org; Tue, 26 Jul 2016 13:54:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bS6Yg-0007Cn-2n for qemu-devel@nongnu.org; Tue, 26 Jul 2016 13:54:23 -0400 References: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> <1469532873-78542-1-git-send-email-pasic@linux.vnet.ibm.com> <7c4bdb1e-f0aa-4a07-2780-37f4f92c6665@redhat.com> <57979B63.1060505@linux.vnet.ibm.com> From: Max Reitz Message-ID: <5fd0b60a-4d31-d949-9f9b-934b228b2e4e@redhat.com> Date: Tue, 26 Jul 2016 19:54:13 +0200 MIME-Version: 1.0 In-Reply-To: <57979B63.1060505@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lUwuNajPBCS5T2ac7Psu82xV0pEkxe8LR" Subject: Re: [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Halil Pasic , qemu-block@nongnu.org Cc: Kevin Wolf , Cornelia Huck , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --lUwuNajPBCS5T2ac7Psu82xV0pEkxe8LR From: Max Reitz To: Halil Pasic , qemu-block@nongnu.org Cc: Kevin Wolf , Cornelia Huck , qemu-devel@nongnu.org Message-ID: <5fd0b60a-4d31-d949-9f9b-934b228b2e4e@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open References: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> <1469532873-78542-1-git-send-email-pasic@linux.vnet.ibm.com> <7c4bdb1e-f0aa-4a07-2780-37f4f92c6665@redhat.com> <57979B63.1060505@linux.vnet.ibm.com> In-Reply-To: <57979B63.1060505@linux.vnet.ibm.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 26.07.2016 19:18, Halil Pasic wrote: >=20 >=20 > On 07/26/2016 05:42 PM, Max Reitz wrote: >>> +++ b/block/raw-posix.c >>>> @@ -485,6 +485,7 @@ static int raw_open_common(BlockDriverState *bs,= QDict *options, >>>> s->fd =3D -1; >>>> fd =3D qemu_open(filename, s->open_flags, 0644); >>>> if (fd < 0) { >>>> + error_setg_errno(errp, errno, "Could not open file"); >> We don't guarantee that error_setg_errno() does not modify errno. (In >> practice it should not, but we don't guarantee that.) >> >=20 >=20 > Thank you very much for your review. I have double checked, and I > remembered correctly: error_setg_errno saves and restores the original > errno, so that is why I assumed it does not.=20 Oh, and about this: Yes, I remember, this was introduced after we had noticed that we had some old code that assumed that error_setg() would not modify errno. We had to decide between making error_setg*() save and restore errno (which we deemed a bit ugly) and fixing all of that old code (which we deemed hard). So we want for the former, but I don't think we actually guarantee that behavior (because you should never rely on any function not to modify errno). (The difference between us saving/restoring errno in practice and guaranteeing that feature is the lack of documentation thereof, i.e., the comment for error_setg() in include/qapi/error.h doesn't mention this :-)) Max --lUwuNajPBCS5T2ac7Psu82xV0pEkxe8LR 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 iQEvBAEBCAAZBQJXl6PFEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6DisrZQm B/9nrYlpF8ORlUNk9xWAnWwAWLarb4f7XvLSaBIR6tqLBmcPxcN1fdFlfr/UWeNL i8K4lK9MBSKiFoS6LZmTiCE5Gxc0BQOKuu3czLLt93NF4l2JpgqtBxoYuoOYmHZ3 UZfq2u4fIs1oK+33Mg2FQOuRWNgUe4cbvGFROGfFj/TSzz2FwcEVoq8Y6XCmsngQ cdi5o7Vgt3LN3i1ZTGxE5E95VGLfWNUZhK5413/QVRWtxYUpiw4xdXMP+ccAVcJk AFZDHpMbuz8AEgohSh2z5uxj6ClYnA+rSa7AwJqDa8qNlqBWHC508dZ92HK/C84G r5k+1XV/dpdG22hSmmprihSm =R7DO -----END PGP SIGNATURE----- --lUwuNajPBCS5T2ac7Psu82xV0pEkxe8LR--