[FFmpeg-devel] [PATCH] Implement av_strerror()
Stefano Sabatini
stefano.sabatini-lala
Sun Mar 14 19:12:07 CET 2010
On date Sunday 2010-03-14 15:52:41 +0000, M?ns Rullg?rd encoded:
> Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:
[...]
> > +int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
> > +{
> > + int ret = 0;
> > + const char *errstr = NULL;
> > +
> > + switch (errnum) {
> > +#define HANDLE_ERROR(ERR, ERRSTR) case AVERROR_##ERR: errstr = ERRSTR; break
> > +
> > +#if LIBAVUTIL_VERSION_MAJOR < 51
> > + HANDLE_ERROR(IO , "I/O error");
> > + HANDLE_ERROR(NOENT , "No such file or directory");
> > + HANDLE_ERROR(NOMEM , "Not enough memory");
> > +#endif
> > + HANDLE_ERROR(EOF , "End of file");
> > + HANDLE_ERROR(INVALIDDATA , "Invalid data found");
> > + HANDLE_ERROR(NOFMT , "Unknown format");
> > + HANDLE_ERROR(NOTSUPP , "Operation not supported");
> > + HANDLE_ERROR(NUMEXPECTED , "Number syntax expected in filename");
> > + HANDLE_ERROR(PATCHWELCOME , "Not yet implemented in FFmpeg, patches welcome");
> > + }
>
> Please drop the macro. It only obfuscates.
Dropeed.
> > + if (errstr) {
> > + av_strlcatf(errbuf, errbuf_size, errstr);
>
> av_strlcpy()
>
> > + } else {
> > +#if _POSIX_C_SOURCE >= 200112L
> > + ret = strerror_r(AVUNERROR(errnum), errbuf, errbuf_size);
> > +#else
> > + av_strlcatf(errbuf, errbuf_size, "Error number %d", errnum);
> > +#endif
>
> This is wrong for two reasons:
>
> 1. We define _POSIX_C_SOURCE to 200112.
> 2. strerror_r() is optional.
>
> The correct solution is to check_func it in configure.
Done like that.
--
FFmpeg = Frenzy Frightening Multipurpose Peaceless Extended Guru
More information about the ffmpeg-devel
mailing list