diff options
author | Yunhee Seo <yuni.seo@samsung.com> | 2024-09-23 11:25:21 +0900 |
---|---|---|
committer | Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com> | 2024-09-23 10:24:42 +0200 |
commit | 10ec12c2dfa91693abc49e2a29284c06b010f1d1 (patch) | |
tree | 2fc6de6203459e1238135675729b2afa79f4fec5 | |
parent | 8fe6059556fe75360f7d17f422baf48c3b05e855 (diff) | |
download | webapi-plugins-10ec12c2dfa91693abc49e2a29284c06b010f1d1.tar.gz webapi-plugins-10ec12c2dfa91693abc49e2a29284c06b010f1d1.tar.bz2 webapi-plugins-10ec12c2dfa91693abc49e2a29284c06b010f1d1.zip |
[Power] Fix variable type to avoid invalidationaccepted/tizen/unified/x/asan/20241013.235602accepted/tizen/unified/x/20240925.015909accepted/tizen/unified/toolchain/20241004.101306accepted/tizen/unified/20240924.153222
[Bug] Double can be represented with some inaccuracy e.g. 30.0 can be
29.999999 which in case of casting to int is casted to 29 instead of 30
as expected.
[Solution] Added std round to proper round double value to closest
inteager instead of cutting of the decimal part of number.
Change-Id: I20e889df9d6a0ff4434fc18b77016287f0bd45c7
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
-rw-r--r-- | src/power/power_manager.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/power/power_manager.cc b/src/power/power_manager.cc index 4973b0c4..db0b4fc6 100644 --- a/src/power/power_manager.cc +++ b/src/power/power_manager.cc @@ -183,7 +183,7 @@ PlatformResult PowerManager::SetScreenBrightness(double brightness) { return result; } - int platform_brightness = (int)(brightness * max_brightness_); + int platform_brightness = std::round(brightness * max_brightness_); if (0 == platform_brightness) { // The value '0' on native level is treated as setting ScreenState to "SCREEN_DIM", thus the // brightness values come from range from 1 to max_brightness_ (which is usually equal to |