clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: Iceec1dc95b6c908ec6c21fb40093de9dd18bf11a
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp
index 2180329..1e56cd9 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -101,27 +101,27 @@
inputBuffer->data(),
[this, self(shared_from_this())](const boost::beast::error_code& ec,
std::size_t bytesWritten) {
- BMCWEB_LOG_DEBUG("Wrote {}bytes", bytesWritten);
- doingWrite = false;
- inputBuffer->consume(bytesWritten);
+ BMCWEB_LOG_DEBUG("Wrote {}bytes", bytesWritten);
+ doingWrite = false;
+ inputBuffer->consume(bytesWritten);
- if (session == nullptr)
- {
- return;
- }
- if (ec == boost::asio::error::eof)
- {
- session->close("VM socket port closed");
- return;
- }
- if (ec)
- {
- session->close("Error in writing to proxy port");
- BMCWEB_LOG_ERROR("Error in VM socket write {}", ec);
- return;
- }
- doWrite();
- });
+ if (session == nullptr)
+ {
+ return;
+ }
+ if (ec == boost::asio::error::eof)
+ {
+ session->close("VM socket port closed");
+ return;
+ }
+ if (ec)
+ {
+ session->close("Error in writing to proxy port");
+ BMCWEB_LOG_ERROR("Error in VM socket write {}", ec);
+ return;
+ }
+ doWrite();
+ });
}
void doRead()
@@ -132,30 +132,30 @@
outputBuffer->prepare(bytes),
[this, self(shared_from_this())](
const boost::system::error_code& ec, std::size_t bytesRead) {
- BMCWEB_LOG_DEBUG("Read done. Read {} bytes", bytesRead);
- if (ec)
- {
- BMCWEB_LOG_ERROR("Couldn't read from VM port: {}", ec);
- if (session != nullptr)
+ BMCWEB_LOG_DEBUG("Read done. Read {} bytes", bytesRead);
+ if (ec)
{
- session->close("Error in connecting to VM port");
+ BMCWEB_LOG_ERROR("Couldn't read from VM port: {}", ec);
+ if (session != nullptr)
+ {
+ session->close("Error in connecting to VM port");
+ }
+ return;
}
- return;
- }
- if (session == nullptr)
- {
- return;
- }
+ if (session == nullptr)
+ {
+ return;
+ }
- outputBuffer->commit(bytesRead);
- std::string_view payload(
- static_cast<const char*>(outputBuffer->data().data()),
- bytesRead);
- session->sendBinary(payload);
- outputBuffer->consume(bytesRead);
+ outputBuffer->commit(bytesRead);
+ std::string_view payload(
+ static_cast<const char*>(outputBuffer->data().data()),
+ bytesRead);
+ session->sendBinary(payload);
+ outputBuffer->consume(bytesRead);
- doRead();
- });
+ doRead();
+ });
}
boost::asio::readable_pipe pipeOut;
@@ -188,8 +188,7 @@
NbdProxyServer(crow::websocket::Connection& connIn,
const std::string& socketIdIn,
const std::string& endpointIdIn, const std::string& pathIn) :
- socketId(socketIdIn),
- endpointId(endpointIdIn), path(pathIn),
+ socketId(socketIdIn), endpointId(endpointIdIn), path(pathIn),
peerSocket(connIn.getIoContext()),
acceptor(connIn.getIoContext(), stream_protocol::endpoint(socketId)),
@@ -278,8 +277,8 @@
crow::connections::systemBus->async_method_call(
[weak{weak_from_this()}](const boost::system::error_code& ec,
bool isBinary) {
- afterMount(weak, ec, isBinary);
- },
+ afterMount(weak, ec, isBinary);
+ },
"xyz.openbmc_project.VirtualMedia", path,
"xyz.openbmc_project.VirtualMedia.Proxy", "Mount");
}
@@ -380,10 +379,10 @@
}
uxWriteInProgress = true;
- peerSocket.async_write_some(ws2uxBuf.data(),
- std::bind_front(&NbdProxyServer::afterWrite,
- weak_from_this(),
- std::move(onDone)));
+ peerSocket.async_write_some(
+ ws2uxBuf.data(),
+ std::bind_front(&NbdProxyServer::afterWrite, weak_from_this(),
+ std::move(onDone)));
}
// Keeps UNIX socket endpoint file path
@@ -455,8 +454,8 @@
std::filesystem::remove(socket.c_str(), ec2);
// Ignore failures. File might not exist.
- sessions[&conn] = std::make_shared<NbdProxyServer>(conn, socket, endpointId,
- path);
+ sessions[&conn] =
+ std::make_shared<NbdProxyServer>(conn, socket, endpointId, path);
sessions[&conn]->run();
}
@@ -480,8 +479,8 @@
"xyz.openbmc_project.VirtualMedia.MountPoint",
[&conn, path](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- afterGetSocket(conn, path, ec, propertiesList);
- });
+ afterGetSocket(conn, path, ec, propertiesList);
+ });
// We need to wait for dbus and the websockets to hook up before data is
// sent/received. Tell the core to hold off messages until the sockets are
@@ -552,58 +551,58 @@
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
.onopen([](crow::websocket::Connection& conn) {
- BMCWEB_LOG_DEBUG("Connection {} opened", logPtr(&conn));
+ BMCWEB_LOG_DEBUG("Connection {} opened", logPtr(&conn));
- if (session != nullptr)
- {
- conn.close("Session already connected");
- return;
- }
+ if (session != nullptr)
+ {
+ conn.close("Session already connected");
+ return;
+ }
- if (handler != nullptr)
- {
- conn.close("Handler already running");
- return;
- }
+ if (handler != nullptr)
+ {
+ conn.close("Handler already running");
+ return;
+ }
- session = &conn;
+ session = &conn;
- // media is the last digit of the endpoint /vm/0/0. A future
- // enhancement can include supporting different endpoint values.
- const char* media = "0";
- handler = std::make_shared<Handler>(media, conn.getIoContext());
- handler->connect();
- })
+ // media is the last digit of the endpoint /vm/0/0. A future
+ // enhancement can include supporting different endpoint values.
+ const char* media = "0";
+ handler = std::make_shared<Handler>(media, conn.getIoContext());
+ handler->connect();
+ })
.onclose([](crow::websocket::Connection& conn,
const std::string& /*reason*/) {
- if (&conn != session)
- {
- return;
- }
+ if (&conn != session)
+ {
+ return;
+ }
- session = nullptr;
- handler->doClose();
- handler->inputBuffer->clear();
- handler->outputBuffer->clear();
- handler.reset();
- })
+ session = nullptr;
+ handler->doClose();
+ handler->inputBuffer->clear();
+ handler->outputBuffer->clear();
+ handler.reset();
+ })
.onmessage([](crow::websocket::Connection& conn,
const std::string& data, bool) {
- if (data.length() >
- handler->inputBuffer->capacity() - handler->inputBuffer->size())
- {
- BMCWEB_LOG_ERROR("Buffer overrun when writing {} bytes",
- data.length());
- conn.close("Buffer overrun");
- return;
- }
+ if (data.length() > handler->inputBuffer->capacity() -
+ handler->inputBuffer->size())
+ {
+ BMCWEB_LOG_ERROR("Buffer overrun when writing {} bytes",
+ data.length());
+ conn.close("Buffer overrun");
+ return;
+ }
- size_t copied = boost::asio::buffer_copy(
- handler->inputBuffer->prepare(data.size()),
- boost::asio::buffer(data));
- handler->inputBuffer->commit(copied);
- handler->doWrite();
- });
+ size_t copied = boost::asio::buffer_copy(
+ handler->inputBuffer->prepare(data.size()),
+ boost::asio::buffer(data));
+ handler->inputBuffer->commit(copied);
+ handler->doWrite();
+ });
}
}