From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xlycs-0000We-0x for qemu-devel@nongnu.org; Wed, 05 Nov 2014 06:19:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xlycn-0005vQ-2X for qemu-devel@nongnu.org; Wed, 05 Nov 2014 06:19:45 -0500 Message-ID: <545A07C6.1020001@redhat.com> Date: Wed, 05 Nov 2014 12:19:34 +0100 From: Eric Blake MIME-Version: 1.0 References: <1415174992-13246-1-git-send-email-syeon.hwang@samsung.com> <5459DBE1.30509@redhat.com> <545A0288.4010905@gnu.org> <545A05CC.4050109@redhat.com> In-Reply-To: <545A05CC.4050109@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="T9NIESscUjkrrMBxTAEJ50hgFQhmduHJ3" Subject: Re: [Qemu-devel] [PATCH] error: fixed error_set_errno() to deal with a negative type of os_error. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , Paolo Bonzini , SeokYeon Hwang , qemu-devel@nongnu.org Cc: paolo.bonzini@gmail.com, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --T9NIESscUjkrrMBxTAEJ50hgFQhmduHJ3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/05/2014 12:11 PM, Max Reitz wrote: >>>> + err->msg =3D g_strdup_printf("%s: %s", msg1, >>>> strerror(abs(os_errno))); >> I don't, we really should fix the callers. >=20 > Of course I understand, but this patch doesn't make matters worse, as > long as there are not systems which have negative values for errno POSIX requires all defined errno values to be positive; negative errno values are unambiguous as values that will cause strerror() to have to generate a message about an unknown value. > (which I think we generally assume not to exist throughout qemu). That'= s > why I'm fine with it. We should fix the callers but I don't see why we > shouldn't apply this patch as well. This patch is a bandaid; it makes it harder to find callers that need to be fixed. I'd almost argue the exact opposite - add an assert(os_errno > 0). Then we'd loudly break on broken callers, making them easier to fi= nd. >=20 > A similar issue already came up and led to commit b276d2499, where > callers of error_setg_errno() assumed that it would not clobber errno, > so we fixed some of the callers but also applied that commit which just= > saves errno because there's no reason not to. If we're willing to accept the convenience so that callers can be lazy, then I like this patch. If we want to fix bugs in the callers, then this patch makes it harder to find those bugs. I'm actually 60:40 in favor of this patch (I think the convenience outweighs an audit of fixing all callers); but if we do that, then we might also want to intentionally switch existing callers to pass negative values rather than declaring that passing a negative value is a bug. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --T9NIESscUjkrrMBxTAEJ50hgFQhmduHJ3 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUWgfGAAoJEKeha0olJ0Nqp8oH/2EXjRfSyCRvYjqLrAX8Ih8q R8R5zZiNQjDC4nUzDQ+pNLgyK/aTvrsqRW0KeohPRIo1dvGqUqYTPyIrtFuu/GxP bpjxLVl/GxZ2bGWigtAO6mY/1rVzw076fkrh8GQ9FeQSzWqyS9aEyJJxzhhbXF8L JyFTLvkyaWiLm+6m+cDFqyJ9YNxnHyNswDCAL5wI8oE4JN+c+bM5RnQtndwZiVou 4mByAp/4Aiagi8fu6rNf7dQX0aqziA4/wg96ATm6ENXzqoS5kAb7aLEnVSITr+Nl 2W3fFobV4FhN6MuNvOzCu1RHkVioQNVOZTEuHjyccA2JmbKw3337aSi6j3wntbM= =b8OI -----END PGP SIGNATURE----- --T9NIESscUjkrrMBxTAEJ50hgFQhmduHJ3--