From 1f3c0d81182f0e6936642aa3d8a1d0004a3a84e0 Mon Sep 17 00:00:00 2001 From: njl Date: Thu, 24 Jun 2004 00:38:51 +0000 Subject: Use uintmax_t for CPU statistics and add a cast to prevent truncation of the statistics in a multiply. Pointed out by: YONETANI Tomokazu --- sys/dev/acpica/acpi_cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/dev/acpica') diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 3691c81..b52ef7a 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -1046,7 +1046,7 @@ acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS) struct sbuf sb; char buf[128]; int i; - uint64_t fract, sum, whole; + uintmax_t fract, sum, whole; sum = 0; for (i = 0; i < cpu_cx_count; i++) @@ -1054,7 +1054,7 @@ acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS) sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN); for (i = 0; i < cpu_cx_count; i++) { if (sum > 0) { - whole = cpu_cx_stats[i] * 100; + whole = (uintmax_t)cpu_cx_stats[i] * 100; fract = (whole % sum) * 100; sbuf_printf(&sb, "%u.%02u%% ", (u_int)(whole / sum), (u_int)(fract / sum)); -- cgit v1.1