[Ffmpeg-devel] BeOS cleanup work in progress

François Revol revol
Sat Jan 27 11:10:53 CET 2007


> > So I factored it out there in the first one.
> 
> yes but you droped the code in a public header it
> 1. shouldnt be in a header and
> 2. shouldnt be public
> 
> there are 2 uses in tcp.c and none anywhere else? factoring the code 
> out
> here obviously means putting the new function as static (NOT inline)
> function in tcp.c

That was in anticipation of good-practice contributions using it :)

> > As for which lib they go into, well there were several return -EFOO 
> > in
> > libavcodec as well. And someone suggested moving errors there.
> > I can move that back to avformat, and change others to return -1.
> > I don't care as long as it's not those ugly -EFOO.
> 
> after thinking a little about this i feel less and less comfortable
> with the whole change
> both my copy of the c standard and "info libc" says that 
> E* MUST be positive, so -EFOO seems the simplest and cleanest way to
> do this ...

Opengroup also says that in *one* page, and others only !=0, and on 
that page they say they changed their mind to comply with something 
from 1999.
http://www.opengroup.org/onlinepubs/009695399/basedefs/errno.h.html
"Issue 6:
Values for errno are now required to be distinct positive values rather 
than non-zero values. This change is for alignment with the ISO/IEC 
9899:1999 standard."
For ex this page only says 0 means success without enforcing positive 
values.
http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_03.html
So much for consistency.

You can't expect headers written before 99 to comply with that, and 
there is no way to change BeOS errors to positive values to please 
whatever standard it predates. Complain to the standardization body who 
didn't set it right the first time.

> also abs(AVERROR_*) if we do agree on them should have the same value 
> as
> abs(E*) that way mapping from one to the other becomes much simpler

Except E* don't have the same value on all platforms.
It pretty much falls down to my first idea which was 

/* os_support.h or whatever */
#ifdef __BEOS__
#  define FFERR(e) (e)
#else
#  define FFERR(e) (-(e))
#endif


...
  return FFERR(ENOMEM);
...

err = av_foo(..);
if (err < 0 && err != FFERR(EINTR))
  return err;

Not sure but if cpp supports abs we can even #if abs(EINVAL) != EINVAL 
instead, though I don't know any other OS that does that (being alone 
doesn't mean you are wrong :p).

It suppresses the need for AVERROR_* leaving all the semantics attached 
to the posix errors without folding them to 10 cases. (but we still 
need to handle OSes which don't have some defined).

For the time being we could keep AVERROR_* as #defined to FFERR(E*) 
until we increment the versions.



Fran?ois.





More information about the ffmpeg-devel mailing list