From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeV6T-0001WH-VR for qemu-devel@nongnu.org; Thu, 07 Nov 2013 14:18:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VeV6O-00031k-UY for qemu-devel@nongnu.org; Thu, 07 Nov 2013 14:18:53 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:42069 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeV6O-00031a-KT for qemu-devel@nongnu.org; Thu, 07 Nov 2013 14:18:48 -0500 Date: Thu, 7 Nov 2013 20:18:45 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20131107191845.GG2921@irqsave.net> References: <1383851429-9213-1-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1383851429-9213-1-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] util/error: Save errno from clobbering List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi Le Thursday 07 Nov 2013 =E0 20:10:29 (+0100), Max Reitz a =E9crit : > There may be calls to error_setg() and especially error_setg_errno() > which blindly (and until now wrongly) assume these functions not to > clobber errno (e.g., they pass errno to error_setg_errno() and return > -errno afterwards). Instead of trying to find and fix all of these > constructs, just make sure error_setg() and error_setg_errno() indeed d= o > not clobber errno. >=20 > Suggested-by: Eric Blake > Signed-off-by: Max Reitz > --- > util/error.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/util/error.c b/util/error.c > index ec0faa6..3ee362a 100644 > --- a/util/error.c > +++ b/util/error.c > @@ -27,6 +27,7 @@ void error_set(Error **errp, ErrorClass err_class, co= nst char *fmt, ...) > { > Error *err; > va_list ap; > + int saved_errno =3D errno; > =20 > if (errp =3D=3D NULL) { > return; > @@ -41,6 +42,8 @@ void error_set(Error **errp, ErrorClass err_class, co= nst char *fmt, ...) > err->err_class =3D err_class; > =20 > *errp =3D err; > + > + errno =3D saved_errno; > } > =20 > void error_set_errno(Error **errp, int os_errno, ErrorClass err_class, > @@ -49,6 +52,7 @@ void error_set_errno(Error **errp, int os_errno, Erro= rClass err_class, > Error *err; > char *msg1; > va_list ap; > + int saved_errno =3D errno; > =20 > if (errp =3D=3D NULL) { > return; > @@ -69,6 +73,8 @@ void error_set_errno(Error **errp, int os_errno, Erro= rClass err_class, > err->err_class =3D err_class; > =20 > *errp =3D err; > + > + errno =3D saved_errno; > } > =20 > void error_setg_file_open(Error **errp, int os_errno, const char *file= name) > --=20 > 1.8.4.2 >=20 >=20 Yes this look better than trying to fix all callers. Reviewed-by: Benoit Canet