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: I9bb0aaa05541fe88ccabfaa5d00e3117e489ea8d
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
IndentWrappedFunctionNames: true
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
@@ -98,13 +98,14 @@
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
diff --git a/mslverify/util.hpp b/mslverify/util.hpp
index 4c1ea00..1c1ee41 100644
--- a/mslverify/util.hpp
+++ b/mslverify/util.hpp
@@ -79,10 +79,9 @@
/** @brief Invoke a method and read the response. */
template <typename Ret, typename... Args>
-static auto callMethodAndRead(const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method, Args&&... args)
+static auto callMethodAndRead(
+ const std::string& busName, const std::string& path,
+ const std::string& interface, const std::string& method, Args&&... args)
{
return callMethodAndRead<Ret>(getBus(), busName, path, interface, method,
std::forward<Args>(args)...);
@@ -118,9 +117,9 @@
{
using namespace std::literals::string_literals;
- auto msg = callMethod(bus, busName, path,
- "org.freedesktop.DBus.Properties"s, "Get"s, interface,
- property);
+ auto msg =
+ callMethod(bus, busName, path, "org.freedesktop.DBus.Properties"s,
+ "Get"s, interface, property);
::std::variant<Property> value;
msg.read(value);
return std::get<Property>(value);
diff --git a/src/callback.hpp b/src/callback.hpp
index 0295246..7d23077 100644
--- a/src/callback.hpp
+++ b/src/callback.hpp
@@ -48,7 +48,7 @@
* @param[in] msg - The sdbusplus signal message
*/
virtual void operator()(Context /* ctx */,
- sdbusplus::message_t& /* msg */){};
+ sdbusplus::message_t& /* msg */) {};
};
/** @class Conditional
@@ -171,9 +171,7 @@
ConditionalCallback& operator=(ConditionalCallback&&) = default;
virtual ~ConditionalCallback() = default;
ConditionalCallback(const std::vector<size_t>& graphEntry,
- Conditional& cond) :
- graph(graphEntry),
- condition(cond)
+ Conditional& cond) : graph(graphEntry), condition(cond)
{}
/** @brief Run the callback if the condition is satisfied. */
@@ -235,14 +233,14 @@
{
if (!timer)
{
- timer =
- std::make_unique<TimerType>(sdeventplus::Event::get_default(),
- // **INDENT-OFF**
- [this](auto& /* source */) {
- // The timer uses the context saved on timer enable
- this->ConditionalCallback<CallbackAccess>::operator()(
- this->ctx);
- });
+ timer = std::make_unique<TimerType>(
+ sdeventplus::Event::get_default(),
+ // **INDENT-OFF**
+ [this](auto& /* source */) {
+ // The timer uses the context saved on timer enable
+ this->ConditionalCallback<CallbackAccess>::operator()(
+ this->ctx);
+ });
// **INDENT-ON**
}
diff --git a/src/count.hpp b/src/count.hpp
index 3dad8e7..ed0b2c9 100644
--- a/src/count.hpp
+++ b/src/count.hpp
@@ -47,34 +47,35 @@
const std::function<bool(size_t)>& _countOp,
const std::function<bool(T)>& _propertyOp,
bool oneshot = false) :
- IndexedConditional(conditionIndex),
- countOp(_countOp), propertyOp(_propertyOp), oneshot(oneshot)
+ IndexedConditional(conditionIndex), countOp(_countOp),
+ propertyOp(_propertyOp), oneshot(oneshot)
{}
bool operator()() override
{
// Count the number of properties in the index that
// pass the condition specified in the config file.
- auto count = std::count_if(index.cbegin(), index.cend(),
- [this](const auto& item)
- // *INDENT-OFF*
- {
- // Get the property value from storage[0],
- // and save the op result in storage[1].
- const auto& storage = std::get<storageIndex>(item.second);
- // Don't count properties that don't exist.
- if (!std::get<valueIndex>(storage.get()).has_value())
+ auto count = std::count_if(
+ index.cbegin(), index.cend(),
+ [this](const auto& item)
+ // *INDENT-OFF*
{
- return false;
- }
- const auto& value =
- std::any_cast<T>(std::get<valueIndex>(storage.get()));
- auto r = propertyOp(value);
+ // Get the property value from storage[0],
+ // and save the op result in storage[1].
+ const auto& storage = std::get<storageIndex>(item.second);
+ // Don't count properties that don't exist.
+ if (!std::get<valueIndex>(storage.get()).has_value())
+ {
+ return false;
+ }
+ const auto& value =
+ std::any_cast<T>(std::get<valueIndex>(storage.get()));
+ auto r = propertyOp(value);
- std::get<resultIndex>(storage.get()) = r;
+ std::get<resultIndex>(storage.get()) = r;
- return r;
- });
+ return r;
+ });
// *INDENT-ON*
// Now apply the count condition to the count.
diff --git a/src/event.hpp b/src/event.hpp
index 9292a99..b355ca5 100644
--- a/src/event.hpp
+++ b/src/event.hpp
@@ -92,8 +92,7 @@
*/
Event(const std::string& eventName, const std::string& eventMessage,
const PropertyIndex& index) :
- EventBase(index),
- name(eventName), message(eventMessage)
+ EventBase(index), name(eventName), message(eventMessage)
{}
private:
diff --git a/src/event_manager.cpp b/src/event_manager.cpp
index c0c0c4a..77c6b80 100644
--- a/src/event_manager.cpp
+++ b/src/event_manager.cpp
@@ -77,10 +77,10 @@
fs::remove(eventPath, ec);
}
- auto event = std::make_unique<Entry>(objPath,
- ms, // Milliseconds since 1970
- std::move(msg),
- std::move(additionalData));
+ auto event = std::make_unique<Entry>(
+ objPath,
+ ms, // Milliseconds since 1970
+ std::move(msg), std::move(additionalData));
serialize(*event, eventName);
eventQueue.push(std::move(event));
}
diff --git a/src/median.hpp b/src/median.hpp
index 9976972..254d6cf 100644
--- a/src/median.hpp
+++ b/src/median.hpp
@@ -44,8 +44,8 @@
MedianCondition(const PropertyIndex& conditionIndex,
const std::function<bool(T)>& _medianOp,
bool oneshot = false) :
- IndexedConditional(conditionIndex),
- medianOp(_medianOp), oneshot(oneshot)
+ IndexedConditional(conditionIndex), medianOp(_medianOp),
+ oneshot(oneshot)
{}
bool operator()() override
diff --git a/src/method.hpp b/src/method.hpp
index 7190a88..baaebcd 100644
--- a/src/method.hpp
+++ b/src/method.hpp
@@ -63,8 +63,7 @@
virtual ~MethodBase() = default;
MethodBase(const std::string& b, const std::string& p, const std::string& i,
const std::string& m) :
- Callback(),
- bus(b), path(p), interface(i), method(m)
+ Callback(), bus(b), path(p), interface(i), method(m)
{}
/** @brief Callback interface implementation. */
diff --git a/src/pathwatchimpl.hpp b/src/pathwatchimpl.hpp
index f2ac946..282ed60 100644
--- a/src/pathwatchimpl.hpp
+++ b/src/pathwatchimpl.hpp
@@ -33,7 +33,7 @@
sdbusplus::bus::match::rules::interfacesAdded(objectPath),
[this](auto& msg)
// *INDENT-OFF*
- { (this->cb)(Context::SIGNAL, msg); });
+ { (this->cb)(Context::SIGNAL, msg); });
// *INDENT-ON*
alreadyRan = true;
diff --git a/src/propertywatch.hpp b/src/propertywatch.hpp
index e1ae986..57eda6f 100644
--- a/src/propertywatch.hpp
+++ b/src/propertywatch.hpp
@@ -41,8 +41,7 @@
PropertyWatch(const PropertyIndex& watchIndex,
bool ignoreStartCallback = false,
Callback* callback = nullptr) :
- Watch(),
- index(watchIndex), cb(callback), alreadyRan(false),
+ Watch(), index(watchIndex), cb(callback), alreadyRan(false),
ignoreStartCallback(ignoreStartCallback)
{}
diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp
index 9c009fe..cf97f63 100644
--- a/src/propertywatchimpl.hpp
+++ b/src/propertywatchimpl.hpp
@@ -45,7 +45,7 @@
sdbusplus::bus::match::rules::interfacesAdded(path),
[this](auto& msg)
// *INDENT-OFF*
- { this->interfacesAdded(msg); });
+ { this->interfacesAdded(msg); });
// *INDENT-ON*
// Do a query to populate the cache. Start with a mapper query.
@@ -77,12 +77,12 @@
interface),
[this](auto& msg)
// *INDENT-OFF*
- {
- std::string interface;
- msg.read(interface);
- auto path = msg.get_path();
- this->propertiesChanged(msg, path, interface);
- });
+ {
+ std::string interface;
+ msg.read(interface);
+ auto path = msg.get_path();
+ this->propertiesChanged(msg, path, interface);
+ });
// *INDENT-ON*
// The mapper response is a busname:[interfaces] map. Look for
diff --git a/src/sdbusplus.hpp b/src/sdbusplus.hpp
index 670caa0..083cdf4 100644
--- a/src/sdbusplus.hpp
+++ b/src/sdbusplus.hpp
@@ -39,10 +39,9 @@
/** @brief Invoke a method; ignore reply. */
template <typename... Args>
- static void callMethodNoReply(const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method, Args&&... args)
+ static void callMethodNoReply(
+ const std::string& busName, const std::string& path,
+ const std::string& interface, const std::string& method, Args&&... args)
{
auto reqMsg = getBus().new_method_call(
busName.c_str(), path.c_str(), interface.c_str(), method.c_str());
@@ -68,10 +67,9 @@
/** @brief Invoke a method and read the response. */
template <typename Ret, typename... Args>
- static auto callMethodAndRead(const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method, Args&&... args)
+ static auto callMethodAndRead(
+ const std::string& busName, const std::string& path,
+ const std::string& interface, const std::string& method, Args&&... args)
{
Ret resp;
sdbusplus::message_t respMsg = callMethod<Args...>(
diff --git a/src/test/propertywatchtest.hpp b/src/test/propertywatchtest.hpp
index f6b7496..e912b43 100644
--- a/src/test/propertywatchtest.hpp
+++ b/src/test/propertywatchtest.hpp
@@ -270,10 +270,9 @@
/** @brief GMock member template/free function forward. */
template <typename Ret, typename... Args>
- static auto callMethodAndRead(const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method, Args&&... args)
+ static auto callMethodAndRead(
+ const std::string& busName, const std::string& path,
+ const std::string& interface, const std::string& method, Args&&... args)
{
return CallMethodAndRead<MockDBusInterface, Ret, Args...>::op(
instance(), busName, path, interface, method,
diff --git a/src/watch.hpp b/src/watch.hpp
index 5cf2c19..36e7df1 100644
--- a/src/watch.hpp
+++ b/src/watch.hpp
@@ -39,7 +39,8 @@
virtual void callback(Context ctx) = 0;
/** @brief Invoke the callback associated with the watch. */
- virtual void callback(Context /* ctx */, sdbusplus::message_t& /* msg */){};
+ virtual void callback(Context /* ctx */, sdbusplus::message_t& /* msg */) {
+ };
};
} // namespace monitoring