From 1673bf86d6390cb3f7aaaae115264afa1dc41a14 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Wed, 19 May 2010 08:03:22 +0000 Subject: Make av_strerror() return -1 even in the case when av_strerror_r() is not defined. This allows applications to check if av_strerror() cannot provide a meaningful representation for the provided error code, without having to actually check the filled string. backport r23031 by stefano Originally committed as revision 23174 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6 --- libavutil/avutil.h | 2 +- libavutil/error.c | 4 +++- libavutil/error.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'libavutil') diff --git a/libavutil/avutil.h b/libavutil/avutil.h index b2c49283b0..e9e07b92fd 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -41,7 +41,7 @@ #define LIBAVUTIL_VERSION_MAJOR 50 #define LIBAVUTIL_VERSION_MINOR 15 -#define LIBAVUTIL_VERSION_MICRO 0 +#define LIBAVUTIL_VERSION_MICRO 1 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/libavutil/error.c b/libavutil/error.c index 3dd38a351c..b6d6019061 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -36,8 +36,10 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) } else { #if HAVE_STRERROR_R ret = strerror_r(AVUNERROR(errnum), errbuf, errbuf_size); +#else + ret = -1; #endif - if (!HAVE_STRERROR_R || ret < 0) + if (ret < 0) snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum); } diff --git a/libavutil/error.h b/libavutil/error.h index a1b9ccc050..13a9a35930 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -64,7 +64,8 @@ * error message indicating the errnum provided to errbuf. * * @param errbuf_size the size in bytes of errbuf - * @return 0 on success, a negative value otherwise + * @return 0 on success, a negative value if a description for errnum + * cannot be found */ int av_strerror(int errnum, char *errbuf, size_t errbuf_size); -- cgit v1.2.3