[FFmpeg-devel] [PATCH 1/2] Make av_strerror() print the string of "Error number %d occurred" if strerror_r() did not succeed, for example because the error code is not known.

Stefano Sabatini stefano.sabatini-lala
Sat May 1 10:28:33 CEST 2010


This avoids the need for the application to fill the string in case
strerror_r() fails to do it for whatever reason.
---
 libavutil/error.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavutil/error.c b/libavutil/error.c
index a1a0b87..3cf08da 100644
--- a/libavutil/error.c
+++ b/libavutil/error.c
@@ -21,7 +21,7 @@
 
 int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
 {
-    int ret = 0;
+    int ret = -1;
     const char *errstr = NULL;
 
     switch (errnum) {
@@ -36,9 +36,9 @@ 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
-        snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
 #endif
+        if (ret < 0)
+            snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
     }
 
     return ret;
-- 
1.7.0




More information about the ffmpeg-devel mailing list