diff mbox series

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

Message ID DB6PR07MB3175F2F9E1E85521E518F33DA64C9@DB6PR07MB3175.eurprd07.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel] libavformat/fitsdec: use correct type for assert | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch

Commit Message

Johannes Kauffmann Sept. 20, 2022, 11:22 p.m. UTC
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(-)

Comments

Johannes Kauffmann Sept. 20, 2022, 11:55 p.m. UTC | #1
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;
From a615d32204c50ab8a341caafba76b02ffebd2877 Mon Sep 17 00:00:00 2001
From: Johannes Kauffmann <johanneskauffmann@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;
diff mbox series

Patch

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;