diff options
author | James Feist <james.feist@linux.intel.com> | 2019-12-06 02:01:55 +0300 |
---|---|---|
committer | James Feist <james.feist@linux.intel.com> | 2019-12-10 00:41:02 +0300 |
commit | b4b9595ad8d679f2f5e83bd75d9b0902620fb1f5 (patch) | |
tree | 0d57eec19a11286ae78a85e1893c2b44dd364f80 | |
parent | 40d68ef6ebe088e4cd0078f8ff4910ca58f2be5d (diff) | |
download | bmcweb-b4b9595ad8d679f2f5e83bd75d9b0902620fb1f5.tar.xz |
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.hpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp index 93eb40354f..e9ccde177e 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"; |