Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hrtimer: Cast explicitely to u32t in __ktime_divns()

do_div() does a 64-by-32 division at least on 32bit platforms, while the
divisor 'div' is explicitly casted to unsigned long, thus 64-bit on 64-bit
platforms.

The code already ensures that the divisor is less than 2^32. Hence the
proper cast type is u32.

Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200130130851.29204-1-wenyang@linux.alibaba.com

authored by

Wen Yang and committed by
Thomas Gleixner
38f7b0b1 4cbbc3a0

+1 -1
+1 -1
kernel/time/hrtimer.c
··· 311 311 div >>= 1; 312 312 } 313 313 tmp >>= sft; 314 - do_div(tmp, (unsigned long) div); 314 + do_div(tmp, (u32) div); 315 315 return dclc < 0 ? -tmp : tmp; 316 316 } 317 317 EXPORT_SYMBOL_GPL(__ktime_divns);