From: Sitsofe Wheeler Date: Thu, 12 Oct 2017 16:09:48 +0000 (+0100) Subject: gettime: fix cycles_per_msec overflow when using 32 bit longs X-Git-Tag: fio-3.2~29^2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=cae9edd999e5233a1ca54d34cd18d90596f125b6;p=fio.git gettime: fix cycles_per_msec overflow when using 32 bit longs Compiling fio with clang's undefined behaviour sanitizer and unsigned wraparound detection enabled on a 32 bit Linux build turned up the following: gettime.c:313:28: runtime error: unsigned integer overflow: 3600 * 2600730 cannot be represented in type 'unsigned long' Fix this by making cycles_per_msec a long long. Signed-off-by: Sitsofe Wheeler --- diff --git a/gettime.c b/gettime.c index 79455284..1cbef84b 100644 --- a/gettime.c +++ b/gettime.c @@ -15,7 +15,7 @@ #if defined(ARCH_HAVE_CPU_CLOCK) #ifndef ARCH_CPU_CLOCK_CYCLES_PER_USEC -static unsigned long cycles_per_msec; +static unsigned long long cycles_per_msec; static unsigned long long cycles_start; static unsigned long long clock_mult; static unsigned long long max_cycles_mask;