From 4e224776e65d7d0cbdaeb6ec36885add9052bd25 Mon Sep 17 00:00:00 2001 From: Veselin Georgiev Date: Mon, 18 Aug 2014 18:24:44 +0300 Subject: [PATCH] Shut up a warning in cpu_clock_by_ic(). Namely, printing a uint64_t with printf(...%llu...) is considered bad practice; you need to use the format specifier PRIu64, defined in inttypes.h. Apparently, it's not safe to assume that uint64_t == unsigned long long. However, I don't like this kind of formatting uglyness. The td variable on my machine is ~30k - and conceivably can't go above 1M. Moreover, this printf is only for detailed debug purposes. So it's safe to cast the var to int and print it with %d. --- libcpuid/rdtsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcpuid/rdtsc.c b/libcpuid/rdtsc.c index a13d983..5930681 100644 --- a/libcpuid/rdtsc.c +++ b/libcpuid/rdtsc.c @@ -275,7 +275,7 @@ int cpu_clock_by_ic(int millis, int runs) sys_precise_clock(&t1); } while (t1 - t0 < tl * (uint64_t) 8); // cpu_Hz = cycles_inner * cycles_outer * 256 / (t1 - t0) * 1000000 - debugf(2, "c = %d, td = %llu\n", c, t1 - t0); + debugf(2, "c = %d, td = %d\n", c, (int) (t1 - t0)); hz = ((uint64_t) cycles_inner * (uint64_t) 256 + 12) * (uint64_t) cycles_outer * (uint64_t) multiplier_numerator * (uint64_t) c * (uint64_t) 1000000 / ((t1 - t0) * (uint64_t) multiplier_denom);