Subject: Re: [PATCH iproute2 1/2] tc_core: Use double in tc_core_time2tick()

From: Patrick McHardy <[email-masked]>
Date: Tue, 09 Jun 2009 16:03:16 +0200

Jarek Poplawski wrote:
> Change 'time' parameters of tc_core_time2tick() and tc_core_time2big()
> from unsigned to double. It is especially needed to use in
> tc_calc_rtable() for kernels with increased psched ticks resolution,
> but even without this, it looks reasonable to avoid rounding here.

I would prefer to keep using integers, which are a lot easier to
analyze for rounding errors and overflows, besides having constant
granularity.

> -unsigned tc_core_time2tick(unsigned time)
> +unsigned tc_core_time2tick(double time)
>  {
> -	return time*tick_in_usec;
> +	return time * tick_in_usec + 0.5;

ceil()?

>  }

It seems inconsistent to have the time2tick() function take a
double, but return an unsigned from tick2time(). If we're going
to change this, please keep them symetrical (you could even use
floor() in tick2time() to make it more explicit).