From 50da095243745f2e2a0c3f4805fe187a392832b7 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 23 May 2015 12:06:35 +0200 Subject: utils/vmstat: fix integer overflow Previously, the `vmstat' utility would stop displaying the memory object hit ratio after some time due to an integer overflow. * utils/vmstat.c (get_memobj_hit_ratio): Fix integer overflow. --- utils/vmstat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/vmstat.c b/utils/vmstat.c index e3944848..92a36726 100644 --- a/utils/vmstat.c +++ b/utils/vmstat.c @@ -242,7 +242,8 @@ vm_state_get_field (struct vm_state *state, const struct field *field) static val_t get_memobj_hit_ratio (struct vm_state *state, const struct field *field) { - return state->vmstats.hits * 100 / state->vmstats.lookups; + return (val_t) + ((float) state->vmstats.hits * 100. / (float) state->vmstats.lookups); } /* Makes sure STATE contains a default pager port and associated info, and -- cgit v1.2.3