Incorrect value displayed for total system memory
GUI displays 0 as total system memory when the total size is
not exactly divisible by 1024 as the code truncates the
floating point value.
This commit has the fix for it.
Change-Id: I95dc6f5ee9e36bb624315909a264c5d21c054a1d
Signed-off-by: Priyanga Ramasamy <priyanga24@in.ibm.com>
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index c30002a..69ef490 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -297,16 +297,17 @@
{
nlohmann::json& totalMemory =
asyncResp->res.jsonValue["MemorySummary"]["TotalSystemMemoryGiB"];
- const uint64_t* preValue = totalMemory.get_ptr<const uint64_t*>();
+ const double* preValue = totalMemory.get_ptr<const double*>();
if (preValue == nullptr)
{
asyncResp->res.jsonValue["MemorySummary"]["TotalSystemMemoryGiB"] =
- *memorySizeInKB / static_cast<size_t>(1024 * 1024);
+ static_cast<double>(*memorySizeInKB) / (1024 * 1024);
}
else
{
asyncResp->res.jsonValue["MemorySummary"]["TotalSystemMemoryGiB"] =
- *memorySizeInKB / static_cast<size_t>(1024 * 1024) + *preValue;
+ static_cast<double>(*memorySizeInKB) / (1024 * 1024) +
+ *preValue;
}
if constexpr (bmcwebEnableProcMemStatus)
{
@@ -3236,7 +3237,7 @@
"Disabled";
}
asyncResp->res.jsonValue["MemorySummary"]["TotalSystemMemoryGiB"] =
- uint64_t(0);
+ double(0);
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system";
asyncResp->res.jsonValue["Processors"]["@odata.id"] =