From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSVfF-0007Pz-CP for qemu-devel@nongnu.org; Wed, 27 Jul 2016 16:42:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSVfA-0005f2-8k for qemu-devel@nongnu.org; Wed, 27 Jul 2016 16:42:48 -0400 Received: from resqmta-po-11v.sys.comcast.net ([2001:558:fe16:19:96:114:154:170]:46139 helo=resqmta-ch2-11v.sys.comcast.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSVfA-0005eD-1Y for qemu-devel@nongnu.org; Wed, 27 Jul 2016 16:42:44 -0400 References: <1469611466-31574-1-git-send-email-silbe@linux.vnet.ibm.com> From: Eric Blake Message-ID: <57991CC1.40003@redhat.com> Date: Wed, 27 Jul 2016 14:42:41 -0600 MIME-Version: 1.0 In-Reply-To: <1469611466-31574-1-git-send-email-silbe@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GntvR2o1cHnX7dj8Nn3SbCmAI2A8iQS9R" Subject: Re: [Qemu-devel] [PATCH] error: error_setg_errno(): errno gets preserved List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sascha Silbe , qemu-devel@nongnu.org Cc: Markus Armbruster , Max Reitz , Halil Pasic , Kevin Wolf , Cornelia Huck , Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GntvR2o1cHnX7dj8Nn3SbCmAI2A8iQS9R From: Eric Blake To: Sascha Silbe , qemu-devel@nongnu.org Cc: Markus Armbruster , Max Reitz , Halil Pasic , Kevin Wolf , Cornelia Huck , Michael Roth Message-ID: <57991CC1.40003@redhat.com> Subject: Re: [PATCH] error: error_setg_errno(): errno gets preserved References: <1469611466-31574-1-git-send-email-silbe@linux.vnet.ibm.com> In-Reply-To: <1469611466-31574-1-git-send-email-silbe@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/27/2016 03:24 AM, Sascha Silbe wrote: > C11 allows errno to be clobbered by pretty much any library function > call, so in general callers need to take care to save errno before > calling other functions. >=20 > However, for error reporting functions this is rather awkward and can > make the code on the caller side more complicated than > necessary. error_setg_errno() already takes care of preserving errno > and some functions rely on that, so just promise that we continue to > do so in the future. >=20 > Signed-off-by: Sascha Silbe > --- >=20 > Alternative approach to "error: error_setg_errno(): errno may be > clobbered" [1]. I like this alternative better. > +++ b/include/qapi/error.h > @@ -170,6 +170,9 @@ void error_setg_internal(Error **errp, > * 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. > + * > + * The value of errno (which usually can get clobbered by almost any > + * function call) will be preserved. > */ > #define error_setg_errno(errp, os_error, fmt, ...) = \ > error_setg_errno_internal((errp), __FILE__, __LINE__, __func__, = \ Do we need/want to make the guarantee of preserving errno across any of the other functions and macros declared in error.h? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --GntvR2o1cHnX7dj8Nn3SbCmAI2A8iQS9R 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/ iQEcBAEBCAAGBQJXmRzBAAoJEKeha0olJ0Nq0wgIAI5P4qDMAzKSKejzbrFXaFmY ctgtYvHxhmcWo6yvkj58tGLsbf1OCTIYElWgx7WFeumHrU98ba38Uti7w7uQ+8Bw AiJRHGNkwQbfD1tuaHbzMJV/275YKKdCehLzmjW8Ah4ln77KWQ02cbNvjHU05Rw+ 4MY2nL6cpTe+aGO0R+c4onXljWE9n7Syehalqudm58tgDoMx/LQ/sK5VmDnKNYqu zgn2d6SF0durTXyuiyH+4TBTvJ+82wrX9gOHxshx66/1IVAewXB7jVRhqUgrEeuh 0De+KjJHkqL3zK3Y/llHvRu2LhJ/VlclA3WjRhE18uiKmkBcZ8xlk/2F9l+Nz6I= =gjSP -----END PGP SIGNATURE----- --GntvR2o1cHnX7dj8Nn3SbCmAI2A8iQS9R--