diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-05-23 12:06:35 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-05-23 12:06:35 +0200 |
commit | 50da095243745f2e2a0c3f4805fe187a392832b7 (patch) | |
tree | 857c1b56a68717101776f00e1cce6ffba2c857a5 /utils | |
parent | d8a9c7d02629049bcd451d4d9b93fdfaa7c2c8fb (diff) |
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.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/vmstat.c | 3 |
1 files changed, 2 insertions, 1 deletions
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 |