resource: process: Fix to convert to double before integer division 28/280228/1
authorDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 25 Aug 2022 04:46:28 +0000 (13:46 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 25 Aug 2022 10:53:10 +0000 (19:53 +0900)
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 <dwoo08.lee@samsung.com>
src/resource/resource-process.c

index dfbe086..4f68a78 100644 (file)
@@ -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;
        }