[FFmpeg-devel] [PATCHv2] avformat/movenc: suppress -Wstrict-overflow warnings
gajjanagadde at gmail.com
Fri Oct 16 23:39:34 CEST 2015
On Wed, Oct 14, 2015 at 10:05 PM, Ganesh Ajjanagadde
<gajjanagadde at gmail.com> wrote:
> This patch results in identical behavior of movenc, and suppresses -Wstrict-overflow
> warnings observed in GCC 5.2:
> "warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]"
> I have manually checked that all usages are safe, and overflow possibility does
> not exist with this expression rewrite.
> Some expressed concern over readability loss, hence a comment is added.
> This is the simplest way to suppress this warning.
> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
> libavformat/movenc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 5115585..ff997f2 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -854,7 +854,9 @@ static int get_cluster_duration(MOVTrack *track, int cluster_idx)
> int64_t next_dts;
> - if (cluster_idx >= track->entry)
> + /* GCC 5.2 wants to "optimize" cluster_idx >= track->entry to the below
> + * expression. We actually mean cluster_idx >= track->entry. */
> + if (cluster_idx - track->entry >= 0)
> return 0;
> if (cluster_idx + 1 == track->entry)
ping, is this solution acceptable? Note that I will get rid of the
extra * on the second line of the comment.
More information about the ffmpeg-devel