From: Jim Warner Date: Wed, 29 Nov 2017 06:00:00 +0000 (-0600) Subject: library: correct 'use' calculations for api X-Git-Tag: v4.0.0~672 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6634e813d4e1d7655e6788d9ea646849d67a4f02;p=procps-ng library: correct 'use' calculations for api Awhile back, the calculation for cache utilization was corrected to avoid a 32 bit overflow. This commit just brings this branch into line with that earlier change. [ references shown below represent the master branch ] Reference(s): commit 23ba442c886f6250d1068a82fb7d0fc544acfd63 https://gitlab.com/procps-ng/procps/merge_requests/29 http://www.freelists.org/post/procps/fix-regression-created-by-99d71ad Signed-off-by: Jim Warner --- diff --git a/proc/slabinfo.c b/proc/slabinfo.c index 2bd6b568..ba0219c4 100644 --- a/proc/slabinfo.c +++ b/proc/slabinfo.c @@ -427,7 +427,7 @@ static int parse_slabinfo20 ( node->cache_size = (unsigned long)node->nr_slabs * node->pages_per_slab * page_size; if (node->nr_objs) { - node->use = (unsigned int)100 * (node->nr_active_objs / node->nr_objs); + node->use = (unsigned int)(100 * ((float)node->nr_active_objs / node->nr_objs)); slabs->nr_active_caches++; } else node->use = 0;