diff options
| author | Shivraj Toravi <shivrajnt@ami.com> | 2026-08-07 09:27:51 +0300 |
|---|---|---|
| committer | Gunnar Mills <gunnar@gmills.xyz> | 2026-08-11 17:28:22 +0300 |
| commit | c3bbbdf1b4c55f16786280dcf7a0fcc4cd8e87bc (patch) | |
| tree | 5410d650e35442a2ac7a6204e20b54ddc7b01cff | |
| parent | f188deed858de6148365763e641eb5d397e21c23 (diff) | |
| download | bmcweb-c3bbbdf1b4c55f16786280dcf7a0fcc4cd8e87bc.tar.xz | |
redfish-core: Refactor ThermalMetrics lambda
The handleThermalMetricsHead function contained an inline lambda that
triggered the long-lambda ast-grep rule, requiring an inline
suppression (// ast-grep-ignore: long-lambda).
This commit extracts the lambda into a separate doThermalMetricsHead
function and uses std::bind_front to handle the asynchronous callback.
This aligns the code with the preferred bmcweb pattern for D-Bus
callbacks, improves readability, and allows the removal of the static
analysis suppression.
Change-Id: I656e9d03e0780ac252d8778c825c12def9eac89e
Signed-off-by: Shivraj Toravi <shivrajnt@ami.com>
| -rw-r--r-- | redfish-core/lib/thermal_metrics.hpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/redfish-core/lib/thermal_metrics.hpp b/redfish-core/lib/thermal_metrics.hpp index e52246a0db..0b2c792f71 100644 --- a/redfish-core/lib/thermal_metrics.hpp +++ b/redfish-core/lib/thermal_metrics.hpp @@ -151,6 +151,21 @@ inline void doThermalMetrics( getTemperatureReadingsCelsius(asyncResp, *validChassisPath, chassisId); } +inline void doThermalMetricsHead( + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId, + const std::optional<std::string>& validChassisPath) +{ + if (!validChassisPath) + { + messages::resourceNotFound(asyncResp->res, "Chassis", chassisId); + return; + } + asyncResp->res.addHeader( + boost::beast::http::field::link, + "</redfish/v1/JsonSchemas/ThermalMetrics/ThermalMetrics.json>; rel=describedby"); +} + inline void handleThermalMetricsHead( App& app, const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, @@ -163,19 +178,7 @@ inline void handleThermalMetricsHead( redfish::chassis_utils::getValidChassisPath( asyncResp, chassisId, - // ast-grep-ignore: long-lambda - [asyncResp, - chassisId](const std::optional<std::string>& validChassisPath) { - if (!validChassisPath) - { - messages::resourceNotFound(asyncResp->res, "Chassis", - chassisId); - return; - } - asyncResp->res.addHeader( - boost::beast::http::field::link, - "</redfish/v1/JsonSchemas/ThermalMetrics/ThermalMetrics.json>; rel=describedby"); - }); + std::bind_front(doThermalMetricsHead, asyncResp, chassisId)); } inline void handleThermalMetricsGet( |
