diff options
author | njl <njl@FreeBSD.org> | 2004-06-24 00:38:51 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2004-06-24 00:38:51 +0000 |
commit | 1f3c0d81182f0e6936642aa3d8a1d0004a3a84e0 (patch) | |
tree | 2328d4b8124d4cae9423a381455c285aa2be2050 /sys/dev/acpica | |
parent | b6e99841cc0d8b6330ee831b18bad59ab0257297 (diff) | |
download | FreeBSD-src-1f3c0d81182f0e6936642aa3d8a1d0004a3a84e0.zip FreeBSD-src-1f3c0d81182f0e6936642aa3d8a1d0004a3a84e0.tar.gz |
Use uintmax_t for CPU statistics and add a cast to prevent truncation of
the statistics in a multiply.
Pointed out by: YONETANI Tomokazu
Diffstat (limited to 'sys/dev/acpica')
-rw-r--r-- | sys/dev/acpica/acpi_cpu.c | 4 |
1 files changed, 2 insertions, 2 deletions
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)); |