[PATCH] ARM: type casts update_sched_clock cyc_to_sched_clock cyc_to_fixed_sched_clock

Russell King - ARM Linux linux at arm.linux.org.uk
Tue Apr 5 09:57:06 EDT 2011


On Tue, Apr 05, 2011 at 01:12:57PM +0200, Uwe Kleine-König wrote:
> ah, ok, makes sense and actually is consistent with my book.
> (After knowing what I search I found it. The rules are:
> 
>  - A signed type of rank less than int
>    -> int
>  - An unsigned type of rank less than int,
>    all of whose values can be represented in type int
>    -> int
>  - An unsigned type of rank less than int,
>    all of whose values cannot be represented in type int
>    -> unsigned int
> ).
> 
> So the maximal correct variant is (u32)(int)~0U or alternatively
> (u32)(-1), right?

If you really want to be pedantic, (u32)~0UL, as we assume that longs
will always be equal or larger than 32-bit throughout the kernel.  The
u32 cast then becomes truncating in itself.

But... in the interests of avoiding churn, we know the current code
works, we know that its safe should we chose to change the function
argument to be a u64, so lets leave it as-is.  We know the only time
that it'd break is if an 'int' becomes less than 32-bit, which we
aren't going to see on ARM any time soon.



More information about the linux-arm-kernel mailing list