[Dnsmasq-discuss] (no subject)

Simon Kelley simon at thekelleys.org.uk
Tue Feb 13 20:30:44 GMT 2007


Jan 'RedBully' Seiffert wrote:

> hmmm, or not? Rules of implicit type conversion...
> Is the difftime result casted to an int or the int casted to a double:
> Good?
> 
>>./src/rfc2131.c:976:  else if (lease && lease->expires != 0 && difftime(lease->expires, now) > 0.0)
> 
> Bad?
> 
>>./src/lease.c:251:      if ((lease->expires != 0 && difftime(now, lease->expires) > 0) || lease == target)
> 
> 
> Simon?

My understanding  is that both of those work to determine which of the 
tho timevals is larger. I don't think you can be sure to eliminate all 
FP operations in either case by wrapping difftime. All of this is just a 
portable way to find the order of two time_t variables. It's a pity 
there isn't a way to do that portably without involving FP.


Cheers,

Simon.




More information about the Dnsmasq-discuss mailing list