[FFmpeg-devel] [PATCH] avformat/hlsenc: compiler warning fix

Carl Eugen Hoyos ceffmpeg at gmail.com
Mon Jan 20 15:25:42 EET 2020


Am Mo., 20. Jan. 2020 um 14:18 Uhr schrieb Bodecs Bela <bodecsb at vivanet.hu>:
>
>
> 2020.01.20. 14:02 keltezéssel, Carl Eugen Hoyos írta:
> >
> >>>>>>>> This patch corrects compiler warning about returning possibly uninitialized
> >>>>>>>> variable in hls_write_header function.
> >>>>>>>>
> >>>>>>>> Which compiler warns about this?
> >>>>>> libavformat/hlsenc.c: In function ‘hls_write_header’:
> >>>>>> libavformat/hlsenc.c:2174: warning: ‘ret’ may be used uninitialized in
> >>>>>> this function
> >>>>> Looks like a false positive, does not warn with newer compilers.
> >>>> yes and no.
> >>>>
> >>>> no, because if hls->nb_varstreams == 0, then for loop body never
> >>>> executes and so ret does not get any value.
> >>>>
> >>>> yes, because there is no chance for hls->nb_varstreams to be zero.
> >>>>
> >>>> so, I think setting ret to 0 at its declaration does not do any problem
> >>>> and logically right.
> >>> No, update your compiler instead.
> >> which of my statements did your "No" reference?
> > Both.
>
> Thank you for your help. Maybe due to my poor english, but I really do
> not see,
>
> I really did  test with other compiler and really did not give warning
> any longer,
>
> but it does not help that the ret varaiable remain uninitalized but may
> be returned.
>
> As I know theoretically there is no default value of an int variable.
>
> So why the warning did disappear?

I believe newer compilers detect that hls->nb_varstreams cannot
be zero.

Carl Eugen


More information about the ffmpeg-devel mailing list