summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Feist <james.feist@linux.intel.com>2019-12-05 15:01:55 -0800
committerJames Feist <james.feist@linux.intel.com>2019-12-09 21:41:02 +0000
commitb4b9595ad8d679f2f5e83bd75d9b0902620fb1f5 (patch)
tree0d57eec19a11286ae78a85e1893c2b44dd364f80
parent40d68ef6ebe088e4cd0078f8ff4910ca58f2be5d (diff)
downloadbmcweb-b4b9595ad8d679f2f5e83bd75d9b0902620fb1f5.tar.gz
bmcweb-b4b9595ad8d679f2f5e83bd75d9b0902620fb1f5.zip
ProcSummary: Use Nothrow
Exceptions are compiled out, and json.get throws, change it to get_ptr. Tested: no functional change Change-Id: Ie2db7285b89b45b1fd61d8526561b772c85151b3 Signed-off-by: James Feist <james.feist@linux.intel.com>
-rw-r--r--redfish-core/lib/systems.hpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 93eb403..e9ccde1 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -82,13 +82,18 @@ void modifyCpuPresenceState(std::shared_ptr<AsyncResp> aResp,
}
BMCWEB_LOG_DEBUG << "Cpu Present: " << *isCpuPresent;
- nlohmann::json &procCount =
- aResp->res.jsonValue["ProcessorSummary"]["Count"];
if (*isCpuPresent == true)
{
- procCount = procCount.get<int>() + 1;
+ nlohmann::json &procCount =
+ aResp->res.jsonValue["ProcessorSummary"]["Count"];
+ auto procCountPtr =
+ procCount.get_ptr<nlohmann::json::number_integer_t *>();
+ if (procCountPtr != nullptr)
+ {
+ // shouldn't be possible to be nullptr
+ *procCountPtr += 1;
+ }
}
- aResp->res.jsonValue["ProcessorSummary"]["Count"] = procCount;
}
/*
@@ -338,9 +343,18 @@ void getComputerSystem(std::shared_ptr<AsyncResp> aResp,
"ary"];
nlohmann::json &procCount =
procSummary["Count"];
- procCount =
- procCount.get<int>() +
- 1;
+
+ auto procCountPtr =
+ procCount.get_ptr<
+ nlohmann::json::
+ number_integer_t
+ *>();
+ if (procCountPtr != nullptr)
+ {
+ // shouldn't be possible
+ // to be nullptr
+ *procCountPtr += 1;
+ }
procSummary["Status"]
["State"] =
"Enabled";
OpenPOWER on IntegriCloud