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/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);