From fbd7b7ad57cd0da74f51e18167ba235773cbff84 Mon Sep 17 00:00:00 2001 From: Dongwoo Lee Date: Thu, 25 Aug 2022 13:46:28 +0900 Subject: [PATCH] resource: process: Fix to convert to double before integer division In order to prevent losing floating point number for the result of integer division, integer value is coverted to double before calculation. Change-Id: I38c19c1468167ed1203417f03d187dcf0893e6ca Signed-off-by: Dongwoo Lee --- src/resource/resource-process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resource/resource-process.c b/src/resource/resource-process.c index dfbe086..4f68a78 100644 --- a/src/resource/resource-process.c +++ b/src/resource/resource-process.c @@ -112,7 +112,7 @@ static int process_get_mem_attrs(struct resource *res, double *percent = (double *)data; curr = &ctx->curr; - *percent = (curr->coremem * 1024) / curr->ac_stime; + *percent = (double)(curr->coremem * 1024) / curr->ac_stime; *percent /= total_memory * 100.0; break; } -- 2.34.1