[FFmpeg-devel] [PATCH] fix few compiler warnings

Michael Niedermayer michael at niedermayer.cc
Tue May 24 20:38:17 CEST 2016


On Sun, May 22, 2016 at 01:51:05AM +0000, Davinder Singh wrote:
> On Sun, May 22, 2016 at 2:09 AM Michael Niedermayer <michael at niedermayer.cc>
> wrote:
> 
> > On Sat, May 21, 2016 at 02:21:17PM +0000, Davinder Singh wrote:
> > > hi,
> > >
> > > this patch fixes following compiler warnings:
> > >
> > > libavcodec/cfhd.c:346:78: warning: format specifies type 'unsigned short'
> > > but the argument has type 'int' [-Wformat]
> > >             av_log(avctx, AV_LOG_DEBUG, "Small chunk length %"PRIu16"
> > > %s\n", data * 4, tag < 0 ? "optional" : "required");
> > >                                                             ~~
> > >   ^~~~~~~~
> > > libavcodec/cfhd.c:472:110: warning: format specifies type 'unsigned
> > short'
> > > but the argument has type 'int' [-Wformat]
> > >             av_log(avctx, AV_LOG_DEBUG, "Start of lowpass coeffs
> > component
> > > %"PRIu16" height:%d, width:%d\n", s->channel_num, lowpass_height,
> > > lowpass_width);
> > >
> > >  ~~                                ^~~~~~~~~~~~~~
> > > libavcodec/cfhd.c:490:77: warning: format specifies type 'unsigned short'
> > > but the argument has type 'int' [-Wformat]
> > >             av_log(avctx, AV_LOG_DEBUG, "Lowpass coefficients
> > %"PRIu16"\n",
> > > lowpass_width * lowpass_height);
> > >                                                               ~~
> > >  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >
> > >
> > >
> > > libavcodec/dv_tablegen.c:30:60: warning: format specifies type 'char' but
> > > the argument has type 'uint32_t' (aka 'unsigned int') [-Wformat]
> > >                    "{0x%"PRIx32", %"PRId8"}", data[i].vlc, data[i].size)
> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
> > > libavcodec/tableprint.h:37:29: note: expanded from macro
> > > 'WRITE_1D_FUNC_ARGV'
> > >        printf(" "fmtstr",", __VA_ARGS__);\
> > >                             ^~~~~~~~~~~
> > > libavcodec/dv_tablegen.c:30:60: warning: format specifies type 'char' but
> > > the argument has type 'uint32_t' (aka 'unsigned int') [-Wformat]
> > >                    "{0x%"PRIx32", %"PRId8"}", data[i].vlc, data[i].size)
> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
> > >
> > >
> > >
> > > libavfilter/af_hdcd.c:896:57: warning: shifting a negative signed value
> > is
> > > undefined [-Wshift-negative-value]
> > >             state->readahead = readaheadtab[bits & ~(-1 << 8)];
> > >
> > >
> > >
> > > libavfilter/vf_hwdownload.c:59:5: warning: ignoring return value of
> > > function declared with warn_unused_result attribute [-Wunused-result]
> > >     ff_formats_ref(infmts,  &avctx->inputs[0]->out_formats);
> > >     ^~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > libavfilter/vf_hwdownload.c:60:5: warning: ignoring return value of
> > > function declared with warn_unused_result attribute [-Wunused-result]
> > >     ff_formats_ref(outfmts, &avctx->outputs[0]->in_formats);
> > >     ^~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >
> > >
> > >
> > > libavutil/opencl.c:456:17: warning: variable 'kernel_source' is used
> > > uninitialized whenever 'for' loop exits because its condition is false
> > > [-Wsometimes-uninitialized]
> > >     for (i = 0; i < opencl_ctx.kernel_code_count; i++) {
> > >                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > libavutil/opencl.c:466:10: note: uninitialized use occurs here
> > >     if (!kernel_source) {
> > >          ^~~~~~~~~~~~~
> > > libavutil/opencl.c:456:17: note: remove the condition if it is always
> > true
> > >     for (i = 0; i < opencl_ctx.kernel_code_count; i++) {
> > >                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > libavutil/opencl.c:448:30: note: initialize the variable 'kernel_source'
> > to
> > > silence this warning
> > >     const char *kernel_source;
> > >                              ^
> > >                               = NULL
> >
> > >  libavcodec/cfhd.c           |    6 +++---
> > >  libavcodec/dv_tablegen.c    |    2 +-
> > >  libavfilter/af_hdcd.c       |    2 +-
> > >  libavfilter/vf_hwdownload.c |    6 ++++--
> > >  libavutil/opencl.c          |    2 +-
> >
> > please split this patch
> > the fixed warnings are unrelated to each other and possibly differnt
> > developers would like to reply to different parts
> >
> > [...]
> >
> > --
> > Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > I have often repented speaking, but never of holding my tongue.
> > -- Xenocrates
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
[...]

>  opencl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> b3b89a601cc0447677a9f0f375c20f1f63d66f42  0005-libavutil-opencl-fixed-uninitialized-var-warning.patch
> From 9259a055b908c12c7ab7c5f08aae95f3cdaacfa8 Mon Sep 17 00:00:00 2001
> From: dsmudhar <ds.mudhar at gmail.com>
> Date: Sun, 22 May 2016 06:29:27 +0530
> Subject: [PATCH 5/7] libavutil/opencl: fixed uninitialized var warning
> 
> ---
>  libavutil/opencl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavutil/opencl.c b/libavutil/opencl.c
> index 08b5034..af35770 100644
> --- a/libavutil/opencl.c
> +++ b/libavutil/opencl.c
> @@ -445,7 +445,7 @@ cl_program av_opencl_compile(const char *program_name, const char *build_opts)
>      int i;
>      cl_int status, build_status;
>      int kernel_code_idx = 0;
> -    const char *kernel_source;
> +    const char *kernel_source = NULL;

applied

[...]

>  vf_hwdownload.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 5eb7416fececde847414f37de9a78a4e1cd5e1af  0004-libavfilter-vf_hwdownload-show-error-when-ff_formats.patch
> From d1d00989a374facba3cdf777d95c61bf385f1332 Mon Sep 17 00:00:00 2001
> From: dsmudhar <ds.mudhar at gmail.com>
> Date: Sun, 22 May 2016 06:26:36 +0530
> Subject: [PATCH 4/7] libavfilter/vf_hwdownload: show error when ff_formats_ref
>  fails
> 
> ---
>  libavfilter/vf_hwdownload.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_hwdownload.c b/libavfilter/vf_hwdownload.c
> index 2dcc9fa..79ea82d 100644
> --- a/libavfilter/vf_hwdownload.c
> +++ b/libavfilter/vf_hwdownload.c
> @@ -56,8 +56,10 @@ static int hwdownload_query_formats(AVFilterContext *avctx)
>          }
>      }
>  
> -    ff_formats_ref(infmts,  &avctx->inputs[0]->out_formats);
> -    ff_formats_ref(outfmts, &avctx->outputs[0]->in_formats);
> +    if ((err = ff_formats_ref(infmts,  &avctx->inputs[0]->out_formats)) < 0 ||
> +        (err = ff_formats_ref(outfmts, &avctx->outputs[0]->in_formats)) < 0)
> +        return err;

applied

[...]

>  dv_tablegen.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 12cad8bbe5e995562b624c7125a6595ba4aa3507  0002-libavcodec-dv_tablegen-fixed-wrong-printf-format.patch
> From 90bb29867f877c3265837b1c8a2f00171593f173 Mon Sep 17 00:00:00 2001
> From: dsmudhar <ds.mudhar at gmail.com>
> Date: Sun, 22 May 2016 06:16:56 +0530
> Subject: [PATCH 2/7] libavcodec/dv_tablegen: fixed wrong printf format
> 
> ---
>  libavcodec/dv_tablegen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/dv_tablegen.c b/libavcodec/dv_tablegen.c
> index 2579341..d032101 100644
> --- a/libavcodec/dv_tablegen.c
> +++ b/libavcodec/dv_tablegen.c
> @@ -27,7 +27,7 @@
>  #include <inttypes.h>
>  
>  WRITE_1D_FUNC_ARGV(dv_vlc_pair, 7,
> -                   "{0x%"PRIx32", %"PRId8"}", data[i].vlc, data[i].size)
> +                   "{0x%"PRIx32", %"PRIu32"}", data[i].vlc, data[i].size)
>  WRITE_2D_FUNC(dv_vlc_pair)

applied

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Never trust a computer, one day, it may think you are the virus. -- Compn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160524/5ca0b228/attachment.sig>


More information about the ffmpeg-devel mailing list