[FFmpeg-devel] [PATCH] libavformat/fitsdec: use correct type for assert

Johannes Kauffmann johanneskauffmann at hotmail.com
Wed Sep 21 02:55:51 EEST 2022


Now with correct formatting. Patch attached.

On 21/09/2022 01:22, Johannes Kauffmann wrote:
> Since avbuf.len is of type unsigned and not int64_t, compare to UINT_MAX
> instead of INT64_MAX.
>
> This fixes the following warning on clang:
>
> src/libavformat/fitsdec.c:177:26: warning: result of comparison of
> constant 9223372036854775807 with expression of type 'unsigned int' is
> always true [-Wtautological-constant-out-of-range-compare]
>
>     av_assert0(avbuf.len <= INT64_MAX && size <= INT64_MAX);
>     ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ---
>  libavformat/fitsdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/fitsdec.c b/libavformat/fitsdec.c
> index 54412c60ff..b2ef826f52 100644
> --- a/libavformat/fitsdec.c
> +++ b/libavformat/fitsdec.c
> @@ -174,7 +174,7 @@ static int fits_read_packet(AVFormatContext *s, 
> AVPacket *pkt)
>          goto fail;
>      }
>  -    av_assert0(avbuf.len <= INT64_MAX && size <= INT64_MAX);
> +    av_assert0(avbuf.len <= UINT_MAX && size <= INT64_MAX);
>      if (avbuf.len + size > INT_MAX - 80)  {
>          ret = AVERROR_INVALIDDATA;
>          goto fail;
-------------- next part --------------
From a615d32204c50ab8a341caafba76b02ffebd2877 Mon Sep 17 00:00:00 2001
From: Johannes Kauffmann <johanneskauffmann at hotmail.com>
Date: Wed, 21 Sep 2022 01:00:23 +0200
Subject: [PATCH] libavformat/fitsdec: use correct type for assert

Since avbuf.len is of type unsigned and not int64_t, compare to UINT_MAX
instead of INT64_MAX.

This fixes the following warning on clang:

src/libavformat/fitsdec.c:177:26: warning: result of comparison of
constant 9223372036854775807 with expression of type 'unsigned int' is
always true [-Wtautological-constant-out-of-range-compare]

    av_assert0(avbuf.len <= INT64_MAX && size <= INT64_MAX);
    ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 libavformat/fitsdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/fitsdec.c b/libavformat/fitsdec.c
index 54412c60ff..b2ef826f52 100644
--- a/libavformat/fitsdec.c
+++ b/libavformat/fitsdec.c
@@ -174,7 +174,7 @@ static int fits_read_packet(AVFormatContext *s, AVPacket *pkt)
         goto fail;
     }
 
-    av_assert0(avbuf.len <= INT64_MAX && size <= INT64_MAX);
+    av_assert0(avbuf.len <= UINT_MAX && size <= INT64_MAX);
     if (avbuf.len + size > INT_MAX - 80)  {
         ret = AVERROR_INVALIDDATA;
         goto fail;
-- 
2.34.1



More information about the ffmpeg-devel mailing list