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: I08efc0671773edfae814ebcda5c01389155e2cac
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/src/activation.cpp b/src/activation.cpp
index e3f7eb9..226098c 100644
--- a/src/activation.cpp
+++ b/src/activation.cpp
@@ -275,8 +275,8 @@
bool Activation::isCompatible(const std::string& psuInventoryPath)
{
- auto service = utils::getService(bus, psuInventoryPath.c_str(),
- ASSET_IFACE);
+ auto service =
+ utils::getService(bus, psuInventoryPath.c_str(), ASSET_IFACE);
auto psuManufacturer = utils::getProperty<std::string>(
bus, service.c_str(), psuInventoryPath.c_str(), ASSET_IFACE,
MANUFACTURER);
diff --git a/src/item_updater.cpp b/src/item_updater.cpp
index dd6ffd4..03b4add 100644
--- a/src/item_updater.cpp
+++ b/src/item_updater.cpp
@@ -97,9 +97,9 @@
AssociationList associations;
auto activationState = Activation::Status::Ready;
- associations.emplace_back(std::make_tuple(ACTIVATION_FWD_ASSOCIATION,
- ACTIVATION_REV_ASSOCIATION,
- PSU_INVENTORY_PATH_BASE));
+ associations.emplace_back(std::make_tuple(
+ ACTIVATION_FWD_ASSOCIATION, ACTIVATION_REV_ASSOCIATION,
+ PSU_INVENTORY_PATH_BASE));
fs::path manifestPath(filePath);
manifestPath /= MANIFEST_FILE;
@@ -111,8 +111,8 @@
activationState, associations, filePath);
activations.emplace(versionId, std::move(activation));
- auto versionPtr = createVersionObject(path, versionId, version,
- purpose);
+ auto versionPtr =
+ createVersionObject(path, versionId, version, purpose);
versions.emplace(versionId, std::move(versionPtr));
}
return;
@@ -226,9 +226,9 @@
{
// The versionId is already created, associate the path
auto associations = it->second->associations();
- associations.emplace_back(std::make_tuple(ACTIVATION_FWD_ASSOCIATION,
- ACTIVATION_REV_ASSOCIATION,
- psuInventoryPath));
+ associations.emplace_back(
+ std::make_tuple(ACTIVATION_FWD_ASSOCIATION,
+ ACTIVATION_REV_ASSOCIATION, psuInventoryPath));
it->second->associations(associations);
psuPathActivationMap.emplace(psuInventoryPath, it->second);
}
@@ -238,9 +238,9 @@
AssociationList associations;
auto activationState = Activation::Status::Active;
- associations.emplace_back(std::make_tuple(ACTIVATION_FWD_ASSOCIATION,
- ACTIVATION_REV_ASSOCIATION,
- psuInventoryPath));
+ associations.emplace_back(
+ std::make_tuple(ACTIVATION_FWD_ASSOCIATION,
+ ACTIVATION_REV_ASSOCIATION, psuInventoryPath));
auto activation = createActivationObject(
path, versionId, "", activationState, associations, "");
@@ -498,8 +498,8 @@
objPath, versionId, extVersion, activationState, {}, path);
activations.emplace(versionId, std::move(activation));
- auto versionPtr = createVersionObject(objPath, versionId,
- version, purpose);
+ auto versionPtr =
+ createVersionObject(objPath, versionId, version, purpose);
versions.emplace(versionId, std::move(versionPtr));
}
else
diff --git a/src/item_updater.hpp b/src/item_updater.hpp
index 61ff666..2bfd39c 100644
--- a/src/item_updater.hpp
+++ b/src/item_updater.hpp
@@ -51,11 +51,11 @@
*/
ItemUpdater(sdbusplus::bus_t& bus, const std::string& path) :
ItemUpdaterInherit(bus, path.c_str()), bus(bus),
- versionMatch(bus,
- MatchRules::interfacesAdded() +
- MatchRules::path(SOFTWARE_OBJPATH),
- std::bind(std::mem_fn(&ItemUpdater::createActivation),
- this, std::placeholders::_1)),
+ versionMatch(
+ bus,
+ MatchRules::interfacesAdded() + MatchRules::path(SOFTWARE_OBJPATH),
+ std::bind(std::mem_fn(&ItemUpdater::createActivation), this,
+ std::placeholders::_1)),
psuInterfaceMatch(
bus,
MatchRules::interfacesAdded() +
@@ -142,12 +142,11 @@
const AssociationList& assocs, const std::string& filePath);
/** @brief Create Version object */
- std::unique_ptr<Version>
- createVersionObject(const std::string& objPath,
- const std::string& versionId,
- const std::string& versionString,
- sdbusplus::xyz::openbmc_project::Software::server::
- Version::VersionPurpose versionPurpose);
+ std::unique_ptr<Version> createVersionObject(
+ const std::string& objPath, const std::string& versionId,
+ const std::string& versionString,
+ sdbusplus::xyz::openbmc_project::Software::server::Version::
+ VersionPurpose versionPurpose);
/** @brief Create Activation and Version object for PSU inventory
* @details If the same version exists for multiple PSUs, just add
diff --git a/src/utils.cpp b/src/utils.cpp
index 0d9d8a0..9d32f3b 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -93,9 +93,8 @@
return services[0];
}
-std::vector<std::string> Utils::getServices(sdbusplus::bus_t& bus,
- const char* path,
- const char* interface) const
+std::vector<std::string> Utils::getServices(
+ sdbusplus::bus_t& bus, const char* path, const char* interface) const
{
auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
MAPPER_INTERFACE, "GetObject");
@@ -184,8 +183,8 @@
{
return std::find_if(assocs.begin(), assocs.end(),
[&psuInventoryPath](const auto& assoc) {
- return psuInventoryPath == std::get<2>(assoc);
- }) != assocs.end();
+ return psuInventoryPath == std::get<2>(assoc);
+ }) != assocs.end();
}
any Utils::getPropertyImpl(sdbusplus::bus_t& bus, const char* service,
diff --git a/src/utils.hpp b/src/utils.hpp
index 446f024..2e73d87 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -141,8 +141,8 @@
T getProperty(sdbusplus::bus_t& bus, const char* service, const char* path,
const char* interface, const char* propertyName) const
{
- any result = getPropertyImpl(bus, service, path, interface,
- propertyName);
+ any result =
+ getPropertyImpl(bus, service, path, interface, propertyName);
auto value = any_cast<PropertyType>(result);
return std::get<T>(value);
}
diff --git a/src/version.cpp b/src/version.cpp
index 58abf79..f64e4ad 100644
--- a/src/version.cpp
+++ b/src/version.cpp
@@ -23,9 +23,8 @@
using namespace phosphor::logging;
using Argument = xyz::openbmc_project::Common::InvalidArgument;
-std::map<std::string, std::string>
- Version::getValues(const std::string& filePath,
- const std::vector<std::string>& keys)
+std::map<std::string, std::string> Version::getValues(
+ const std::string& filePath, const std::vector<std::string>& keys)
{
if (filePath.empty())
{
diff --git a/src/version.hpp b/src/version.hpp
index 021aadd..144c96e 100644
--- a/src/version.hpp
+++ b/src/version.hpp
@@ -107,9 +107,8 @@
*
* @return The map of keys with filled values.
**/
- static std::map<std::string, std::string>
- getValues(const std::string& filePath,
- const std::vector<std::string>& keys);
+ static std::map<std::string, std::string> getValues(
+ const std::string& filePath, const std::vector<std::string>& keys);
/**
* @brief Read the manifest file to get the value of the key.
diff --git a/test/test_utils.cpp b/test/test_utils.cpp
index 383ed4b..a93af26 100644
--- a/test/test_utils.cpp
+++ b/test/test_utils.cpp
@@ -42,16 +42,17 @@
// std::string
EXPECT_CALL(sdbusMock, sd_bus_message_read_basic(IsNull(), 's', _))
.WillOnce(Invoke([&](sd_bus_message*, char, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = path0;
- return 0;
- })).WillOnce(Invoke([&](sd_bus_message*, char, void* p) {
- const char** s = static_cast<const char**>(p);
- // Read the first parameter, the string.
- *s = path1;
- return 0;
- }));
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = path0;
+ return 0;
+ }))
+ .WillOnce(Invoke([&](sd_bus_message*, char, void* p) {
+ const char** s = static_cast<const char**>(p);
+ // Read the first parameter, the string.
+ *s = path1;
+ return 0;
+ }));
EXPECT_CALL(sdbusMock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)); /* end of std::vector */
@@ -74,9 +75,9 @@
TEST(Utils, IsAssociated)
{
std::string path = "/com/example/chassis/powersupply0";
- utils::AssociationList assocs = {{ACTIVATION_FWD_ASSOCIATION,
- ACTIVATION_REV_ASSOCIATION,
- "a-different-path"}};
+ utils::AssociationList assocs = {
+ {ACTIVATION_FWD_ASSOCIATION, ACTIVATION_REV_ASSOCIATION,
+ "a-different-path"}};
EXPECT_FALSE(utils::isAssociated(path, assocs));