summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-03-17 04:04:41 +0300
committerEd Tanous <ed@tanous.net>2024-03-27 22:17:59 +0300
commitd547d8d2c30a7d00852855da8ecc15c0cc424b0e (patch)
tree2bbb8dbb164443c963c5556bfb18d80e20153cb8 /redfish-core
parent49cc263fdcfc9b279c399c0b03bfd7e9167e06c2 (diff)
downloadbmcweb-d547d8d2c30a7d00852855da8ecc15c0cc424b0e.tar.xz
Check optionals in tidy
clang-tidy-18 makes this feature stable enough for us to use in general. Enable the check, and fix the couple of regressions that have snuck in since we last ran the check. Tidy seems to not be able to understand that ASSERT will not continue, so if we ASSERT a std::optional, it's not a bug. Add explicit checks to keep tidy happy. Tested: clang-tidy passes. Change-Id: I0986453851da5471056a7b47b8ad57a9801df259 Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/ethernet.hpp49
-rw-r--r--redfish-core/lib/fan.hpp6
2 files changed, 22 insertions, 33 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 8bd4cdc62b..8ef8b5a44c 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1775,54 +1775,43 @@ inline void handleIPv6StaticAddressesPatch(
return;
}
- const std::string* addr = nullptr;
- uint8_t prefix = 0;
-
// Find the address and prefixLength values. Any values that are
// not explicitly provided are assumed to be unmodified from the
// current state of the interface. Merge existing state into the
// current request.
- if (address)
- {
- addr = &(*address);
- }
- else if (nicIpEntry != ipv6Data.end())
- {
- addr = &(nicIpEntry->address);
- }
- else
+ if (!address)
{
- messages::propertyMissing(asyncResp->res,
- pathString + "/Address");
- return;
+ if (nicIpEntry == ipv6Data.end())
+ {
+ messages::propertyMissing(asyncResp->res,
+ pathString + "/Address");
+ return;
+ }
+ address = nicIpEntry->address;
}
- if (prefixLength)
- {
- prefix = *prefixLength;
- }
- else if (nicIpEntry != ipv6Data.end())
- {
- prefix = nicIpEntry->prefixLength;
- }
- else
+ if (!prefixLength)
{
- messages::propertyMissing(asyncResp->res,
- pathString + "/PrefixLength");
- return;
+ if (nicIpEntry == ipv6Data.end())
+ {
+ messages::propertyMissing(asyncResp->res,
+ pathString + "/PrefixLength");
+ return;
+ }
+ prefixLength = nicIpEntry->prefixLength;
}
if (nicIpEntry != ipv6Data.end())
{
deleteAndCreateIPAddress(IpVersion::IpV6, ifaceId,
- nicIpEntry->id, prefix, *addr, "",
- asyncResp);
+ nicIpEntry->id, *prefixLength,
+ *address, "", asyncResp);
nicIpEntry = getNextStaticIpEntry(++nicIpEntry,
ipv6Data.cend());
}
else
{
- createIPv6(ifaceId, *prefixLength, *addr, asyncResp);
+ createIPv6(ifaceId, *prefixLength, *address, asyncResp);
}
entryIdx++;
}
diff --git a/redfish-core/lib/fan.hpp b/redfish-core/lib/fan.hpp
index 8915229e27..39b9e2abd7 100644
--- a/redfish-core/lib/fan.hpp
+++ b/redfish-core/lib/fan.hpp
@@ -50,11 +50,11 @@ inline void
inline void getFanPaths(
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::optional<std::string>& validChassisPath,
+ const std::string& validChassisPath,
const std::function<void(const dbus::utility::MapperGetSubTreePathsResponse&
fanPaths)>& callback)
{
- sdbusplus::message::object_path endpointPath{*validChassisPath};
+ sdbusplus::message::object_path endpointPath{validChassisPath};
endpointPath /= "cooled_by";
dbus::utility::getAssociatedSubTreePaths(
@@ -101,7 +101,7 @@ inline void doFanCollection(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
asyncResp->res.jsonValue["Members@odata.count"] = 0;
- getFanPaths(asyncResp, validChassisPath,
+ getFanPaths(asyncResp, *validChassisPath,
std::bind_front(updateFanList, asyncResp, chassisId));
}