[PATCH 1/6] Make av_strerror() return -1 even in the case when av_strerror_r() is not defined.

Stefano Sabatini stefano.sabatini-lala
Mon May 3 23:28:01 CEST 2010


This allows applications to check if av_strerror() cannot provide a
meaningful representation for the provided error code, without to
actually check the filled string.
---
 libavutil/error.c |    4 +++-
 libavutil/error.h |    3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavutil/error.c b/libavutil/error.c
index 3dd38a3..b6d6019 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 a1b9ccc..13a9a35 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);
 
-- 
1.7.0


--UugvWAfsgieZRqgk--



More information about the ffmpeg-devel mailing list