Received: from eggs.gnu.org ([2001:4830:134:3::10]:38268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS6k9-0002tU-J7 for qemu-devel@nongnu.org; Tue, 26 Jul 2016 14:06:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bS6k8-0001L4-Mk for qemu-devel@nongnu.org; Tue, 26 Jul 2016 14:06:13 -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> <87eg6ge0oi.fsf@oc4731375738.ibm.com> From: Max Reitz Message-ID: Date: Tue, 26 Jul 2016 20:06:01 +0200 MIME-Version: 1.0 In-Reply-To: <87eg6ge0oi.fsf@oc4731375738.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Xgnhb6Ca4AVmtu7cPkvJqidWfcM6ReHwN" 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: Sascha Silbe , 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) --Xgnhb6Ca4AVmtu7cPkvJqidWfcM6ReHwN From: Max Reitz To: Sascha Silbe , Halil Pasic , qemu-block@nongnu.org Cc: Kevin Wolf , Cornelia Huck , qemu-devel@nongnu.org Message-ID: 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> <87eg6ge0oi.fsf@oc4731375738.ibm.com> In-Reply-To: <87eg6ge0oi.fsf@oc4731375738.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 26.07.2016 20:03, Sascha Silbe wrote: > Dear Max, >=20 > Max Reitz writes: >=20 >> We don't guarantee that error_setg_errno() does not modify errno. (In >> practice it should not, but we don't guarantee that.) >=20 > I agree it's a good general policy to _not_ rely on the callee > explicitly saving and restoring errno. Especially since C11 pretty much= > allows any "library function" (including e.g. va_start()) to clobber > errno... >=20 > In the case of error_setg_errno() it would be helpful to mention that i= n > the API docs. The current implementation goes out of its way to preserv= e > errno, so callers might come to rely on it. >=20 > So how about: >=20 > /* > * Just like error_setg(), with @os_error info added to the message. > * If @os_error is non-zero, ": " + strerror(os_error) is appended to > * the human-readable error message. > + * > + * Reminder: errno may get clobbered by almost any function call. If > + * you need the value of errno for another purpose, save it before > + * invoking error_setg_errno() (or any other function for that > + * matter). > */ > #define error_setg_errno(errp, os_error, fmt, ...) = \ > error_setg_errno_internal((errp), __FILE__, __LINE__, __func__, = \ > (os_error), (fmt), ## __VA_ARGS__) >=20 > (I can prepare a proper patch if you agree with the above.) Thanks, that sounds good to me. Max --Xgnhb6Ca4AVmtu7cPkvJqidWfcM6ReHwN 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 iQEvBAEBCAAZBQJXl6aKEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6DisrSYh B/4gUfLpR0X8F1FiBE91DsXLMRBZEj7Ew//kw7MwQwfRWmwQimlutMCvkMuqSc3N eMZCbl+DM6WPiVU57A3DnUFSDNNOJBaWhvMX41av3j8RaylpJ7p30/0Lz1K0tbnT zEKBRmCtRzhcNtevziLjXiVsszRkVCPRMmSvsNavJLd8+ommK5Ie6GViVPvAwhHG 5q2CO1vNOSam0be64kHK6OTRDkICrRwZ0PhMxHTkbek2xlaGl5TQ6gmzLfHV7gqI t3tCyECC4YMJaRHEmAniU81zXrMNP/Z6j6HAV5EsZw/lLD67Z23M5FE47n27FNH8 ZbgGsdzZ5W5QM21dnRHyHu7k =A9pB -----END PGP SIGNATURE----- --Xgnhb6Ca4AVmtu7cPkvJqidWfcM6ReHwN--