clang-format: copy latest and re-format
clang-format-16 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: I077deb6e98025e4e8c6abd4d039f9af4db19342b
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index 5f0cb09..d92a3f1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -7,7 +7,9 @@
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: Align
-AlignTrailingComments: true
+AlignTrailingComments:
+ Kind: Always
+ OverEmptyLines: 1
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
@@ -36,6 +38,7 @@
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
+BreakAfterAttributes: Never
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
@@ -78,7 +81,10 @@
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
+InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -98,6 +104,7 @@
ReferenceAlignment: Left
ReflowComments: true
RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: Keyword
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
@@ -117,7 +124,6 @@
SpacesInSquareBrackets: false
Standard: Latest
TabWidth: 4
-UseCRLF: false
UseTab: Never
...
diff --git a/extensions/openpower-pels/data_interface.cpp b/extensions/openpower-pels/data_interface.cpp
index 4a91fd0..ead3c16 100644
--- a/extensions/openpower-pels/data_interface.cpp
+++ b/extensions/openpower-pels/data_interface.cpp
@@ -151,14 +151,14 @@
_properties.emplace_back(std::make_unique<PropertyWatcher<DataInterface>>(
bus, object_path::enableHostPELs, interface::enable, "Enabled", *this,
[this](const auto& value) {
- if (std::get<bool>(value) != this->_sendPELsToHost)
- {
- log<level::INFO>(
- fmt::format("The send PELs to host setting changed to {}",
- std::get<bool>(value))
- .c_str());
- }
- this->_sendPELsToHost = std::get<bool>(value);
+ if (std::get<bool>(value) != this->_sendPELsToHost)
+ {
+ log<level::INFO>(
+ fmt::format("The send PELs to host setting changed to {}",
+ std::get<bool>(value))
+ .c_str());
+ }
+ this->_sendPELsToHost = std::get<bool>(value);
}));
// Watch the BMCState property
@@ -172,17 +172,17 @@
_properties.emplace_back(std::make_unique<InterfaceWatcher<DataInterface>>(
bus, object_path::chassisState, interface::chassisState, *this,
[this](const auto& properties) {
- auto state = properties.find("CurrentPowerState");
- if (state != properties.end())
- {
- this->_chassisState = std::get<std::string>(state->second);
- }
+ auto state = properties.find("CurrentPowerState");
+ if (state != properties.end())
+ {
+ this->_chassisState = std::get<std::string>(state->second);
+ }
- auto trans = properties.find("RequestedPowerTransition");
- if (trans != properties.end())
- {
- this->_chassisTransition = std::get<std::string>(trans->second);
- }
+ auto trans = properties.find("RequestedPowerTransition");
+ if (trans != properties.end())
+ {
+ this->_chassisTransition = std::get<std::string>(trans->second);
+ }
}));
// Watch the CurrentHostState property
@@ -197,19 +197,18 @@
bus, object_path::biosConfigMgr, interface::biosConfigMgr,
"BaseBIOSTable", service_name::biosConfigMgr, *this,
[this](const auto& value) {
- const auto& attributes = std::get<BiosAttributes>(value);
+ const auto& attributes = std::get<BiosAttributes>(value);
- auto it = attributes.find("pvm_hmc_managed");
- if (it != attributes.end())
+ auto it = attributes.find("pvm_hmc_managed");
+ if (it != attributes.end())
+ {
+ const auto& currentValVariant = std::get<5>(it->second);
+ auto currentVal = std::get_if<std::string>(¤tValVariant);
+ if (currentVal)
{
- const auto& currentValVariant = std::get<5>(it->second);
- auto currentVal = std::get_if<std::string>(¤tValVariant);
- if (currentVal)
- {
- this->_hmcManaged = (*currentVal == "Enabled") ? true
- : false;
- }
+ this->_hmcManaged = (*currentVal == "Enabled") ? true : false;
}
+ }
}));
}
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index 3b7ecf5..4e16fc5 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -64,11 +64,11 @@
#ifdef PEL_ENABLE_PHAL
// Add sbe ffdc processed data into ffdcfiles.
namespace sbe = openpower::pels::sbe;
- auto processReq =
- std::any_of(ffdcFiles.begin(), ffdcFiles.end(), [](const auto& file) {
- return file.format == UserDataFormat::custom &&
- file.subType == sbe::sbeFFDCSubType;
- });
+ auto processReq = std::any_of(ffdcFiles.begin(), ffdcFiles.end(),
+ [](const auto& file) {
+ return file.format == UserDataFormat::custom &&
+ file.subType == sbe::sbeFFDCSubType;
+ });
// sbeFFDC can't be destroyed until the end of the PEL constructor
// because it needs to keep around the FFDC Files to be used below.
std::unique_ptr<sbe::SbeFFDC> sbeFFDCPtr;
@@ -309,11 +309,11 @@
std::optional<SRC*> PEL::primarySRC() const
{
- auto src = std::find_if(
- _optionalSections.begin(), _optionalSections.end(), [](auto& section) {
- return section->header().id ==
- static_cast<uint16_t>(SectionID::primarySRC);
- });
+ auto src = std::find_if(_optionalSections.begin(), _optionalSections.end(),
+ [](auto& section) {
+ return section->header().id ==
+ static_cast<uint16_t>(SectionID::primarySRC);
+ });
if (src != _optionalSections.end())
{
return static_cast<SRC*>(src->get());
@@ -554,11 +554,11 @@
{
// Get the ED section from PEL
auto op = std::find_if(_optionalSections.begin(),
- _optionalSections.end(), [](auto& section) {
- return section->header().id ==
- static_cast<uint16_t>(
- SectionID::extUserData);
- });
+ _optionalSections.end(),
+ [](auto& section) {
+ return section->header().id ==
+ static_cast<uint16_t>(SectionID::extUserData);
+ });
// Check for ED section found and its not the last section of PEL
if (op != _optionalSections.end())
diff --git a/extensions/openpower-pels/pel_values.cpp b/extensions/openpower-pels/pel_values.cpp
index a94606c..e52f7e1 100644
--- a/extensions/openpower-pels/pel_values.cpp
+++ b/extensions/openpower-pels/pel_values.cpp
@@ -252,8 +252,8 @@
{
return std::find_if(fields.begin(), fields.end(),
[value](const auto& entry) {
- return value == std::get<fieldValuePos>(entry);
- });
+ return value == std::get<fieldValuePos>(entry);
+ });
}
PELValues::const_iterator findByName(const std::string& name,
@@ -262,8 +262,8 @@
{
return std::find_if(fields.begin(), fields.end(),
[&name](const auto& entry) {
- return name == std::get<registryNamePos>(entry);
- });
+ return name == std::get<registryNamePos>(entry);
+ });
}
/**
@@ -357,13 +357,13 @@
const pel_values::PELValues& table)
{
std::vector<std::string> foundValues;
- std::for_each(
- table.begin(), table.end(), [&value, &foundValues](const auto& entry) {
- if (value & std::get<fieldValuePos>(entry))
- {
- foundValues.push_back(std::get<descriptionPos>(entry));
- }
- });
+ std::for_each(table.begin(), table.end(),
+ [&value, &foundValues](const auto& entry) {
+ if (value & std::get<fieldValuePos>(entry))
+ {
+ foundValues.push_back(std::get<descriptionPos>(entry));
+ }
+ });
return foundValues;
}
diff --git a/extensions/openpower-pels/registry.cpp b/extensions/openpower-pels/registry.cpp
index c9c4169..e646928 100644
--- a/extensions/openpower-pels/registry.cpp
+++ b/extensions/openpower-pels/registry.cpp
@@ -560,10 +560,10 @@
const auto& callouts = json["CalloutsWithTheirADValues"];
// find the entry with that AD value
- auto it = std::find_if(
- callouts.begin(), callouts.end(), [adValue](const nlohmann::json& j) {
- return *adValue == j["ADValue"].get<std::string>();
- });
+ auto it = std::find_if(callouts.begin(), callouts.end(),
+ [adValue](const nlohmann::json& j) {
+ return *adValue == j["ADValue"].get<std::string>();
+ });
if (it == callouts.end())
{
@@ -658,13 +658,12 @@
auto& reg = (_registry) ? _registry : registryTmp;
const auto& registry = reg.value();
// Find an entry with this name in the PEL array.
- auto e = std::find_if(
- registry["PELs"].begin(), registry["PELs"].end(),
- [&name, &type](const auto& j) {
- return ((name == j["Name"] && type == LookupType::name) ||
- (name == j["SRC"]["ReasonCode"] &&
- type == LookupType::reasonCode));
- });
+ auto e = std::find_if(registry["PELs"].begin(), registry["PELs"].end(),
+ [&name, &type](const auto& j) {
+ return (
+ (name == j["Name"] && type == LookupType::name) ||
+ (name == j["SRC"]["ReasonCode"] && type == LookupType::reasonCode));
+ });
if (e != registry["PELs"].end())
{
diff --git a/extensions/openpower-pels/repository.cpp b/extensions/openpower-pels/repository.cpp
index e04b9a8..b19ce7a 100644
--- a/extensions/openpower-pels/repository.cpp
+++ b/extensions/openpower-pels/repository.cpp
@@ -566,18 +566,19 @@
{
std::vector<Repository::AttributesReference> attributes;
- std::for_each(
- _pelAttributes.begin(), _pelAttributes.end(),
- [&attributes](auto& pelEntry) { attributes.push_back(pelEntry); });
+ std::for_each(_pelAttributes.begin(), _pelAttributes.end(),
+ [&attributes](auto& pelEntry) {
+ attributes.push_back(pelEntry);
+ });
std::sort(attributes.begin(), attributes.end(),
[order](const auto& left, const auto& right) {
- if (order == SortOrder::ascending)
- {
- return left.get().second.path < right.get().second.path;
- }
- return left.get().second.path > right.get().second.path;
- });
+ if (order == SortOrder::ascending)
+ {
+ return left.get().second.path < right.get().second.path;
+ }
+ return left.get().second.path > right.get().second.path;
+ });
return attributes;
}
@@ -696,18 +697,18 @@
// Pass 4: delete all PELs
static const std::vector<std::function<bool(const PELAttributes& pel)>>
stateChecks{[](const auto& pel) {
- return pel.hmcState == TransmissionState::acked;
+ return pel.hmcState == TransmissionState::acked;
},
[](const auto& pel) {
- return pel.hostState == TransmissionState::acked;
- },
+ return pel.hostState == TransmissionState::acked;
+ },
- [](const auto& pel) {
- return pel.hostState == TransmissionState::sent;
- },
+ [](const auto& pel) {
+ return pel.hostState == TransmissionState::sent;
+ },
- [](const auto& /*pel*/) { return true; }};
+ [](const auto& /*pel*/) { return true; }};
for (const auto& stateCheck : stateChecks)
{
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index dc75e07..338c323 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -1558,8 +1558,8 @@
if (std::all_of(progressCodeString.begin(), progressCodeString.end(),
[](char c) {
- return std::isxdigit(static_cast<unsigned char>(c));
- }))
+ return std::isxdigit(static_cast<unsigned char>(c));
+ }))
{
progressCode = std::stoul(progressCodeString, nullptr, 16);
}
diff --git a/extensions/openpower-pels/tools/peltool.cpp b/extensions/openpower-pels/tools/peltool.cpp
index 39cb1e5..063127f 100644
--- a/extensions/openpower-pels/tools/peltool.cpp
+++ b/extensions/openpower-pels/tools/peltool.cpp
@@ -496,8 +496,8 @@
// Sort the pairs based on second time parameter
std::sort(PELs.begin(), PELs.end(),
[](const auto& left, const auto& right) {
- return left.second < right.second;
- });
+ return left.second < right.second;
+ });
bool foundPEL = false;
diff --git a/lib/include/phosphor-logging/lg2/conversion.hpp b/lib/include/phosphor-logging/lg2/conversion.hpp
index cdff0a3..373fbe4 100644
--- a/lib/include/phosphor-logging/lg2/conversion.hpp
+++ b/lib/include/phosphor-logging/lg2/conversion.hpp
@@ -28,9 +28,8 @@
template <typename T>
concept string_like_type =
(std::constructible_from<std::string_view, T> ||
- std::same_as<std::filesystem::path, std::decay_t<T>>) &&
- !
-std::same_as<std::nullptr_t, T>;
+ std::same_as<std::filesystem::path,
+ std::decay_t<T>>)&&!std::same_as<std::nullptr_t, T>;
/** Concept to determine if an item acts like a pointer.
*
@@ -39,9 +38,7 @@
*/
template <typename T>
concept pointer_type = (std::is_pointer_v<T> ||
- std::same_as<std::nullptr_t, T>) &&
- !
-string_like_type<T>;
+ std::same_as<std::nullptr_t, T>)&&!string_like_type<T>;
/** Concept to determine if an item acts like an unsigned_integral.
*
@@ -49,8 +46,8 @@
* `True` and `False` strings.
*/
template <typename T>
-concept unsigned_integral_except_bool = !
-std::same_as<T, bool>&& std::unsigned_integral<T>;
+concept unsigned_integral_except_bool = !std::same_as<T, bool> &&
+ std::unsigned_integral<T>;
template <typename T>
concept sdbusplus_enum = sdbusplus::message::has_convert_from_string_v<T>;
diff --git a/log_manager.cpp b/log_manager.cpp
index 23e7bd6..d573972 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -384,8 +384,8 @@
// Verify we don't already have this entry blocking
auto it = find_if(this->blockingErrors.begin(), this->blockingErrors.end(),
[&](const std::unique_ptr<Block>& obj) {
- return obj->entryId == entryId;
- });
+ return obj->entryId == entryId;
+ });
if (it != this->blockingErrors.end())
{
// Already recorded so just return
@@ -470,8 +470,8 @@
// First look for blocking object and remove
auto it = find_if(blockingErrors.begin(), blockingErrors.end(),
[&](const std::unique_ptr<Block>& obj) {
- return obj->entryId == entryId;
- });
+ return obj->entryId == entryId;
+ });
if (it != blockingErrors.end())
{
blockingErrors.erase(it);
diff --git a/test/openpower-pels/data_interface_test.cpp b/test/openpower-pels/data_interface_test.cpp
index 3041bc2..febf937 100644
--- a/test/openpower-pels/data_interface_test.cpp
+++ b/test/openpower-pels/data_interface_test.cpp
@@ -33,4 +33,4 @@
std::string uptime = dataIntf.getBMCUptime(seconds);
EXPECT_EQ(uptime, retUptime);
-}
\ No newline at end of file
+}
diff --git a/test/openpower-pels/host_notifier_test.cpp b/test/openpower-pels/host_notifier_test.cpp
index 42a87c7..6fc235b 100644
--- a/test/openpower-pels/host_notifier_test.cpp
+++ b/test/openpower-pels/host_notifier_test.cpp
@@ -121,8 +121,8 @@
{
bool hostState = false;
bool called = false;
- DataInterfaceBase::HostStateChangeFunc func = [&hostState,
- &called](bool state) {
+ DataInterfaceBase::HostStateChangeFunc func =
+ [&hostState, &called](bool state) {
hostState = state;
called = true;
};
diff --git a/test/openpower-pels/mocks.hpp b/test/openpower-pels/mocks.hpp
index df85066..094c670 100644
--- a/test/openpower-pels/mocks.hpp
+++ b/test/openpower-pels/mocks.hpp
@@ -191,8 +191,8 @@
int fd = open(_fifo.c_str(), O_NONBLOCK | O_RDWR);
EXPECT_TRUE(fd >= 0) << "Unable to open FIFO";
- auto callback = [this](sdeventplus::source::IO& source, int fd,
- uint32_t events) {
+ auto callback =
+ [this](sdeventplus::source::IO& source, int fd, uint32_t events) {
this->receive(source, fd, events);
};
diff --git a/test/openpower-pels/pel_test.cpp b/test/openpower-pels/pel_test.cpp
index 66cb6cf..9fa8f2b 100644
--- a/test/openpower-pels/pel_test.cpp
+++ b/test/openpower-pels/pel_test.cpp
@@ -261,11 +261,11 @@
// Make sure that there are still 2 UD sections.
const auto& optSections = pel.optionalSections();
- auto udCount = std::count_if(
- optSections.begin(), optSections.end(), [](const auto& section) {
- return section->header().id ==
- static_cast<uint16_t>(SectionID::userData);
- });
+ auto udCount = std::count_if(optSections.begin(), optSections.end(),
+ [](const auto& section) {
+ return section->header().id ==
+ static_cast<uint16_t>(SectionID::userData);
+ });
EXPECT_EQ(udCount, 2); // AD section and sysInfo section
}
diff --git a/test/openpower-pels/pel_utils.cpp b/test/openpower-pels/pel_utils.cpp
index b9b46a6..9b33818 100644
--- a/test/openpower-pels/pel_utils.cpp
+++ b/test/openpower-pels/pel_utils.cpp
@@ -32,10 +32,10 @@
const std::vector<uint8_t> privateHeaderSection{
// section header
- 0x50, 0x48, // ID 'PH'
- 0x00, 0x30, // Size
- 0x01, 0x02, // version, subtype
- 0x03, 0x04, // comp ID
+ 0x50, 0x48, // ID 'PH'
+ 0x00, 0x30, // Size
+ 0x01, 0x02, // version, subtype
+ 0x03, 0x04, // comp ID
0x20, 0x30, 0x05, 0x09, 0x11, 0x1E, 0x1, 0x63, // create timestamp
0x20, 0x31, 0x06, 0x0F, 0x09, 0x22, 0x3A, 0x00, // commit timestamp
@@ -50,10 +50,10 @@
const std::vector<uint8_t> userHeaderSection{
// section header
- 0x55, 0x48, // ID 'UH'
- 0x00, 0x18, // Size
- 0x01, 0x0A, // version, subtype
- 0x0B, 0x0C, // comp ID
+ 0x55, 0x48, // ID 'UH'
+ 0x00, 0x18, // Size
+ 0x01, 0x0A, // version, subtype
+ 0x0B, 0x0C, // comp ID
0x10, 0x04, // subsystem, scope
0x20, 0x00, // severity, type