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 7B7E14BBFA for ; Mon, 15 Jul 2024 15:45:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 74AEC68D99B; Mon, 15 Jul 2024 18:45:34 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3D53A68D8CD for ; Mon, 15 Jul 2024 18:45:28 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E98B3EAAC0 for ; Mon, 15 Jul 2024 17:45:26 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VUWuQFdgsfj3 for ; Mon, 15 Jul 2024 17:45:24 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 3FA88EA855 for ; Mon, 15 Jul 2024 17:45:24 +0200 (CEST) Date: Mon, 15 Jul 2024 17:45:24 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20240715151319.2322241-1-ffmpeg-devel@pileofstuff.org> Message-ID: <14f41f0c-d2b0-3bd4-06ef-bfbac84274a9@passwd.hu> References: <20240715151319.2322241-1-ffmpeg-devel@pileofstuff.org> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, 15 Jul 2024, Andrew Sayers wrote: > 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. All ffmpeg internal error codes (including the ones having some special tag representation) should be handled by error.c. The user should never receive FFERROR_REDO, that is an internal error code, it should never reach the user. Therefore I see no benefit in disclosing the error bytes, because that is not the proper fix. Regards, Marton > > If a non-negative number somehow gets passed to this function, > print a message saying this shouldn't happen. > --- > libavutil/error.c | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/libavutil/error.c b/libavutil/error.c > index 90bab7b9d3..c40b54b1f9 100644 > --- a/libavutil/error.c > +++ b/libavutil/error.c > @@ -119,6 +119,38 @@ 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, > + "Unrecognised error code \"%c%c%c%c\" occurred", > + (-errnum >> 0) & 0xFF, > + (-errnum >> 8) & 0xFF, > + (-errnum >> 16) & 0xFF, > + (-errnum >> 24) & 0xFF > + ); > + } else { > + snprintf( > + errbuf, > + errbuf_size, > + "Unrecognised error code \"%c%c%c\" occurred", > + (-errnum >> 0) & 0xFF, > + (-errnum >> 8) & 0xFF, > + (-errnum >> 16) & 0xFF > + ); > + } > + } else if (errnum >= 0) { > + snprintf(errbuf, errbuf_size, "Impossible: non-negative error number %d occurred", errnum); > } else { > #if HAVE_STRERROR_R > ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size)); > -- > 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". > _______________________________________________ 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".