PR #20680 opened by timblechmann URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20680 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20680.patch
* add more fallbacks with different error codes * add strerror_s codepath for windows/msvc >From 6ea5baadd63ae9ab37855fb3ede56415ff671663 Mon Sep 17 00:00:00 2001 From: Tim Blechmann <[email protected]> Date: Thu, 9 Oct 2025 14:44:21 +0800 Subject: [PATCH 1/2] avutil: add missing error codes av_strerror does not implement fallbacks for many posix error codes when strerror_r is not available. Adding the missing entries. --- libavutil/error.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/libavutil/error.c b/libavutil/error.c index 90bab7b9d3..e7867cad71 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -103,6 +103,129 @@ static const struct error_entry error_entries[] = { { EERROR_TAG(ESPIPE), "Illegal seek" }, { EERROR_TAG(ESRCH), "No such process" }, { EERROR_TAG(EXDEV), "Cross-device link" }, +#ifdef EADDRINUSE + { EERROR_TAG(EADDRINUSE), "Address in use" }, +#endif +#ifdef EADDRNOTAVAIL + { EERROR_TAG(EADDRNOTAVAIL), "Address not available" }, +#endif +#ifdef EAFNOSUPPORT + { EERROR_TAG(EAFNOSUPPORT), "Address family not supported" }, +#endif +#ifdef EALREADY + { EERROR_TAG(EALREADY), "Connection already in progress" }, +#endif +#ifdef EBADMSG + { EERROR_TAG(EBADMSG), "Bad message" }, +#endif +#ifdef ECANCELED + { EERROR_TAG(ECANCELED), "Operation canceled" }, +#endif +#ifdef ECONNABORTED + { EERROR_TAG(ECONNABORTED), "Connection aborted" }, +#endif +#ifdef ECONNREFUSED + { EERROR_TAG(ECONNREFUSED), "Connection refused" }, +#endif +#ifdef ECONNRESET + { EERROR_TAG(ECONNRESET), "Connection reset" }, +#endif +#ifdef EDESTADDRREQ + { EERROR_TAG(EDESTADDRREQ), "Destination address required" }, +#endif +#ifdef EHOSTUNREACH + { EERROR_TAG(EHOSTUNREACH), "Host unreachable" }, +#endif +#ifdef EIDRM + { EERROR_TAG(EIDRM), "Identifier removed" }, +#endif +#ifdef EINPROGRESS + { EERROR_TAG(EINPROGRESS), "Operation in progress" }, +#endif +#ifdef EISCONN + { EERROR_TAG(EISCONN), "Already connected" }, +#endif +#ifdef ELOOP + { EERROR_TAG(ELOOP), "Too many symbolic link levels" }, +#endif +#ifdef EMSGSIZE + { EERROR_TAG(EMSGSIZE), "Message size" }, +#endif +#ifdef ENETDOWN + { EERROR_TAG(ENETDOWN), "Network down" }, +#endif +#ifdef ENETRESET + { EERROR_TAG(ENETRESET), "Network reset" }, +#endif +#ifdef ENETUNREACH + { EERROR_TAG(ENETUNREACH), "Network unreachable" }, +#endif +#ifdef ENOBUFS + { EERROR_TAG(ENOBUFS), "No buffer space" }, +#endif +#ifdef ENODATA + { EERROR_TAG(ENODATA), "No message available" }, +#endif +#ifdef ENOLINK + { EERROR_TAG(ENOLINK), "No link" }, +#endif +#ifdef ENOMSG + { EERROR_TAG(ENOMSG), "No message" }, +#endif +#ifdef ENOPROTOOPT + { EERROR_TAG(ENOPROTOOPT), "No protocol option" }, +#endif +#ifdef ENOSR + { EERROR_TAG(ENOSR), "No stream resources" }, +#endif +#ifdef ENOSTR + { EERROR_TAG(ENOSTR), "Not a stream" }, +#endif +#ifdef ENOTCONN + { EERROR_TAG(ENOTCONN), "Not connected" }, +#endif +#ifdef ENOTRECOVERABLE + { EERROR_TAG(ENOTRECOVERABLE), "State not recoverable" }, +#endif +#ifdef ENOTSOCK + { EERROR_TAG(ENOTSOCK), "Not a socket" }, +#endif +#ifdef ENOTSUP + { EERROR_TAG(ENOTSUP), "Not supported" }, +#endif +#ifdef EOPNOTSUPP + { EERROR_TAG(EOPNOTSUPP), "Operation not supported" }, +#endif +#ifdef EOTHER + { EERROR_TAG(EOTHER), "Other" }, +#endif +#ifdef EOVERFLOW + { EERROR_TAG(EOVERFLOW), "Value too large" }, +#endif +#ifdef EOWNERDEAD + { EERROR_TAG(EOWNERDEAD), "Owner dead" }, +#endif +#ifdef EPROTO + { EERROR_TAG(EPROTO), "Protocol error" }, +#endif +#ifdef EPROTONOSUPPORT + { EERROR_TAG(EPROTONOSUPPORT), "Protocol not supported" }, +#endif +#ifdef EPROTOTYPE + { EERROR_TAG(EPROTOTYPE), "Wrong protocol type" }, +#endif +#ifdef ETIME + { EERROR_TAG(ETIME), "Stream timeout" }, +#endif +#ifdef ETIMEDOUT + { EERROR_TAG(ETIMEDOUT), "Timed out" }, +#endif +#ifdef ETXTBSY + { EERROR_TAG(ETXTBSY), "Text file busy" }, +#endif +#ifdef EWOULDBLOCK + { EERROR_TAG(EWOULDBLOCK), "Operation would block" }, +#endif #endif }; -- 2.49.1 >From c09b672527fa32dd0950cfd998fe5aefaffb9550 Mon Sep 17 00:00:00 2001 From: Tim Blechmann <[email protected]> Date: Thu, 9 Oct 2025 14:53:22 +0800 Subject: [PATCH 2/2] avutil: av_strerror - add implementation via strerror_s win32 does not have strerror_r, but strerror_s. adding a codepath to av_strerror, that makes use of it. --- libavutil/error.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavutil/error.c b/libavutil/error.c index e7867cad71..088dcf7483 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -25,6 +25,10 @@ #include "error.h" #include "macros.h" +#if defined(_WIN32) && defined(_MSC_VER) +#define HAVE_STRERROR_S +#endif + struct error_entry { int num; const char *tag; @@ -64,7 +68,7 @@ static const struct error_entry error_entries[] = { { ERROR_TAG(HTTP_TOO_MANY_REQUESTS), "Server returned 429 Too Many Requests" }, { ERROR_TAG(HTTP_OTHER_4XX), "Server returned 4XX Client Error, but not one of 40{0,1,3,4}" }, { ERROR_TAG(HTTP_SERVER_ERROR), "Server returned 5XX Server Error reply" }, -#if !HAVE_STRERROR_R +#if !HAVE_STRERROR_R && !defined(HAVE_STRERROR_S) { EERROR_TAG(E2BIG), "Argument list too long" }, { EERROR_TAG(EACCES), "Permission denied" }, { EERROR_TAG(EAGAIN), "Resource temporarily unavailable" }, @@ -226,7 +230,7 @@ static const struct error_entry error_entries[] = { #ifdef EWOULDBLOCK { EERROR_TAG(EWOULDBLOCK), "Operation would block" }, #endif -#endif +#endif // !HAVE_STRERROR_R && !defined(HAVE_STRERROR_S) }; int av_strerror(int errnum, char *errbuf, size_t errbuf_size) @@ -245,6 +249,8 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) } else { #if HAVE_STRERROR_R ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size)); +#elif defined(HAVE_STRERROR_S) + ret = AVERROR(strerror_s(errbuf, errbuf_size, AVUNERROR(errnum))); #else ret = -1; #endif -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
