From: timblechmann via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: timblechmann <code@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] improve error messages when strerror_r is not available (PR #20680) Date: Thu, 09 Oct 2025 06:55:00 -0000 Message-ID: <175999290100.65.8682990166039430515@bf249f23a2c8> (raw) 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 <tim@klingt.org> 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 <tim@klingt.org> 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 -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-10-09 6:55 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=175999290100.65.8682990166039430515@bf249f23a2c8 \ --to=ffmpeg-devel@ffmpeg.org \ --cc=code@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror http://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ http://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git