qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "François Revol" <revol@free.fr>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [6324] Return -errno on write failure (Gleb Natapov)
Date: Thu, 15 Jan 2009 22:20:33 +0100 CET	[thread overview]
Message-ID: <2858981241-BeMail@laptop> (raw)
In-Reply-To: <E1LNZ4k-0004ZW-UT@cvs.savannah.gnu.org>

> 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	other threads:[~2009-01-15 21:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-15 20:44 [Qemu-devel] [6324] Return -errno on write failure (Gleb Natapov) Anthony Liguori
2009-01-15 21:20 ` François Revol [this message]
2009-01-15 22:15   ` M. Warner Losh
2009-01-15 22:33     ` François Revol
2009-01-16  7:31   ` Gleb Natapov
2009-01-16 17:37   ` Ian Jackson
2009-01-16 18:36     ` François Revol
2009-01-16 18:49       ` Anthony Liguori
2009-01-16 19:17         ` François Revol
2009-01-16 19:31           ` Anthony Liguori
2009-01-16 19:41             ` François Revol
2009-01-19 11:37       ` Ian Jackson
2009-01-19 18:52         ` François Revol
2009-01-19 19:47           ` Lennart Sorensen
2009-01-19 20:31             ` François Revol
2009-01-19 20:03           ` M. Warner Losh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2858981241-BeMail@laptop \
    --to=revol@free.fr \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).