Re: [PATCH] ktime: Fix ktime_divns to do signed division

From: Nicolas Pitre
Date: Fri May 01 2015 - 20:14:37 EST


On Fri, 1 May 2015, John Stultz wrote:

> static inline u64 ktime_divns(const ktime_t kt, s64 div)
> {
> if (__builtin_constant_p(div) && !(div >> 32)) {
> - u64 ns = kt.tv64;
> + s64 ns = kt.tv64;
> + int neg = 0;
> +
> + if (ns < 0) {
> + neg = 1;
> + ns = -ns;
> + }

Minor comment: you could save some realestate with:

s64 ns = kt.tv64;
bool neg = (ns < 0);

if (neg)
ns = -ns;


Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/