From b4b9595ad8d679f2f5e83bd75d9b0902620fb1f5 Mon Sep 17 00:00:00 2001 From: James Feist Date: Thu, 5 Dec 2019 15:01:55 -0800 Subject: 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 --- redfish-core/lib/systems.hpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'redfish-core') 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 aResp, } BMCWEB_LOG_DEBUG << "Cpu Present: " << *isCpuPresent; - nlohmann::json &procCount = - aResp->res.jsonValue["ProcessorSummary"]["Count"]; if (*isCpuPresent == true) { - procCount = procCount.get() + 1; + nlohmann::json &procCount = + aResp->res.jsonValue["ProcessorSummary"]["Count"]; + auto procCountPtr = + procCount.get_ptr(); + 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 aResp, "ary"]; nlohmann::json &procCount = procSummary["Count"]; - procCount = - procCount.get() + - 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"; -- cgit v1.2.3