From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSmk5-0000Oc-4l for qemu-devel@nongnu.org; Thu, 28 Jul 2016 10:56:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSmk2-0004Y2-CC for qemu-devel@nongnu.org; Thu, 28 Jul 2016 10:56:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34780) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSmk2-0004Xy-3J for qemu-devel@nongnu.org; Thu, 28 Jul 2016 10:56:54 -0400 References: <1469611466-31574-1-git-send-email-silbe@linux.vnet.ibm.com> <57991CC1.40003@redhat.com> <87twfaysit.fsf@dusky.pond.sub.org> <5799E26B.7090408@linux.vnet.ibm.com> From: Eric Blake Message-ID: <579A1D33.6010500@redhat.com> Date: Thu, 28 Jul 2016 08:56:51 -0600 MIME-Version: 1.0 In-Reply-To: <5799E26B.7090408@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="34QDww5T6TG9gI2JiMWgHf1MHf6nKlRIQ" 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: Halil Pasic , Markus Armbruster Cc: Sascha Silbe , qemu-devel@nongnu.org, Kevin Wolf , Michael Roth , Cornelia Huck , Max Reitz This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --34QDww5T6TG9gI2JiMWgHf1MHf6nKlRIQ From: Eric Blake To: Halil Pasic , Markus Armbruster Cc: Sascha Silbe , qemu-devel@nongnu.org, Kevin Wolf , Michael Roth , Cornelia Huck , Max Reitz Message-ID: <579A1D33.6010500@redhat.com> Subject: Re: [Qemu-devel] [PATCH] error: error_setg_errno(): errno gets preserved References: <1469611466-31574-1-git-send-email-silbe@linux.vnet.ibm.com> <57991CC1.40003@redhat.com> <87twfaysit.fsf@dusky.pond.sub.org> <5799E26B.7090408@linux.vnet.ibm.com> In-Reply-To: <5799E26B.7090408@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/28/2016 04:46 AM, Halil Pasic wrote: > The implementation of preserve errno seems inconsistent to me. The > function error_setv is static, and I guess it is supposed to provide > this indirect errno preservation and is used for both error_setg und > error_setg_errno, yet error_setg_ errno_internal does extra save-restor= e > itself while error_setg_iternal relies on 'indirect', what is not OK in= > my opinion. As long as errno gets saved where it is documented as saved, I don't care whether it is direct or indirect (indirect is probably more efficient, where we can prove that nothing is called that is allowed to clobber errno). >=20 > As Sascha pointed out, in C11 any library functions may change errno > unless explicitly told otherwise for the particular function. Since > start_va and end_va has nothing on preserving errno it is guaranteed by= > the standard that they persevere errno, and we should assume they don't= =2E You mean va_start, not start_va. And actually, C11 is clear that errno is unspecified after library functions (but not macros) that don't explicitly state otherwise. Since va_start() is a macro and not a library function, that means va_start does NOT have carte blanche permission to modify errno. For more reading on the topic: http://austingroupbugs.net/view.php?id=3D384 There are several related POSIX bug reports of other functions that have been requested to explicitly document that they don't modify errno, and I'm happy to submit even more, if we find other standard interfaces whose semantics are easier when they guarantee that errno is not clobbere= d. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --34QDww5T6TG9gI2JiMWgHf1MHf6nKlRIQ 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/ iQEcBAEBCAAGBQJXmh00AAoJEKeha0olJ0NqjdMIAKgLOlO6dOlIeAuul2wwbRHO tdPMhBcIiv36PxgWDYp8VaeCTe+bXjLnsW+B83mBdnkOo6djGDMZpiNQwk8nf+6u IuqL76WzcoGl40FseeN2eTZnS1C7DvOgwPzS3Sqw+agpIWvjF854ZLN0kVV1pprd rregEFtXP+cHr/dSwoB+wjbVqXs4EGJCt+ehgxqPdkaYPdifMC5ZWImqyM1pElkK 5kZUZ7sndeC8fyDSLPdBzaW6dIZ1skvDQJZijCd9nD0gmLJHYE1YJfSDDxdjQbuo KpPpm8Uha2eMQhd+DwozYdzne57f3jJY2NyOOd7NAFknEJQueyugqhRpx3dsrgY= =Ssfd -----END PGP SIGNATURE----- --34QDww5T6TG9gI2JiMWgHf1MHf6nKlRIQ--