summaryrefslogtreecommitdiff
path: root/include/obmc_console.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-05-31 18:59:27 +0300
committerEd Tanous <ed@tanous.net>2022-06-01 19:10:35 +0300
commit002d39b4a7a5ed7166e2acad84e0943c3def9492 (patch)
tree4307dd5161ec9779d59308a9b933e408cc2c6ca7 /include/obmc_console.hpp
parent62c416fb0d2f62e09d7f60754ff359ac2389e749 (diff)
downloadbmcweb-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 'include/obmc_console.hpp')
-rw-r--r--include/obmc_console.hpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp
index fc99d41fef..d5eaf819e7 100644
--- a/include/obmc_console.hpp
+++ b/include/obmc_console.hpp
@@ -45,23 +45,23 @@ inline void doWrite()
hostSocket->async_write_some(
boost::asio::buffer(inputBuffer.data(), inputBuffer.size()),
[](boost::beast::error_code ec, std::size_t bytesWritten) {
- doingWrite = false;
- inputBuffer.erase(0, bytesWritten);
+ doingWrite = false;
+ inputBuffer.erase(0, bytesWritten);
- if (ec == boost::asio::error::eof)
- {
- for (crow::websocket::Connection* session : sessions)
- {
- session->close("Error in reading to host port");
- }
- return;
- }
- if (ec)
+ if (ec == boost::asio::error::eof)
+ {
+ for (crow::websocket::Connection* session : sessions)
{
- BMCWEB_LOG_ERROR << "Error in host serial write " << ec;
- return;
+ session->close("Error in reading to host port");
}
- doWrite();
+ return;
+ }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Error in host serial write " << ec;
+ return;
+ }
+ doWrite();
});
}
@@ -77,23 +77,22 @@ inline void doRead()
hostSocket->async_read_some(
boost::asio::buffer(outputBuffer.data(), outputBuffer.size()),
[](const boost::system::error_code& ec, std::size_t bytesRead) {
- BMCWEB_LOG_DEBUG << "read done. Read " << bytesRead << " bytes";
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Couldn't read from host serial port: "
- << ec;
- for (crow::websocket::Connection* session : sessions)
- {
- session->close("Error in connecting to host port");
- }
- return;
- }
- std::string_view payload(outputBuffer.data(), bytesRead);
+ BMCWEB_LOG_DEBUG << "read done. Read " << bytesRead << " bytes";
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Couldn't read from host serial port: " << ec;
for (crow::websocket::Connection* session : sessions)
{
- session->sendBinary(payload);
+ session->close("Error in connecting to host port");
}
- doRead();
+ return;
+ }
+ std::string_view payload(outputBuffer.data(), bytesRead);
+ for (crow::websocket::Connection* session : sessions)
+ {
+ session->sendBinary(payload);
+ }
+ doRead();
});
}
@@ -118,20 +117,21 @@ inline void requestRoutes(App& app)
BMCWEB_ROUTE(app, "/console0")
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
- .onopen([](crow::websocket::Connection& conn) {
- BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
+ .onopen(
+ [](crow::websocket::Connection& conn) {
+ BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
- sessions.insert(&conn);
- if (hostSocket == nullptr)
- {
- const std::string consoleName("\0obmc-console", 13);
- boost::asio::local::stream_protocol::endpoint ep(consoleName);
+ sessions.insert(&conn);
+ if (hostSocket == nullptr)
+ {
+ const std::string consoleName("\0obmc-console", 13);
+ boost::asio::local::stream_protocol::endpoint ep(consoleName);
- hostSocket = std::make_unique<
- boost::asio::local::stream_protocol::socket>(
+ hostSocket =
+ std::make_unique<boost::asio::local::stream_protocol::socket>(
conn.getIoContext());
- hostSocket->async_connect(ep, connectHandler);
- }
+ hostSocket->async_connect(ep, connectHandler);
+ }
})
.onclose([](crow::websocket::Connection& conn,
[[maybe_unused]] const std::string& reason) {