On Fri, Jun 19, 2015 at 10:20:59AM +0100, Stuart Henderson wrote: > On 2015/06/19 11:11, Theo Buehler wrote: > > In video(1)'s verbose mode, this results in a bogus `run time' being > > printed due to the use of the uninitialized variable `tp_start', which > > is only initialized after the first frame was grabbed successfully. > > > --- app/video/video.c 23 Oct 2014 07:36:06 -0000 1.12 > > +++ app/video/video.c 19 Jun 2015 09:06:27 -0000 > > @@ -1406,6 +1406,10 @@ stream(struct video *vid) > > long frames_played = -1, frames_grabbed = 0, fus = 50000; > > int sequence = 20, ret, err, todo, done; > > > > + /* Guard against uninitialized variable in case no frame is grabbed. */ > > + if (vid->verbose > 0) > > + gettimeofday(&tp_start, NULL); > > + > > if (vid->fps && !vid->nofps) { > > fus = 1000000 / vid->fps; > > timerclear(&frit.it_value); > > Wouldn't it be simpler (and more robust if something else ever changed > to rely on tp_start) to do this unconditionally rather than just for > verbose mode? >
You're probably right. Like so? Index: app/video/video.c =================================================================== RCS file: /cvs/xenocara/app/video/video.c,v retrieving revision 1.12 diff -u -p -r1.12 video.c --- app/video/video.c 23 Oct 2014 07:36:06 -0000 1.12 +++ app/video/video.c 19 Jun 2015 09:23:52 -0000 @@ -1406,6 +1406,9 @@ stream(struct video *vid) long frames_played = -1, frames_grabbed = 0, fus = 50000; int sequence = 20, ret, err, todo, done; + /* Guard against uninitialized variable in case no frame is grabbed. */ + gettimeofday(&tp_start, NULL); + if (vid->fps && !vid->nofps) { fus = 1000000 / vid->fps; timerclear(&frit.it_value);