From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 474E64BECF for ; Thu, 18 Jul 2024 10:48:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0274E68DAA3; Thu, 18 Jul 2024 13:48:29 +0300 (EEST) Received: from alt2.a-painless.mh.aa.net.uk (alt2.a-painless.mh.aa.net.uk [81.187.30.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EC0F568D5B7 for ; Thu, 18 Jul 2024 13:48:20 +0300 (EEST) Received: from 0.b.4.b.7.4.0.8.c.4.a.5.d.8.b.2.0.5.8.0.9.1.8.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:819:850:2b8d:5a4c:8047:b4b0] helo=andrews-2024-laptop.lan) by painless-a.thn.aa.net.uk with esmtp (Exim 4.96) (envelope-from ) id 1sUOgO-000Wr5-1K; Thu, 18 Jul 2024 11:48:20 +0100 From: Andrew Sayers To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Jul 2024 11:46:48 +0100 Message-ID: <20240718104757.2809396-3-ffmpeg-devel@pileofstuff.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718104757.2809396-1-ffmpeg-devel@pileofstuff.org> References: <20240718104757.2809396-1-ffmpeg-devel@pileofstuff.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 2/3] avutil/error: Provide better feedback about unknown error codes X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andrew Sayers Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: AVERROR messages should always be less than zero, and are often FourCCs. For error codes that aren't explicitly handled by error.c (e.g. undocumented system error codes, or internal error codes that leaked to the public API), print the FourCC code so the user has a little more information to work with. If a non-negative number somehow gets passed to this function, print a message saying this shouldn't happen. --- libavutil/error.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavutil/error.c b/libavutil/error.c index 90bab7b9d3..0f748bd9e5 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -20,6 +20,7 @@ #define _XOPEN_SOURCE 600 /* XSI-compliant version of strerror_r */ #include #include +#include "avutil.h" #include "config.h" #include "avstring.h" #include "error.h" @@ -119,6 +120,8 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) } if (entry) { av_strlcpy(errbuf, entry->str, errbuf_size); + } 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 +129,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 (%s) occurred, please report this bug", -errnum, av_fourcc2str(-errnum)); } return ret; -- 2.45.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".