[FFmpeg-devel] [PATCH] work around some 'may be used uninitialized warnings'
Diego Biurrun
diego
Thu Mar 5 20:16:22 CET 2009
On Thu, Mar 05, 2009 at 12:43:02AM +0100, Aurelien Jacobs wrote:
> Benoit Fouet wrote:
>
> > On 03/03/2009 02:28 PM, Diego Biurrun wrote:
> > > Here is a patch to work around the 'may be used uninitialized warnings'
> > > in libavformat, please review. I will commit individual parts if OKed,
> > > not before.
> > >
> > > A bunch of these warnings seem to be legitimate. I initialized these
> > > variables to 0, but probably somebody should have a closer look at the
> > > code.
> >
> > --- libavformat/mpeg.c (revision 17759)
> > +++ libavformat/mpeg.c (working copy)
> > @@ -413,7 +413,7 @@
> > enum CodecType type;
> > int64_t pts, dts, dummy_pos; //dummy_pos is needed for the index building to work
> > - uint8_t dvdaudio_substream_type;
> > + uint8_t av_uninit(dvdaudio_substream_type);
>
> dvdaudio_substream_type indeed can't be used uninitialized, so this
> hunk looks OK.
Applied.
> > > --- libavformat/rmdec.c (revision 17759)
> > > +++ libavformat/rmdec.c (working copy)
> > > @@ -482,7 +482,7 @@
> > > RMDemuxContext *rm, RMStream *vst,
> > > AVPacket *pkt, int len)
> > > {
> > > - int hdr, seq, pic_num, len2, pos;
> > > + int hdr, seq=0, pic_num=0, len2=0, av_uninit(pos);
> > > int type;
> >
> > from what I read, they should all be av_uninit, no initialization is
> > needed, as type can only be 0, 1, 2 or 3.
>
> That's right. Anyway, gcc-4.3 is able to detect this and don't generate
> warning here, so no change needed.
I'll switch to gcc 4.3 soon...
> > > --- libavformat/utils.c (revision 17759)
> > > +++ libavformat/utils.c (working copy)
> > > @@ -1289,7 +1289,7 @@
> > >
> > > int av_seek_frame_binary(AVFormatContext *s, int stream_index,
> > int64_t target_ts, int flags){
> > > AVInputFormat *avif= s->iformat;
> > > - int64_t pos_min, pos_max, pos, pos_limit;
> > > + int64_t pos_min=0, pos_max=0, pos, pos_limit;
> > > int64_t ts_min, ts_max, ts;
> > > int index;
> > > AVStream *st;
> >
> > I had a look at this one once, and it appears that they are not used
> > uninitialized, if you know how av_gen_search() works
>
> That's right. pos_min and pos_max can't be used uninitialized with
> current code, so initializing them to 0 is not OK.
OK, marked as av_uninit then.
Diego
More information about the ffmpeg-devel
mailing list