qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [6324] Return -errno on write failure (Gleb Natapov)


From: François Revol
Subject: Re: [Qemu-devel] [6324] Return -errno on write failure (Gleb Natapov)
Date: Thu, 15 Jan 2009 22:20:33 +0100 CET

> Revision: 6324
>           http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6324
> > 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 = to
INT32_MIN 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 !=0. 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?revision=16580&view=markup

#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çois.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]