From cae9edd999e5233a1ca54d34cd18d90596f125b6 Mon Sep 17 00:00:00 2001 From: Sitsofe Wheeler Date: Thu, 12 Oct 2017 17:09:48 +0100 Subject: [PATCH] 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 --- gettime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.25.1