From 889a110f73bca0bd4099f395389c674842a3204d Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 24 Sep 2019 11:43:49 +0900 Subject: [PATCH] Add float typecasting to prevent the loss of fractional part in division Change-Id: I596e67df50c253591bc8365e60623b31ca4c51d1 Signed-off-by: Youngjae Cho --- src/device_manager_plugin_emul.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/device_manager_plugin_emul.c b/src/device_manager_plugin_emul.c index ebca0c4..6f0e226 100644 --- a/src/device_manager_plugin_emul.c +++ b/src/device_manager_plugin_emul.c @@ -374,7 +374,7 @@ int OEM_sys_get_backlight_brightness(int index, int *value, int power_saving) devmgr_log("Can't read max_brightness node[%s]", path); return ret; } - pwr_saving_offset = (int)((PWR_SAVING_CANDELA_CRITERION * max_brightness / MAX_CANDELA_CRITERION) + 0.5); + pwr_saving_offset = (int)((PWR_SAVING_CANDELA_CRITERION * (float)max_brightness / MAX_CANDELA_CRITERION) + 0.5); if (*value > max_brightness - pwr_saving_offset) *value = max_brightness; @@ -409,7 +409,7 @@ static int OEM_sys_set_backlight_brightness(int index, int value, int power_savi devmgr_log("Can't read max_brightness node[%s]", path); return ret; } - pwr_saving_offset = (int)((PWR_SAVING_CANDELA_CRITERION * max_brightness / MAX_CANDELA_CRITERION) + 0.5); + pwr_saving_offset = (int)((PWR_SAVING_CANDELA_CRITERION * (float)max_brightness / MAX_CANDELA_CRITERION) + 0.5); if (value < pwr_saving_offset) value = 0; -- 2.7.4