svn commit: r214781 - head/sbin/camcontrol

Alexander Motin mav at FreeBSD.org
Thu Nov 4 17:49:36 UTC 2010


Bruce Cran wrote:
> Author: brucec
> Date: Thu Nov  4 15:24:32 2010
> New Revision: 214781
> URL: http://svn.freebsd.org/changeset/base/214781
> 
> Log:
>   Fix standby timer calculation: the timer was being set 30 minutes later
>   than the user requested.
>   Also, 21 minutes is encoded as 252 and 22-29 minutes cannot be encoded
>   so must be rounded up to 30.
>   
>   PR:	bin/151871
> 
> Modified:
>   head/sbin/camcontrol/camcontrol.c
> 
> Modified: head/sbin/camcontrol/camcontrol.c
> ==============================================================================
> --- head/sbin/camcontrol/camcontrol.c	Thu Nov  4 12:33:07 2010	(r214780)
> +++ head/sbin/camcontrol/camcontrol.c	Thu Nov  4 15:24:32 2010	(r214781)
> @@ -4316,10 +4316,17 @@ atapm(struct cam_device *device, int arg
>  		sc = 0;
>  	else if (t <= (240 * 5))
>  		sc = t / 5;
> +	else if (t == (252 * 5))

There should be "<=".

> +		/* special encoding for 21 minutes */
> +		sc = 252;
> +	else if (t < (30 * 60))
> +		/* no encoding exists for 22-29 minutes, so set to 30 mins */
> +		sc = 241;
>  	else if (t <= (11 * 30 * 60))
> -		sc = t / (30 * 60) + 241;
> +		sc = t / (30 * 60) + 240;

This will round period down. You will get 30 minutes instead of 59. In
this case rounding up IMHO more appropriate. I agree that previous
rounding up was over aggressive. I would prefer something like:
		sc = (t - 1) / (30 * 60) + 241;
or at least
		sc = (t + 15 * 60) / (30 * 60) + 240;
This will also make previous range unneeded.

Range "t <= (240 * 5)" probably also should be corrected to round up or
at least closest.

-- 
Alexander Motin


More information about the svn-src-all mailing list