[FFmpeg-devel] [PATCH] [RFC] fix 'may be used uninitialized' warnings

Måns Rullgård mans
Mon Feb 2 11:54:15 CET 2009


Diego Biurrun <diego at biurrun.de> writes:

> Here is a patch to fix all but one 'may be used initialized' warning
> in FFmpeg.  Regression tests pass, so this cannot have broken things
> too badly, but some of it may nonetheless be suspicious.
>
> Please review, I will commit individual hunks as they get approved,
> not before.
>
> Index: libavcodec/motion_est.c
> ===================================================================
> --- libavcodec/motion_est.c	(revision 16938)
> +++ libavcodec/motion_est.c	(working copy)
> @@ -536,7 +536,7 @@
>      const int size= 1;
>      const int h=8;
>      int block;
> -    int P[10][2];
> +    int P[10][2] = {0, 0};
>      int dmin_sum=0, mx4_sum=0, my4_sum=0;
>      int same=1;
>      const int stride= c->stride;
> @@ -686,7 +686,7 @@
>      const int size=0;
>      const int h=8;
>      int block;
> -    int P[10][2];
> +    int P[10][2] = {0, 0};
>      uint8_t * const mv_penalty= c->current_mv_penalty;
>      int same=1;
>      const int stride= 2*s->linesize;

Those initialisers are incorrect, lacking a set of braces.  The
correct syntax would be {{0}, {0}}.  The simpler {} is also correct.
GCC should issue a warning about this, something like "missing braces
in initialiser".

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list