Add float typecasting to prevent the loss of fractional part in division
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 24 Sep 2019 02:43:49 +0000 (11:43 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 24 Sep 2019 02:43:49 +0000 (11:43 +0900)
Change-Id: I596e67df50c253591bc8365e60623b31ca4c51d1
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/device_manager_plugin_emul.c

index ebca0c4..6f0e226 100644 (file)
@@ -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;