clang-format: copy latest and re-format
clang-format-17 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.
Change-Id: Ic0bb299201cf8abb024b7d4aca465d50cbc8b585
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d92a3f1..d43e884 100644
--- a/.clang-format
+++ b/.clang-format
@@ -14,26 +14,30 @@
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
-AllowShortIfStatementsOnASingleLine: false
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
+BitFieldColonSpacing: None
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
+ AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
- AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
+ BeforeLambdaBody: false
+ BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
@@ -48,17 +52,16 @@
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
-DeriveLineEnding: false
DerivePointerAlignment: false
-PointerAlignment: Left
DisableFormat: false
-ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
-ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+ForEachMacros:
+ - foreach
+ - Q_FOREACH
+ - BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^[<"](gtest|gmock)'
@@ -78,6 +81,7 @@
- Regex: '.*'
Priority: 6
IndentCaseLabels: true
+IndentExternBlock: NoIndent
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
@@ -92,6 +96,7 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
+PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
@@ -100,12 +105,13 @@
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
+PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
ReflowComments: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: Keyword
-SortIncludes: true
+SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
@@ -117,7 +123,7 @@
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
-SpacesInAngles: false
+SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
diff --git a/dbus/dbuspassiveredundancy.cpp b/dbus/dbuspassiveredundancy.cpp
index 0e186a6..640e587 100644
--- a/dbus/dbuspassiveredundancy.cpp
+++ b/dbus/dbuspassiveredundancy.cpp
@@ -49,8 +49,7 @@
match(bus,
"type='signal',member='PropertiesChanged',arg0namespace='" +
std::string(redundancy::interface) + "'",
- std::move(
- [this](sdbusplus::message_t& message) {
+ std::move([this](sdbusplus::message_t& message) {
std::string objectName;
std::unordered_map<std::string,
std::variant<std::string, std::vector<std::string>>>
@@ -100,8 +99,8 @@
failed.erase(d);
}
}
- })),
-passiveBus(bus)
+})),
+ passiveBus(bus)
{
populateFailures();
}
diff --git a/test/dbus_active_unittest.cpp b/test/dbus_active_unittest.cpp
index c9f663e..562dd73 100644
--- a/test/dbus_active_unittest.cpp
+++ b/test/dbus_active_unittest.cpp
@@ -45,10 +45,10 @@
.WillOnce(Invoke([&]([[maybe_unused]] const std::string& service,
[[maybe_unused]] const std::string& path,
SensorProperties* prop) {
- prop->scale = -3;
- prop->value = 10000;
- prop->unit = "x";
- }));
+ prop->scale = -3;
+ prop->value = 10000;
+ prop->unit = "x";
+ }));
DbusActiveRead ar(bus_mock, path, service, std::move(helper));
diff --git a/test/dbus_passive_unittest.cpp b/test/dbus_passive_unittest.cpp
index 9120336..29c73dc 100644
--- a/test/dbus_passive_unittest.cpp
+++ b/test/dbus_passive_unittest.cpp
@@ -79,13 +79,13 @@
.WillOnce(Invoke([&]([[maybe_unused]] const std::string& service,
[[maybe_unused]] const std::string& path,
SensorProperties* prop) {
- prop->scale = _scale;
- prop->value = _value;
- prop->unit = "x";
- prop->min = 0;
- prop->max = 0;
- prop->available = true;
- }));
+ prop->scale = _scale;
+ prop->value = _value;
+ prop->unit = "x";
+ prop->min = 0;
+ prop->max = 0;
+ prop->available = true;
+ }));
EXPECT_CALL(*helper, thresholdsAsserted(StrEq("asdf"), StrEq(path)))
.WillOnce(Return(false));
@@ -168,18 +168,18 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = intf;
- return 0;
- }))
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = intf;
+ return 0;
+ }))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- *s = Value;
- // Read the string in the pair (dictionary).
- return 0;
- }));
+ const char** s = static_cast<const char**>(p);
+ *s = Value;
+ // Read the string in the pair (dictionary).
+ return 0;
+ }));
// std::map
EXPECT_CALL(sdbus_mock,
@@ -206,10 +206,10 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- int64_t* s = static_cast<int64_t*>(p);
- *s = xValue;
- return 0;
- }));
+ int64_t* s = static_cast<int64_t*>(p);
+ *s = xValue;
+ return 0;
+ }));
EXPECT_CALL(sdbus_mock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)) /* variant. */
@@ -241,18 +241,18 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = intf;
- return 0;
- }))
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = intf;
+ return 0;
+ }))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- *s = Scale;
- // Read the string in the pair (dictionary).
- return 0;
- }));
+ const char** s = static_cast<const char**>(p);
+ *s = Scale;
+ // Read the string in the pair (dictionary).
+ return 0;
+ }));
// std::map
EXPECT_CALL(sdbus_mock,
@@ -279,10 +279,10 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- int64_t* s = static_cast<int64_t*>(p);
- *s = xScale;
- return 0;
- }));
+ int64_t* s = static_cast<int64_t*>(p);
+ *s = xScale;
+ return 0;
+ }));
EXPECT_CALL(sdbus_mock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)) /* variant. */
@@ -312,18 +312,18 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = intf;
- return 0;
- }))
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = intf;
+ return 0;
+ }))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- *s = criticalAlarm;
- // Read the string in the pair (dictionary).
- return 0;
- }));
+ const char** s = static_cast<const char**>(p);
+ *s = criticalAlarm;
+ // Read the string in the pair (dictionary).
+ return 0;
+ }));
// std::map
EXPECT_CALL(sdbus_mock,
@@ -356,10 +356,10 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'b', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- bool* s = static_cast<bool*>(p);
- *s = alarm;
- return 0;
- }));
+ bool* s = static_cast<bool*>(p);
+ *s = alarm;
+ return 0;
+ }));
EXPECT_CALL(sdbus_mock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)) /* variant. */
@@ -389,18 +389,18 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = intf;
- return 0;
- }))
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = intf;
+ return 0;
+ }))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- *s = criticalAlarm;
- // Read the string in the pair (dictionary).
- return 0;
- }));
+ const char** s = static_cast<const char**>(p);
+ *s = criticalAlarm;
+ // Read the string in the pair (dictionary).
+ return 0;
+ }));
// std::map
EXPECT_CALL(sdbus_mock,
@@ -433,10 +433,10 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'b', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- bool* s = static_cast<bool*>(p);
- *s = alarm;
- return 0;
- }));
+ bool* s = static_cast<bool*>(p);
+ *s = alarm;
+ return 0;
+ }));
EXPECT_CALL(sdbus_mock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)) /* variant. */
@@ -466,18 +466,18 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = intf;
- return 0;
- }))
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = intf;
+ return 0;
+ }))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- *s = property;
- // Read the string in the pair (dictionary).
- return 0;
- }));
+ const char** s = static_cast<const char**>(p);
+ *s = property;
+ // Read the string in the pair (dictionary).
+ return 0;
+ }));
// std::map
EXPECT_CALL(sdbus_mock,
@@ -510,10 +510,10 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'b', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- bool* s = static_cast<bool*>(p);
- *s = asserted;
- return 0;
- }));
+ bool* s = static_cast<bool*>(p);
+ *s = asserted;
+ return 0;
+ }));
EXPECT_CALL(sdbus_mock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)) /* variant. */
@@ -545,18 +545,18 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = intf;
- return 0;
- }))
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = intf;
+ return 0;
+ }))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- *s = property;
- // Read the string in the pair (dictionary).
- return 0;
- }));
+ const char** s = static_cast<const char**>(p);
+ *s = property;
+ // Read the string in the pair (dictionary).
+ return 0;
+ }));
// std::map
EXPECT_CALL(sdbus_mock,
@@ -589,10 +589,10 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'b', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- bool* s = static_cast<bool*>(p);
- *s = asserted;
- return 0;
- }));
+ bool* s = static_cast<bool*>(p);
+ *s = asserted;
+ return 0;
+ }));
EXPECT_CALL(sdbus_mock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)) /* variant. */
@@ -621,13 +621,13 @@
.WillOnce(Invoke([&]([[maybe_unused]] const std::string& service,
[[maybe_unused]] const std::string& path,
SensorProperties* prop) {
- prop->scale = _scale;
- prop->value = _value;
- prop->unit = "x";
- prop->min = 0;
- prop->max = 0;
- prop->available = true;
- }));
+ prop->scale = _scale;
+ prop->value = _value;
+ prop->unit = "x";
+ prop->min = 0;
+ prop->max = 0;
+ prop->available = true;
+ }));
EXPECT_CALL(*helper, thresholdsAsserted(StrEq("asdf"), StrEq(path)))
.WillOnce(Return(false));
@@ -669,18 +669,18 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = intf;
- return 0;
- }))
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = intf;
+ return 0;
+ }))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- *s = property;
- // Read the string in the pair (dictionary).
- return 0;
- }));
+ const char** s = static_cast<const char**>(p);
+ *s = property;
+ // Read the string in the pair (dictionary).
+ return 0;
+ }));
// std::map
EXPECT_CALL(sdbus_mock,
@@ -713,10 +713,10 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'b', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- bool* s = static_cast<bool*>(p);
- *s = asserted;
- return 0;
- }));
+ bool* s = static_cast<bool*>(p);
+ *s = asserted;
+ return 0;
+ }));
EXPECT_CALL(sdbus_mock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)) /* variant. */
@@ -750,18 +750,18 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = intf;
- return 0;
- }))
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = intf;
+ return 0;
+ }))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- const char** s = static_cast<const char**>(p);
- *s = property;
- // Read the string in the pair (dictionary).
- return 0;
- }));
+ const char** s = static_cast<const char**>(p);
+ *s = property;
+ // Read the string in the pair (dictionary).
+ return 0;
+ }));
// std::map
EXPECT_CALL(sdbus_mock,
@@ -794,10 +794,10 @@
EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'b', NotNull()))
.WillOnce(Invoke([&]([[maybe_unused]] sd_bus_message* m,
[[maybe_unused]] char type, void* p) {
- bool* s = static_cast<bool*>(p);
- *s = asserted;
- return 0;
- }));
+ bool* s = static_cast<bool*>(p);
+ *s = asserted;
+ return 0;
+ }));
EXPECT_CALL(sdbus_mock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)) /* variant. */
diff --git a/test/helpers.hpp b/test/helpers.hpp
index 4d3faea..378a4ae 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -66,9 +66,9 @@
[[maybe_unused]] const char* path,
[[maybe_unused]] const char* interface,
const char** names) {
- EXPECT_STREQ(properties[(*index)++].c_str(), names[0]);
- return 0;
- }));
+ EXPECT_STREQ(properties[(*index)++].c_str(), names[0]);
+ return 0;
+ }));
}
return;
diff --git a/test/pid_zone_unittest.cpp b/test/pid_zone_unittest.cpp
index 3a51d88..f0b96b1 100644
--- a/test/pid_zone_unittest.cpp
+++ b/test/pid_zone_unittest.cpp
@@ -190,7 +190,7 @@
[[maybe_unused]] const char* interface, const char** names) {
EXPECT_STREQ("Enable", names[0]);
return 0;
- }));
+ }));
zone->addPidControlProcess(sensorname, sensorType, setpoint,
bus_mock_enable, pidsensorpath.c_str(), defer);
@@ -248,7 +248,7 @@
[[maybe_unused]] const char* interface, const char** names) {
EXPECT_STREQ("Enable", names[0]);
return 0;
- }));
+ }));
zone->addPidControlProcess(sensorname, sensorType, setpoint,
bus_mock_enable, pidsensorpath.c_str(), defer);
@@ -292,7 +292,7 @@
[[maybe_unused]] const char* interface, const char** names) {
EXPECT_STREQ("Enable", names[0]);
return 0;
- }));
+ }));
zone->addPidControlProcess(sensorname, sensorType, setpoint,
bus_mock_enable, pidsensorpath.c_str(), defer);
@@ -708,7 +708,7 @@
[[maybe_unused]] const char* interface, const char** names) {
EXPECT_STREQ("Manual", names[0]);
return 0;
- }));
+ }));
// Method under test will set the manual mode to true and broadcast this
// change on dbus.
diff --git a/test/sensor_host_unittest.cpp b/test/sensor_host_unittest.cpp
index 4fe0816..cb5ede4 100644
--- a/test/sensor_host_unittest.cpp
+++ b/test/sensor_host_unittest.cpp
@@ -95,7 +95,7 @@
[[maybe_unused]] const char* interface, const char** names) {
EXPECT_STREQ("Value", names[0]);
return 0;
- }));
+ }));
std::chrono::high_resolution_clock::time_point t1 =
std::chrono::high_resolution_clock::now();