[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:12:48 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 | 4 ++--
libavutil/error.h | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavutil/error.c b/libavutil/error.c
index a1a0b87..3dd38a3 100644
--- a/libavutil/error.c
+++ b/libavutil/error.c
@@ -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 (!HAVE_STRERROR_R || ret < 0)
+ snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
}
return ret;
diff --git a/libavutil/error.h b/libavutil/error.h
index abf9a57..a754d41 100644
--- a/libavutil/error.h
+++ b/libavutil/error.h
@@ -60,7 +60,8 @@
/**
* Puts a description of the AVERROR code errnum in errbuf.
* In case of failure the global variable errno is set to indicate the
- * error.
+ * error. Even in case of failure av_strerror() will print to errbuf a
+ * generic error message indicating the errnum provided.
*
* @param errbuf_size the size in bytes of errbuf
* @return 0 on success, a negative value otherwise
--
1.7.0
--dc+cDN39EJAMEtIO--
More information about the ffmpeg-devel
mailing list