diff options
author | Ed Tanous <ed@tanous.net> | 2024-04-07 23:37:25 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2024-04-11 21:21:57 +0300 |
commit | dc8cfa66f36470a2978300f7db616dc859dea0ec (patch) | |
tree | 81baa36f0cf74d2731f0a730c4b75392b47ccf93 /redfish-core | |
parent | 4c521c3c34162b6a5930ac1d78da3456f9b69283 (diff) | |
download | bmcweb-dc8cfa66f36470a2978300f7db616dc859dea0ec.tar.xz |
Add nullptr check
Change-Id: If511f1210cca7bd1da3a8c5152688487d3036e2f
Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core')
-rw-r--r-- | redfish-core/lib/log_services.hpp | 6 | ||||
-rw-r--r-- | redfish-core/lib/pcie.hpp | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index f27785d78f..7522c0349a 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -3957,7 +3957,11 @@ static bool fillPostCodeEntry( // Get the Message from the MessageRegistry const registries::Message* message = registries::getMessage("OpenBMC.0.2.BIOSPOSTCode"); - + if (message == nullptr) + { + BMCWEB_LOG_ERROR("Couldn't find known message?"); + return false; + } uint64_t currentCodeIndex = 0; uint64_t firstCodeTimeUs = 0; for (const std::pair<uint64_t, std::tuple<uint64_t, std::vector<uint8_t>>>& diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp index 9392916c47..223522b5f0 100644 --- a/redfish-core/lib/pcie.hpp +++ b/redfish-core/lib/pcie.hpp @@ -712,7 +712,11 @@ inline void addPCIeFunctionProperties( { const std::string* strProperty = std::get_if<std::string>(&property.second); - + if (strProperty == nullptr) + { + BMCWEB_LOG_ERROR("Function wasn't a string?"); + continue; + } if (property.first == functionName + "DeviceId") { resp.jsonValue["DeviceId"] = *strProperty; @@ -799,11 +803,12 @@ inline void systemName); return; } + std::string_view pcieFunctionIdView = pcieFunctionIdStr; uint64_t pcieFunctionId = 0; std::from_chars_result result = std::from_chars( - &*pcieFunctionIdStr.begin(), &*pcieFunctionIdStr.end(), pcieFunctionId); - if (result.ec != std::errc{} || result.ptr != &*pcieFunctionIdStr.end()) + pcieFunctionIdView.begin(), pcieFunctionIdView.end(), pcieFunctionId); + if (result.ec != std::errc{} || result.ptr != pcieFunctionIdView.end()) { messages::resourceNotFound(asyncResp->res, "PCIeFunction", pcieFunctionIdStr); |