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: I4f63258febea27dae710c252033b9151e02be7e8
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/example/asio-example.cpp b/example/asio-example.cpp
index 08fcd11..f5f0176 100644
--- a/example/asio-example.cpp
+++ b/example/asio-example.cpp
@@ -59,10 +59,10 @@
{
boost::system::error_code ec;
variant testValue;
- conn->yield_method_call<>(yield, ec, "xyz.openbmc_project.asio-test",
- "/xyz/openbmc_project/test",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.test", "int", variant(24));
+ conn->yield_method_call<>(
+ yield, ec, "xyz.openbmc_project.asio-test", "/xyz/openbmc_project/test",
+ "org.freedesktop.DBus.Properties", "Set", "xyz.openbmc_project.test",
+ "int", variant(24));
testValue = conn->yield_method_call<variant>(
yield, ec, "xyz.openbmc_project.asio-test", "/xyz/openbmc_project/test",
"org.freedesktop.DBus.Properties", "Get", "xyz.openbmc_project.test",
@@ -217,26 +217,26 @@
iface->register_property("lessThan50", 23,
// custom set
[](const int& req, int& propertyValue) {
- if (req >= 50)
- {
- return false;
- }
- propertyValue = req;
- return true;
- });
+ if (req >= 50)
+ {
+ return false;
+ }
+ propertyValue = req;
+ return true;
+ });
iface->register_property(
"TrailTime", std::string("foo"),
// custom set
[](const std::string& req, std::string& propertyValue) {
- propertyValue = req;
- return true;
- },
+ propertyValue = req;
+ return true;
+ },
// custom get
[](const std::string& property) {
- auto now = std::chrono::system_clock::now();
- auto timePoint = std::chrono::system_clock::to_time_t(now);
- return property + std::ctime(&timePoint);
- });
+ auto now = std::chrono::system_clock::now();
+ auto timePoint = std::chrono::system_clock::to_time_t(now);
+ return property + std::ctime(&timePoint);
+ });
// test method creation
iface->register_method("TestMethod", [](const int32_t& callCount) {
@@ -250,8 +250,8 @@
// so will be executed in coroutine context if called
iface->register_method("TestYieldFunction",
[conn](boost::asio::yield_context yield, int val) {
- return fooYield(yield, conn, val);
- });
+ return fooYield(yield, conn, val);
+ });
iface->register_method("TestMethodWithMessage", methodWithMessage);
@@ -297,10 +297,10 @@
}
// test async method call and async send
- auto mesg = conn->new_method_call("xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper",
- "GetSubTree");
+ auto mesg =
+ conn->new_method_call("xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree");
int32_t depth = 2;
constexpr std::array<std::string_view, 1> interfaces{
@@ -324,17 +324,17 @@
conn->async_method_call(
[](boost::system::error_code ec, GetSubTreeType& subtree) {
- std::cout << "async_method_call callback\n";
- if (ec)
- {
- std::cerr << "error with async_method_call\n";
- return;
- }
- for (auto& item : subtree)
- {
- std::cout << item.first << "\n";
- }
- },
+ std::cout << "async_method_call callback\n";
+ if (ec)
+ {
+ std::cerr << "error with async_method_call\n";
+ return;
+ }
+ for (auto& item : subtree)
+ {
+ std::cout << item.first << "\n";
+ }
+ },
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree",
@@ -345,17 +345,18 @@
[nonConstCapture = std::move(nonConstCapture)](
boost::system::error_code ec,
const std::vector<std::string>& /*things*/) mutable {
- std::cout << "async_method_call callback\n";
- nonConstCapture += " stuff";
- if (ec)
- {
- std::cerr << "async_method_call expected failure: " << ec << "\n";
- }
- else
- {
- std::cerr << "async_method_call should have failed!\n";
- }
- },
+ std::cout << "async_method_call callback\n";
+ nonConstCapture += " stuff";
+ if (ec)
+ {
+ std::cerr << "async_method_call expected failure: " << ec
+ << "\n";
+ }
+ else
+ {
+ std::cerr << "async_method_call should have failed!\n";
+ }
+ },
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree",
@@ -383,15 +384,15 @@
conn->async_method_call(
[](boost::system::error_code ec, int32_t testValue) {
- if (ec)
- {
- std::cerr << "TestYieldFunction returned error with "
- "async_method_call (ec = "
- << ec << ")\n";
- return;
- }
- std::cout << "TestYieldFunction return " << testValue << "\n";
- },
+ if (ec)
+ {
+ std::cerr << "TestYieldFunction returned error with "
+ "async_method_call (ec = "
+ << ec << ")\n";
+ return;
+ }
+ std::cout << "TestYieldFunction return " << testValue << "\n";
+ },
"xyz.openbmc_project.asio-test", "/xyz/openbmc_project/test",
"xyz.openbmc_project.test", "TestYieldFunction", int32_t(41));
io.run();
diff --git a/example/calculator-aserver.cpp b/example/calculator-aserver.cpp
index b0500de..33a582a 100644
--- a/example/calculator-aserver.cpp
+++ b/example/calculator-aserver.cpp
@@ -18,8 +18,8 @@
return r;
}
- auto method_call(divide_t, auto x, auto y)
- -> sdbusplus::async::task<divide_t::return_type>
+ auto method_call(divide_t, auto x,
+ auto y) -> sdbusplus::async::task<divide_t::return_type>
{
using sdbusplus::error::net::poettering::calculator::DivisionByZero;
if (y == 0)
diff --git a/example/coroutine-example.cpp b/example/coroutine-example.cpp
index 2302f47..b402070 100644
--- a/example/coroutine-example.cpp
+++ b/example/coroutine-example.cpp
@@ -32,27 +32,30 @@
for (auto& [property, value] :
co_await systemd.get_all_properties<variant_type>(ctx))
{
- std::cout << property << " is "
- << std::visit(
- // Convert the variant member to a string for printing.
- [](auto v) {
- if constexpr (std::is_same_v<std::remove_cvref_t<decltype(v)>,
+ std::cout
+ << property << " is "
+ << std::visit(
+ // Convert the variant member to a string for printing.
+ [](auto v) {
+ if constexpr (std::is_same_v<
+ std::remove_cvref_t<decltype(v)>,
std::vector<std::string>>)
- {
- return std::string{"Array"};
- }
- else if constexpr (std::is_same_v<std::remove_cvref_t<decltype(v)>,
+ {
+ return std::string{"Array"};
+ }
+ else if constexpr (std::is_same_v<
+ std::remove_cvref_t<decltype(v)>,
std::string>)
- {
- return v;
- }
- else
- {
- return std::to_string(v);
- }
- },
- value)
- << std::endl;
+ {
+ return v;
+ }
+ else
+ {
+ return std::to_string(v);
+ }
+ },
+ value)
+ << std::endl;
}
// Try to set the Architecture property (which won't work).
diff --git a/example/get-all-properties.cpp b/example/get-all-properties.cpp
index 35e9783..7b91d55 100644
--- a/example/get-all-properties.cpp
+++ b/example/get-all-properties.cpp
@@ -20,11 +20,10 @@
public:
Application(sdbusplus::asio::connection& bus,
sdbusplus::asio::object_server& objServer) :
- bus_(bus),
- objServer_(objServer)
+ bus_(bus), objServer_(objServer)
{
- demo_ = objServer_.add_unique_interface(demoObjectPath,
- demoInterfaceName);
+ demo_ =
+ objServer_.add_unique_interface(demoObjectPath, demoInterfaceName);
demo_->register_property_r<std::string>(
propertyGrettingName, sdbusplus::vtable::property_::const_,
@@ -33,9 +32,9 @@
demo_->register_property_rw<std::string>(
propertyGoodbyesName, sdbusplus::vtable::property_::emits_change,
[this](const auto& newPropertyValue, const auto&) {
- goodbyes_ = newPropertyValue;
- return true;
- },
+ goodbyes_ = newPropertyValue;
+ return true;
+ },
[this](const auto&) { return goodbyes_; });
demo_->register_property_r<uint32_t>(
@@ -84,48 +83,49 @@
const std::vector<std::pair<
std::string, std::variant<std::monostate, std::string>>>&
properties) -> void {
- if (ec)
- {
- logSystemErrorCode(ec);
- return;
- }
- {
- const std::string* greetings = nullptr;
- const std::string* goodbyes = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- [this](const sdbusplus::UnpackErrorReason reason,
- const std::string& property) {
- logUnpackError(reason, property);
- },
- properties, propertyGrettingName, greetings,
- propertyGoodbyesName, goodbyes);
-
- if (success)
+ if (ec)
{
- std::cout << "value of greetings: " << *greetings << "\n";
- std::cout << "value of goodbyes: " << *goodbyes << "\n";
+ logSystemErrorCode(ec);
+ return;
}
- else
{
+ const std::string* greetings = nullptr;
+ const std::string* goodbyes = nullptr;
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ [this](const sdbusplus::UnpackErrorReason reason,
+ const std::string& property) {
+ logUnpackError(reason, property);
+ },
+ properties, propertyGrettingName, greetings,
+ propertyGoodbyesName, goodbyes);
+
+ if (success)
+ {
+ std::cout
+ << "value of greetings: " << *greetings << "\n";
+ std::cout << "value of goodbyes: " << *goodbyes << "\n";
+ }
+ else
+ {
+ ++fatalErrors_;
+ }
+ }
+
+ try
+ {
+ std::string value;
+ sdbusplus::unpackProperties(properties, propertyValueName,
+ value);
+
+ std::cerr << "Error: it should fail because of "
+ "not matched type\n";
++fatalErrors_;
}
- }
-
- try
- {
- std::string value;
- sdbusplus::unpackProperties(properties, propertyValueName,
- value);
-
- std::cerr << "Error: it should fail because of "
- "not matched type\n";
- ++fatalErrors_;
- }
- catch (const sdbusplus::exception::UnpackPropertyError& error)
- {
- logExpectedException(error);
- }
- });
+ catch (const sdbusplus::exception::UnpackPropertyError& error)
+ {
+ logExpectedException(error);
+ }
+ });
}
void asyncGetAllProperties()
@@ -137,59 +137,60 @@
std::string,
std::variant<std::monostate, std::string, uint32_t>>>&
properties) -> void {
- if (ec)
- {
- logSystemErrorCode(ec);
- return;
- }
- try
- {
- std::string greetings;
- std::string goodbyes;
- uint32_t value = 0u;
- sdbusplus::unpackProperties(properties, propertyGrettingName,
- greetings, propertyGoodbyesName,
- goodbyes, propertyValueName, value);
+ if (ec)
+ {
+ logSystemErrorCode(ec);
+ return;
+ }
+ try
+ {
+ std::string greetings;
+ std::string goodbyes;
+ uint32_t value = 0u;
+ sdbusplus::unpackProperties(
+ properties, propertyGrettingName, greetings,
+ propertyGoodbyesName, goodbyes, propertyValueName,
+ value);
- std::cout << "value of greetings: " << greetings << "\n";
- std::cout << "value of goodbyes: " << goodbyes << "\n";
- std::cout << "value of value: " << value << "\n";
- }
- catch (const sdbusplus::exception::UnpackPropertyError& error)
- {
- logException(error);
- }
+ std::cout << "value of greetings: " << greetings << "\n";
+ std::cout << "value of goodbyes: " << goodbyes << "\n";
+ std::cout << "value of value: " << value << "\n";
+ }
+ catch (const sdbusplus::exception::UnpackPropertyError& error)
+ {
+ logException(error);
+ }
- try
- {
- std::string unknownProperty;
- sdbusplus::unpackProperties(properties, "UnknownPropertyName",
- unknownProperty);
+ try
+ {
+ std::string unknownProperty;
+ sdbusplus::unpackProperties(
+ properties, "UnknownPropertyName", unknownProperty);
- std::cerr << "Error: it should fail because of "
- "missing property\n";
- ++fatalErrors_;
- }
- catch (const sdbusplus::exception::UnpackPropertyError& error)
- {
- logExpectedException(error);
- }
+ std::cerr << "Error: it should fail because of "
+ "missing property\n";
+ ++fatalErrors_;
+ }
+ catch (const sdbusplus::exception::UnpackPropertyError& error)
+ {
+ logExpectedException(error);
+ }
- try
- {
- uint32_t notMatchingType;
- sdbusplus::unpackProperties(properties, propertyGrettingName,
- notMatchingType);
+ try
+ {
+ uint32_t notMatchingType;
+ sdbusplus::unpackProperties(
+ properties, propertyGrettingName, notMatchingType);
- std::cerr << "Error: it should fail because of "
- "not matched type\n";
- ++fatalErrors_;
- }
- catch (const sdbusplus::exception::UnpackPropertyError& error)
- {
- logExpectedException(error);
- }
- });
+ std::cerr << "Error: it should fail because of "
+ "not matched type\n";
+ ++fatalErrors_;
+ }
+ catch (const sdbusplus::exception::UnpackPropertyError& error)
+ {
+ logExpectedException(error);
+ }
+ });
}
private:
@@ -208,8 +209,9 @@
boost::asio::io_context ioc;
boost::asio::signal_set signals(ioc, SIGINT, SIGTERM);
- signals.async_wait(
- [&ioc](const boost::system::error_code&, const int&) { ioc.stop(); });
+ signals.async_wait([&ioc](const boost::system::error_code&, const int&) {
+ ioc.stop();
+ });
auto bus = std::make_shared<sdbusplus::asio::connection>(ioc);
auto objServer = std::make_unique<sdbusplus::asio::object_server>(bus);
diff --git a/example/list-users.cpp b/example/list-users.cpp
index 4dabd40..f7ab475 100644
--- a/example/list-users.cpp
+++ b/example/list-users.cpp
@@ -13,9 +13,9 @@
using namespace sdbusplus;
auto b = bus::new_default_system();
- auto m = b.new_method_call("org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager", "ListUsers");
+ auto m =
+ b.new_method_call("org.freedesktop.login1", "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager", "ListUsers");
auto reply = b.call(m);
using return_type =
diff --git a/example/register-property.cpp b/example/register-property.cpp
index e10b0f1..45c8a51 100644
--- a/example/register-property.cpp
+++ b/example/register-property.cpp
@@ -18,25 +18,24 @@
public:
Application(boost::asio::io_context& ioc, sdbusplus::asio::connection& bus,
sdbusplus::asio::object_server& objServer) :
- ioc_(ioc),
- bus_(bus), objServer_(objServer)
+ ioc_(ioc), bus_(bus), objServer_(objServer)
{
demo_ = objServer_.add_unique_interface(
demoObjectPath, demoInterfaceName,
[this](sdbusplus::asio::dbus_interface& demo) {
- demo.register_property_r<std::string>(
- propertyGrettingName, sdbusplus::vtable::property_::const_,
- [this](const auto&) { return greetings_; });
+ demo.register_property_r<std::string>(
+ propertyGrettingName, sdbusplus::vtable::property_::const_,
+ [this](const auto&) { return greetings_; });
- demo.register_property_rw<std::string>(
- propertyGoodbyesName,
- sdbusplus::vtable::property_::emits_change,
- [this](const auto& newPropertyValue, const auto&) {
- goodbyes_ = newPropertyValue;
- return true;
- },
- [this](const auto&) { return goodbyes_; });
- });
+ demo.register_property_rw<std::string>(
+ propertyGoodbyesName,
+ sdbusplus::vtable::property_::emits_change,
+ [this](const auto& newPropertyValue, const auto&) {
+ goodbyes_ = newPropertyValue;
+ return true;
+ },
+ [this](const auto&) { return goodbyes_; });
+ });
}
uint32_t fatalErrors() const
@@ -58,18 +57,18 @@
bus_, demoServiceName, demoObjectPath, demoInterfaceName,
propertyGrettingName,
[this](boost::system::error_code ec, uint32_t) {
- if (ec)
- {
- std::cout
- << "As expected failed to getProperty with wrong type: "
- << ec << "\n";
- return;
- }
+ if (ec)
+ {
+ std::cout
+ << "As expected failed to getProperty with wrong type: "
+ << ec << "\n";
+ return;
+ }
- std::cerr << "Error: it was expected to fail getProperty due "
- "to wrong type\n";
- ++fatalErrors_;
- });
+ std::cerr << "Error: it was expected to fail getProperty due "
+ "to wrong type\n";
+ ++fatalErrors_;
+ });
}
void asyncReadProperties()
@@ -78,25 +77,25 @@
bus_, demoServiceName, demoObjectPath, demoInterfaceName,
propertyGrettingName,
[this](boost::system::error_code ec, std::string value) {
- if (ec)
- {
- getFailed();
- return;
- }
- std::cout << "Greetings value is: " << value << "\n";
- });
+ if (ec)
+ {
+ getFailed();
+ return;
+ }
+ std::cout << "Greetings value is: " << value << "\n";
+ });
sdbusplus::asio::getProperty<std::string>(
bus_, demoServiceName, demoObjectPath, demoInterfaceName,
propertyGoodbyesName,
[this](boost::system::error_code ec, std::string value) {
- if (ec)
- {
- getFailed();
- return;
- }
- std::cout << "Goodbyes value is: " << value << "\n";
- });
+ if (ec)
+ {
+ getFailed();
+ return;
+ }
+ std::cout << "Goodbyes value is: " << value << "\n";
+ });
}
void asyncChangeProperty()
@@ -105,32 +104,35 @@
bus_, demoServiceName, demoObjectPath, demoInterfaceName,
propertyGrettingName, "Hi, hey, hello",
[this](const boost::system::error_code& ec) {
- if (ec)
- {
- std::cout << "As expected, failed to set greetings property: "
- << ec << "\n";
- return;
- }
+ if (ec)
+ {
+ std::cout
+ << "As expected, failed to set greetings property: "
+ << ec << "\n";
+ return;
+ }
- std::cout << "Error: it was expected to fail to change greetings\n";
- ++fatalErrors_;
- });
+ std::cout
+ << "Error: it was expected to fail to change greetings\n";
+ ++fatalErrors_;
+ });
sdbusplus::asio::setProperty(
bus_, demoServiceName, demoObjectPath, demoInterfaceName,
propertyGoodbyesName, "Bye bye",
[this](const boost::system::error_code& ec) {
- if (ec)
- {
- std::cout << "Error: it supposed to be ok to change goodbyes "
- "property: "
- << ec << "\n";
- ++fatalErrors_;
- return;
- }
- std::cout << "Changed goodbyes property as expected\n";
- boost::asio::post(ioc_, [this] { asyncReadProperties(); });
- });
+ if (ec)
+ {
+ std::cout
+ << "Error: it supposed to be ok to change goodbyes "
+ "property: "
+ << ec << "\n";
+ ++fatalErrors_;
+ return;
+ }
+ std::cout << "Changed goodbyes property as expected\n";
+ boost::asio::post(ioc_, [this] { asyncReadProperties(); });
+ });
}
void syncChangeGoodbyes(std::string_view value)
@@ -156,8 +158,9 @@
boost::asio::io_context ioc;
boost::asio::signal_set signals(ioc, SIGINT, SIGTERM);
- signals.async_wait(
- [&ioc](const boost::system::error_code&, const int&) { ioc.stop(); });
+ signals.async_wait([&ioc](const boost::system::error_code&, const int&) {
+ ioc.stop();
+ });
auto bus = std::make_shared<sdbusplus::asio::connection>(ioc);
auto objServer = std::make_unique<sdbusplus::asio::object_server>(bus);