diff options
author | Ed Tanous <edtanous@google.com> | 2022-05-31 18:59:27 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-06-01 19:10:35 +0300 |
commit | 002d39b4a7a5ed7166e2acad84e0943c3def9492 (patch) | |
tree | 4307dd5161ec9779d59308a9b933e408cc2c6ca7 /redfish-core/lib/metric_report.hpp | |
parent | 62c416fb0d2f62e09d7f60754ff359ac2389e749 (diff) | |
download | bmcweb-002d39b4a7a5ed7166e2acad84e0943c3def9492.tar.xz |
Try to fix the lambda formatting issue
clang-tidy has a setting, LambdaBodyIndentation, which it says:
"For callback-heavy code, it may improve readability to have the
signature indented two levels and to use OuterScope."
bmcweb is very callback heavy code. Try to enable it and see if that
improves things. There are many cases where the length of a lambda call
will change, and reindent the entire lambda function. This is really
bad for code reviews, as it's difficult to see the lines changed. This
commit should resolve it. This does have the downside of reindenting a
lot of functions, which is unfortunate, but probably worth it in the
long run.
All changes except for the .clang-format file were made by the robot.
Tested: Code compiles, whitespace changes only.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ib4aa2f1391fada981febd25b67dcdb9143827f43
Diffstat (limited to 'redfish-core/lib/metric_report.hpp')
-rw-r--r-- | redfish-core/lib/metric_report.hpp | 106 |
1 files changed, 49 insertions, 57 deletions
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp index a47f6efcf4..3dd7181558 100644 --- a/redfish-core/lib/metric_report.hpp +++ b/redfish-core/lib/metric_report.hpp @@ -68,22 +68,20 @@ inline void requestRoutesMetricReportCollection(App& app) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) - { - return; - } - - asyncResp->res.jsonValue["@odata.type"] = - "#MetricReportCollection.MetricReportCollection"; - asyncResp->res.jsonValue["@odata.id"] = - telemetry::metricReportUri; - asyncResp->res.jsonValue["Name"] = "Metric Report Collection"; - const std::vector<const char*> interfaces{ - telemetry::reportInterface}; - collection_util::getCollectionMembers( - asyncResp, telemetry::metricReportUri, interfaces, - "/xyz/openbmc_project/Telemetry/Reports/TelemetryService"); - }); + if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) + { + return; + } + + asyncResp->res.jsonValue["@odata.type"] = + "#MetricReportCollection.MetricReportCollection"; + asyncResp->res.jsonValue["@odata.id"] = telemetry::metricReportUri; + asyncResp->res.jsonValue["Name"] = "Metric Report Collection"; + const std::vector<const char*> interfaces{telemetry::reportInterface}; + collection_util::getCollectionMembers( + asyncResp, telemetry::metricReportUri, interfaces, + "/xyz/openbmc_project/Telemetry/Reports/TelemetryService"); + }); } inline void requestRoutesMetricReport(App& app) @@ -94,49 +92,43 @@ inline void requestRoutesMetricReport(App& app) [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& id) { - if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) + if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) + { + return; + } + const std::string reportPath = telemetry::getDbusReportPath(id); + crow::connections::systemBus->async_method_call( + [asyncResp, id, reportPath](const boost::system::error_code& ec) { + if (ec.value() == EBADR || + ec == boost::system::errc::host_unreachable) + { + messages::resourceNotFound(asyncResp->res, "MetricReport", id); + return; + } + if (ec) + { + BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + messages::internalError(asyncResp->res); + return; + } + + sdbusplus::asio::getProperty<telemetry::TimestampReadings>( + *crow::connections::systemBus, telemetry::service, reportPath, + telemetry::reportInterface, "Readings", + [asyncResp, id](const boost::system::error_code ec, + const telemetry::TimestampReadings& ret) { + if (ec) { + BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + messages::internalError(asyncResp->res); return; } - const std::string reportPath = telemetry::getDbusReportPath(id); - crow::connections::systemBus->async_method_call( - [asyncResp, id, - reportPath](const boost::system::error_code& ec) { - if (ec.value() == EBADR || - ec == boost::system::errc::host_unreachable) - { - messages::resourceNotFound(asyncResp->res, - "MetricReport", id); - return; - } - if (ec) - { - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; - messages::internalError(asyncResp->res); - return; - } - - sdbusplus::asio::getProperty< - telemetry::TimestampReadings>( - *crow::connections::systemBus, telemetry::service, - reportPath, telemetry::reportInterface, "Readings", - [asyncResp, - id](const boost::system::error_code ec, - const telemetry::TimestampReadings& ret) { - if (ec) - { - BMCWEB_LOG_ERROR - << "respHandler DBus error " << ec; - messages::internalError(asyncResp->res); - return; - } - - telemetry::fillReport(asyncResp->res.jsonValue, - id, ret); - }); - }, - telemetry::service, reportPath, telemetry::reportInterface, - "Update"); - }); + + telemetry::fillReport(asyncResp->res.jsonValue, id, ret); + }); + }, + telemetry::service, reportPath, telemetry::reportInterface, + "Update"); + }); } } // namespace redfish |