[FFmpeg-devel] [PATCH] avutil/video_enc_param: fix warning

Nicolas George george at nsup.org
Thu May 21 18:10:00 EEST 2020


Anton Khirnov (12020-05-21):
> This is wrong. We should not fix warnings, we should fix bugs. Warnings
> suggest there may be a bug, but not all warnings are correct.
> 
> In this case, I believe the warnings is invalid and there is no problem
> to fix. It's correct that the comparison is always false on some
> platforms, but AFAIK no standard we adhere to guarantees that on all
> platforms.

Yet, we should strive to silence this warning, because invalid warnings
distract from valid ones.

It is tricky to do elegantly.

Maybe:

static inline int
check_overflow(size_t n, size_t s, size_t c)
{
    return n <= SIZE_MAX / s && n * s < SIZE_MAX - c;
}

It would avoid the warning because n is size_t instead of unsigned.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200521/8ce821bd/attachment.sig>


More information about the ffmpeg-devel mailing list