AVERROR messages should always be less than zero,
and are usually based on three or four ASCII characters.
For error codes that aren't explicitly handled by error.c (e.g. FFERROR_REDO),
print the ASCII code so the user has a little more information.
If a non-negative number somehow gets passed to this function,
print a message saying this shouldn't happen.
---
libavutil/error.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/libavutil/error.c b/libavutil/error.c
index 90bab7b9d3..9706578be6 100644
--- a/libavutil/error.c
+++ b/libavutil/error.c
@@ -119,6 +119,40 @@ int av_strerror(int errnum, char *errbuf, size_t
errbuf_size)
}
if (entry) {
av_strlcpy(errbuf, entry->str, errbuf_size);
+ } else if (
+ -errnum <= 0xFFFFFFFF
+ && ((-errnum >> 0) & 0xFF) >= 0x20 && ((-errnum >> 0) & 0xFF) <= 0x7F
+ && ((-errnum >> 8) & 0xFF) >= 0x20 && ((-errnum >> 8) & 0xFF) <= 0x7F
+ && ((-errnum >> 16) & 0xFF) >= 0x20 && ((-errnum >> 16) & 0xFF) <= 0x7F
+ && (
+ (((-errnum >> 24) & 0xFF) >= 0x20 && ((-errnum >> 24) & 0xFF) <=
0x7F)
+ || !((-errnum >> 24) & 0xFF)
+ )
+ ) {
+ if ((-errnum >> 24) & 0xFF) {
+ snprintf(
+ errbuf,
+ errbuf_size,
+ "Error number -0x%x (\"%c%c%c%c\") occurred, please report
this bug",
+ -errnum,
+ (-errnum >> 0) & 0xFF,
+ (-errnum >> 8) & 0xFF,
+ (-errnum >> 16) & 0xFF,
+ (-errnum >> 24) & 0xFF
+ );
+ } else {
+ snprintf(
+ errbuf,
+ errbuf_size,
+ "Error number -0x%x (\"%c%c%c\") occurred, please report this
bug",
+ -errnum,
+ (-errnum >> 0) & 0xFF,
+ (-errnum >> 8) & 0xFF,
+ (-errnum >> 16) & 0xFF
+ );
+ }
+ } else if (errnum >= 0) {
+ snprintf(errbuf, errbuf_size, "Impossible: non-negative error number
%d occurred, please report this bug", errnum);
} else {
#if HAVE_STRERROR_R
ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size));
@@ -126,7 +160,7 @@ int av_strerror(int errnum, char *errbuf, size_t
errbuf_size)
ret = -1;
#endif
if (ret < 0)
- snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
+ snprintf(errbuf, errbuf_size, "Error number -0x%X occurred, please
report this bug", -errnum);
}
return ret;
--
2.45.2
_______________________________________________
ffmpeg-devel mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".