[FFmpeg-devel] [PATCH] avutils/video_enc_params: remove unnecessary check to fix compile warning
Anton Khirnov
anton at khirnov.net
Sun Feb 14 12:37:43 EET 2021
Quoting Nuo Mi (2021-02-14 07:26:56)
> This will fix following compile warning:
>
> libavutil/video_enc_params.c: In function ‘av_video_enc_params_alloc’: libavutil/video_enc_params.c:36:19: warning: comparison is always false due to limited range of data type [-Wtype-limits] 36 | if (nb_blocks > SIZE_MAX / sizeof(AVVideoBlockParams) || | ^
>
> Suppose a is "nb_blocks > SIZE_MAX / sizeof(AVVideoBlockParams))"
> b is "nb_blocks * sizeof(AVVideoBlockParams) > SIZE_MAX - sizw"
> If a is true, b is true.
> If a is false, the expression depends on b.
> No matter a is true or not, it we only need check b.
Check a is needed to prevent overflow in b.
IMO the warning is bogus and we should consider disabling it.
--
Anton Khirnov
More information about the ffmpeg-devel
mailing list