[FFmpeg-devel] [RFC PATCH v2] avutil/error: Provide better feedback about unknown error codes

Michael Niedermayer michael at niedermayer.cc
Thu Jul 18 00:06:56 EEST 2024


On Tue, Jul 16, 2024 at 12:13:10PM +0100, 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.
> 
> If a non-negative number somehow gets passed to this function,
> print a message saying this shouldn't happen.
[...]

> +    } 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);
>      }

I think this (asking for a report and pointing out to the user that
this isnt supposed to happen), is a good idea

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240717/776718f7/attachment.sig>


More information about the ffmpeg-devel mailing list