From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LNZdW-0001YK-A7 for qemu-devel@nongnu.org; Thu, 15 Jan 2009 16:20:22 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LNZdU-0001Xn-5o for qemu-devel@nongnu.org; Thu, 15 Jan 2009 16:20:21 -0500 Received: from [199.232.76.173] (port=44626 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LNZdT-0001Xi-ST for qemu-devel@nongnu.org; Thu, 15 Jan 2009 16:20:20 -0500 Received: from smtp2-g21.free.fr ([212.27.42.2]:38546) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LNZdS-00062q-KO for qemu-devel@nongnu.org; Thu, 15 Jan 2009 16:20:19 -0500 Received: from smtp2-g21.free.fr (localhost [127.0.0.1]) by smtp2-g21.free.fr (Postfix) with ESMTP id C1FFA4B018F for ; Thu, 15 Jan 2009 22:20:13 +0100 (CET) Received: from laptop (vaf26-2-82-244-111-82.fbx.proxad.net [82.244.111.82]) by smtp2-g21.free.fr (Postfix) with ESMTP id D91FD4B015C for ; Thu, 15 Jan 2009 22:20:10 +0100 (CET) In-Reply-To: Subject: Re: [Qemu-devel] [6324] Return -errno on write failure (Gleb Natapov) From: "=?utf-8?q?Fran=C3=A7ois?= Revol" Date: Thu, 15 Jan 2009 22:20:33 +0100 CET Message-Id: <2858981241-BeMail@laptop> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org > Revision: 6324 > http://svn.sv.gnu.org/viewvc/=3Fview=3Drev&root=3Dqemu&revision=3D6324 > > Author: aliguori > Date: 2009-01-15 20:44:26 +0000 (Thu, 15 Jan 2009) > > Log Message: > ----------- > Return -errno on write failure (Gleb Natapov) Nooooooooooo Please do not this bad broken Unix habit! errno and E* are negative in BeOS and Haiku and sometimes =3D to INT32=5FMIN which means negating it results in positive values or even overflows. I've already had too many apps to fix for this. If you want to know why this violates standards, use IPOT and ask Be, Inc. But it's not gonna change soon. And also ask Opengroup why they changed their mind later on after only requiring them to be !=3D0. Shame on them. It's IMO much cleaner and logical after seeing many misplaced signs in various software on that, but I don't expect to change it on Unix anyway, I just ask our way be respected as well. If you really want to pass the error this way, at least make sure they are signed correctly. See http://svn.ffmpeg.org/ffmpeg/trunk/libavcodec/avcodec.h=3Frevision=3D16580&view=3Dmarkup #if EINVAL > 0 #define QERROR(e) (-(e)) /**< Returns a negative error code from a POSIX error code, to return from library functions. */ #define QUNERROR(e) (-(e)) /**< Returns a POSIX error code from a library function error return value. */ #else /* Some platforms have E* and errno already negated. */ #define QERROR(e) (e) #define QUNERROR(e) (e) #endif and return QERROR(errno) or return QERROR(EINVAL); This has been used in FFmpeg and many other things and works very well. In OSS4 they chose to define their own error codes from E* at configure time, but I find it more intrusive. Fran=C3=A7ois.