[SystemInfo] Adding casting int to double + fix InchToMm constant 17/139517/3
authorSzymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
Wed, 19 Jul 2017 10:35:55 +0000 (12:35 +0200)
committerSzymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
Wed, 19 Jul 2017 10:35:55 +0000 (12:35 +0200)
SVACE detected problem with code NO_CAST.INTEGER_DIVISION.

[Verification] Code compiles, TCT SystemInfo passed 100%.

Change-Id: Ie6249780860cd61a8c331d77648b6d37b9241c4c
Signed-off-by: Szymon Jastrzebski <s.jastrzebsk@partner.samsung.com>
src/systeminfo/systeminfo_properties_manager.cc

index 8a5c6e499ac80872d0a58fbc9e3f6b4283d13174..75bb33c31ad1c3c825e9b922146cc90e02f65556 100644 (file)
@@ -42,7 +42,7 @@ using common::ErrorCode;
 namespace {
 const std::string kMemoryStateNormal = "NORMAL";
 const std::string kMemoryStateWarinig = "WARNING";
-const double kDisplayInchToMillimeter = 2.54;
+const double kDisplayInchToMillimeter = 25.4;
 //Battery
 const double kRemainingBatteryChargeMax = 100.0;
 const int kVconfErrorNone = 0;
@@ -306,7 +306,7 @@ PlatformResult SysteminfoPropertiesManager::ReportDisplay(picojson::object* out)
 
   //FETCH PHYSICAL WIDTH
   if (dotsPerInchWidth != 0 && screenWidth != 0) {
-    physicalWidth = (screenWidth / dotsPerInchWidth) * kDisplayInchToMillimeter;
+    physicalWidth = (static_cast<double>(screenWidth) / dotsPerInchWidth) * kDisplayInchToMillimeter;
   } else {
     std::string log_msg = "Failed to get physical screen width value";
     LoggerE("%s, screenWidth : %d, dotsPerInchWidth: %d", log_msg.c_str(),
@@ -315,7 +315,7 @@ PlatformResult SysteminfoPropertiesManager::ReportDisplay(picojson::object* out)
 
   //FETCH PHYSICAL HEIGHT
   if (dotsPerInchHeight != 0 && screenHeight != 0) {
-    physicalHeight = (screenHeight / dotsPerInchHeight) * kDisplayInchToMillimeter;
+    physicalHeight = (static_cast<double>(screenHeight) / dotsPerInchHeight) * kDisplayInchToMillimeter;
   } else {
     std::string log_msg = "Failed to get physical screen height value";
     LoggerE("%s, screenHeight : %d, dotsPerInchHeight: %d", log_msg.c_str(),