Re: [patch] min_delay bugfix.



Robert Love <rml novell com> writes:

> Dan,
>
> In src/NetworkManagerDevice.c :: nm_device_wireless_wait_for_link(), we
> set min_delay to
>
> 	const guint	delay = 30;
>  	const guint	required_tries = 10;
> 	const guint	min_delay = 2 * (required_tries / delay);
>
> That is zero.
>
> We then compare it to the timeout, an unsigned int.  The comparison is
> always false.
>
> Based on a comment below (which says we want to round the timeout up to
> 6 seconds), I think we really want
>
> 	const guint	min_delay = 2 * (delay / required_tries);

Actually, a better approach if you want to round up the dealy might be:

          const guint     min_delay = 
                2 * ((delay + required_tries - 1) / required_tries);

This way it doesn't matter which value is larger... As long as both
values are positive then the result will be at least "2".

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord MIT EDU                        PGP key available



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]