[FFmpeg-devel,v2] avcodec/tscc: fix the warning: assigning to 'Bytef *' (aka 'unsigned char *') from 'const uint8_t *

Submitted by lance.lmwang@gmail.com on Sept. 4, 2019, 10:44 p.m.

Details

Message ID 20190904224455.29670-1-lance.lmwang@gmail.com
State New
Headers show

Commit Message

lance.lmwang@gmail.com Sept. 4, 2019, 10:44 p.m.
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/tscc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

lance.lmwang@gmail.com Sept. 10, 2019, 2:19 p.m.
On Thu, Sep 05, 2019 at 06:44:55AM +0800, lance.lmwang@gmail.com wrote:

ping

> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/tscc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c
> index 6d03081..b0dbef4 100644
> --- a/libavcodec/tscc.c
> +++ b/libavcodec/tscc.c
> @@ -88,7 +88,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
>          av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
>          return AVERROR_UNKNOWN;
>      }
> -    c->zstream.next_in   = buf;
> +    c->zstream.next_in   = (uint8_t*)buf;
>      c->zstream.avail_in  = buf_size;
>      c->zstream.next_out = c->decomp_buf;
>      c->zstream.avail_out = c->decomp_size;
> -- 
> 2.6.4
>
Carl Eugen Hoyos Sept. 10, 2019, 11:42 p.m.
Am Do., 5. Sept. 2019 um 00:45 Uhr schrieb <lance.lmwang@gmail.com>:
>
> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/tscc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c
> index 6d03081..b0dbef4 100644
> --- a/libavcodec/tscc.c
> +++ b/libavcodec/tscc.c
> @@ -88,7 +88,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
>          av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
>          return AVERROR_UNKNOWN;
>      }
> -    c->zstream.next_in   = buf;
> +    c->zstream.next_in   = (uint8_t*)buf;

Iirc, the warning also happens when compiling for android and the reason
is that their zlib header is different / old and therefore doesn't mark the
input as const (as the zlib header does on different systems here, both
new and old). I therefore believe this line should not be changed.

If it is changed, the commit message should first state was is done
("cast a pointer to avoid a warning") and the actual complete warning
should be part of the commit message.

Carl Eugen

(Checking Android sources seems to show that they have fixed
this issue in more recent versions.)
lance.lmwang@gmail.com Sept. 11, 2019, 10:48 p.m.
On Wed, Sep 11, 2019 at 01:42:38AM +0200, Carl Eugen Hoyos wrote:
> Am Do., 5. Sept. 2019 um 00:45 Uhr schrieb <lance.lmwang@gmail.com>:
> >
> > From: Limin Wang <lance.lmwang@gmail.com>
> >
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavcodec/tscc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c
> > index 6d03081..b0dbef4 100644
> > --- a/libavcodec/tscc.c
> > +++ b/libavcodec/tscc.c
> > @@ -88,7 +88,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
> >          av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
> >          return AVERROR_UNKNOWN;
> >      }
> > -    c->zstream.next_in   = buf;
> > +    c->zstream.next_in   = (uint8_t*)buf;
> 
> Iirc, the warning also happens when compiling for android and the reason
> is that their zlib header is different / old and therefore doesn't mark the
> input as const (as the zlib header does on different systems here, both
> new and old). I therefore believe this line should not be changed.
> 
> If it is changed, the commit message should first state was is done
> ("cast a pointer to avoid a warning") and the actual complete warning
> should be part of the commit message.
> 

Thanks for the feedback, I update the patch to use z_const to keep
backward compatibility. Now the default configure will define ZLIB_CONST,
so for new version zlib, it'll use z_const, or for old system, it'll force
to avoid comiler warning.  I have tested with mac pro(old zlib) and imac(new zlib). 

reference link:
https://gitlab.kitware.com/third-party/zlib/commit/5ab9f47745fe9353291b217f705086b6070575d5


> Carl Eugen
> 
> (Checking Android sources seems to show that they have fixed
> this issue in more recent versions.)
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Patch hide | download patch | download mbox

diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c
index 6d03081..b0dbef4 100644
--- a/libavcodec/tscc.c
+++ b/libavcodec/tscc.c
@@ -88,7 +88,7 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
         av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
         return AVERROR_UNKNOWN;
     }
-    c->zstream.next_in   = buf;
+    c->zstream.next_in   = (uint8_t*)buf;
     c->zstream.avail_in  = buf_size;
     c->zstream.next_out = c->decomp_buf;
     c->zstream.avail_out = c->decomp_size;