[FFmpeg-devel] [PATCH] Replace ENOSYS by ENOTSUP

François Revol revol
Thu Aug 16 20:56:29 CEST 2007


> > Then we/apps'll need our own strerror, have to localize them, ...
> > I don't really care though. Just mixing both isn't clean at all.
> 
> i disgagree, mixing both is the best option
> 
> lets see:
>                standard E           mix                 only ours
> std E error    localized strerr()   localized strerr()  nothing 
> directly
> non std E err  random error msg     strerr() fail       nothing 
> directly
> 
> from this its clear that mix is better than just returning standard E
> *
> as the pure standard E* will always end in incorrect error codes and 
> error
> messages if none of the available E* is applicable
> 
> the "nothing directly" and "strerr() fail" cases can of course be
> covered by a av_strerr() if anyone cares but simply calling 
> strerror()
> from av_strerror() is not acceptable as it modifies the result of 
> past
> strerror()

Hmm strerror() doesn't really "fail"... Some implementations set errno 
to EINVAL on unknown error, but not always it seems (DragonFly does 
only for strerror_r).

I'm not sure using 4CCs won't colide with BeOS errors... let's see.

/* Error baselines */
#define B_GENERAL_ERROR_BASE            LONG_MIN
..
/* Developer-defined errors start at (B_ERRORS_END+1) */
#define B_ERRORS_END            (B_GENERAL_ERROR_BASE + 0xffff)

Ok, it seems unlikely, as -MKTAG() would certainly have some upper bits 
set unless the first char is '\0'.


Now, another option is to just use a base value to split the error 
space.
On Unix it could be something like 500000 as I saw in libusb, and on 
BeOS I'd use B_ERRORS_END + something

I already presented this option.

#define AVERROR_NOMEM AVERROR(ENOMEM)
#define AVERROR_WHATEVER AVERROR(AVERROR_BASE + 1)

Then:
av_strerror(int e)
{
	int err = AVUNERROR(e);
	if (e < AVERROR_BASE)
		return strerror(e);
	switch (err) {
	case AVERROR_WHATEVER:
		return "Whatever";
	}
}

Fran?ois.




More information about the ffmpeg-devel mailing list