On Wednesday 14 January 2009 14:21, walter harms wrote:
> >>   unsigned timestamp_before_wait=0;
> >>
> >> will do the same ?
> > 
> > Yes. but
> > 
> > unsigned timestamp_before_wait = timestamp_before_wait;
> > 
> > is better wrt code size. :)
> > 
> > fixed. thanks.
> > 
> 
> aehm, that will only fool the compiler to thing it is used.
> timestamp_before_wait=0 will make sure that it works even if the 'if 
> (tv.tv_sec > 0)' fails.
> and it will fail because:
> 
>         timeout = 0;
>         already_waited_sec = 0;
> ...
>         tv.tv_sec = timeout - already_waited_sec;             
>       if (tv.tv_sec > 0)
>               timestamp_before_wait = (unsigned)monotonic_sec();
> ...   
>       already_waited_sec += (unsigned)monotonic_sec() - timestamp_before_wait;

It's the choice between smaller code and more clearly written code.

In this particular case, do you see a way for timestamp_before_wait
to be used w/o initialization?
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to