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: I2b9626d95674508bb090745de6471fe2755c89fd
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/activation.cpp b/activation.cpp
index cd44cc0..33b1e00 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -116,8 +116,8 @@
if (!activationProgress)
{
- activationProgress = std::make_unique<ActivationProgress>(bus,
- path);
+ activationProgress =
+ std::make_unique<ActivationProgress>(bus, path);
}
if (!activationBlocksTransition)
@@ -192,8 +192,8 @@
if (!redundancyPriority)
{
- redundancyPriority = std::make_unique<RedundancyPriority>(bus, path,
- *this, 0);
+ redundancyPriority =
+ std::make_unique<RedundancyPriority>(bus, path, *this, 0);
}
// Remove version object from image manager
diff --git a/download_manager.hpp b/download_manager.hpp
index 9acba12..84a8814 100644
--- a/download_manager.hpp
+++ b/download_manager.hpp
@@ -30,7 +30,7 @@
* @param[in] objPath - The Dbus object path
*/
Download(sdbusplus::bus_t& bus, const std::string& objPath) :
- DownloadInherit(bus, (objPath).c_str()){};
+ DownloadInherit(bus, (objPath).c_str()) {};
/**
* @brief Download the specified image via TFTP
diff --git a/image_manager.cpp b/image_manager.cpp
index c9a958d..a7687c6 100644
--- a/image_manager.cpp
+++ b/image_manager.cpp
@@ -147,8 +147,8 @@
}
// Get machine name for image to be upgraded
- std::string machineStr = Version::getValue(manifestPath.string(),
- "MachineName");
+ std::string machineStr =
+ Version::getValue(manifestPath.string(), "MachineName");
if (!machineStr.empty())
{
if (machineStr != currMachine)
@@ -193,8 +193,8 @@
auto purpose = convertedPurpose.value_or(Version::VersionPurpose::Unknown);
// Get ExtendedVersion
- std::string extendedVersion = Version::getValue(manifestPath.string(),
- "ExtendedVersion");
+ std::string extendedVersion =
+ Version::getValue(manifestPath.string(), "ExtendedVersion");
// Get CompatibleNames
std::vector<std::string> compatibleNames =
@@ -213,8 +213,8 @@
// active versions on D-Bus that is not managed by this service.
// So check D-Bus if there is an existing version.
auto allSoftwareObjs = getSoftwareObjects(bus);
- auto it = std::find(allSoftwareObjs.begin(), allSoftwareObjs.end(),
- objPath);
+ auto it =
+ std::find(allSoftwareObjs.begin(), allSoftwareObjs.end(), objPath);
if (versions.find(id) == versions.end() && it == allSoftwareObjs.end())
{
// Rename the temp dir to image dir
@@ -228,8 +228,8 @@
imageDirPath.string(), compatibleNames,
std::bind(&Manager::erase, this, std::placeholders::_1), id);
versionPtr->deleteObject =
- std::make_unique<phosphor::software::manager::Delete>(bus, objPath,
- *versionPtr);
+ std::make_unique<phosphor::software::manager::Delete>(
+ bus, objPath, *versionPtr);
versions.insert(std::make_pair(id, std::move(versionPtr)));
}
else
diff --git a/image_manager.hpp b/image_manager.hpp
index 21dd373..f1281eb 100644
--- a/image_manager.hpp
+++ b/image_manager.hpp
@@ -26,7 +26,7 @@
*
* @param[in] bus - The Dbus bus object
*/
- explicit Manager(sdbusplus::bus_t& bus) : bus(bus){};
+ explicit Manager(sdbusplus::bus_t& bus) : bus(bus) {};
/**
* @brief Verify and untar the tarball. Verify the manifest file.
diff --git a/image_verify.cpp b/image_verify.cpp
index 12e938e..687fff7 100644
--- a/image_verify.cpp
+++ b/image_verify.cpp
@@ -38,8 +38,7 @@
Signature::Signature(const fs::path& imageDirPath,
const fs::path& signedConfPath) :
- imageDirPath(imageDirPath),
- signedConfPath(signedConfPath)
+ imageDirPath(imageDirPath), signedConfPath(signedConfPath)
{
fs::path file(imageDirPath / MANIFEST_FILE_NAME);
@@ -200,8 +199,8 @@
sigFile += SIGNATURE_FILE_EXT;
// Verify the signature.
- optionalImagesValid = verifyFile(file, sigFile, publicKeyFile,
- hashType);
+ optionalImagesValid =
+ verifyFile(file, sigFile, publicKeyFile, hashType);
if (!optionalImagesValid)
{
error("Image file Signature Validation failed on {IMAGE}",
@@ -410,10 +409,9 @@
size);
}
-bool Signature::checkAndVerifyImage(const std::string& filePath,
- const std::string& publicKeyPath,
- const std::vector<std::string>& imageList,
- bool& fileFound)
+bool Signature::checkAndVerifyImage(
+ const std::string& filePath, const std::string& publicKeyPath,
+ const std::vector<std::string>& imageList, bool& fileFound)
{
bool valid = true;
diff --git a/item_updater.cpp b/item_updater.cpp
index fad8c21..e2282f7 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -144,7 +144,7 @@
{
result = ItemUpdater::ActivationStatus::ready;
}
- AssociationList associations = {};
+ AssociationList associations;
if (result == ItemUpdater::ActivationStatus::ready)
{
@@ -161,8 +161,8 @@
std::bind(&ItemUpdater::erase, this, std::placeholders::_1),
versionId);
versionPtr->deleteObject =
- std::make_unique<phosphor::software::manager::Delete>(bus, path,
- *versionPtr);
+ std::make_unique<phosphor::software::manager::Delete>(
+ bus, path, *versionPtr);
versions.insert(std::make_pair(versionId, std::move(versionPtr)));
activations.insert(std::make_pair(
@@ -293,7 +293,7 @@
}
}
- AssociationList associations = {};
+ AssociationList associations;
if (activationState == server::Activation::Activations::Active)
{
@@ -382,8 +382,8 @@
// create rofs-<versionId>-functional under MEDIA_DIR, then call again
// processBMCImage() to create the D-Bus interface for it.
auto version = VersionClass::getBMCVersion(OS_RELEASE_FILE);
- auto id = phosphor::software::manager::Version::getId(version +
- functionalSuffix);
+ auto id = phosphor::software::manager::Version::getId(
+ version + functionalSuffix);
auto versionFileDir = BMC_ROFS_PREFIX + id + functionalSuffix + "/etc/";
try
{
@@ -391,8 +391,8 @@
{
fs::create_directories(versionFileDir);
}
- auto versionFilePath = BMC_ROFS_PREFIX + id + functionalSuffix +
- OS_RELEASE_FILE;
+ auto versionFilePath =
+ BMC_ROFS_PREFIX + id + functionalSuffix + OS_RELEASE_FILE;
fs::create_directory_symlink(OS_RELEASE_FILE, versionFilePath);
ItemUpdater::processBMCImage();
}
@@ -536,8 +536,8 @@
cmpPriority cmpPriorityFunc =
[](const std::pair<std::string, uint8_t>& priority1,
const std::pair<std::string, uint8_t>& priority2) {
- return priority1.second <= priority2.second;
- };
+ return priority1.second <= priority2.second;
+ };
// Sort versions by ascending priority
std::set<std::pair<std::string, uint8_t>, cmpPriority> prioritySet(
@@ -618,8 +618,8 @@
// The fieldmode u-boot environment variable may not exist since it is not
// part of the default environment, run fw_printenv with 2>&1 to ignore the
// error message in the journal "Error: "fieldmode" not defined"
- std::pair<int, std::string> ret = utils::execute("/sbin/fw_printenv", "-n",
- "fieldmode", "2>&1");
+ std::pair<int, std::string> ret =
+ utils::execute("/sbin/fw_printenv", "-n", "fieldmode", "2>&1");
if (ret.first != 0)
{
@@ -873,7 +873,7 @@
auto versionId = path.substr(pos + 1);
auto version = "null";
- AssociationList assocs = {};
+ AssociationList assocs;
biosActivation = std::make_unique<Activation>(
bus, path, *this, versionId, server::Activation::Activations::Active,
assocs);
@@ -885,8 +885,8 @@
std::vector<std::string>(),
std::bind(dummyErase, std::placeholders::_1), "");
biosVersion->deleteObject =
- std::make_unique<phosphor::software::manager::Delete>(bus, path,
- *biosVersion);
+ std::make_unique<phosphor::software::manager::Delete>(
+ bus, path, *biosVersion);
}
#endif
diff --git a/item_updater.hpp b/item_updater.hpp
index f850492..9768627 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -260,7 +260,7 @@
sdbusplus::bus::match_t versionMatch;
/** @brief This entry's associations */
- AssociationList assocs = {};
+ AssociationList assocs;
/** @brief Clears read only partition for
* given Activation D-Bus object.
diff --git a/side-switch/side_switch.cpp b/side-switch/side_switch.cpp
index 6bb3d1d..0261569 100644
--- a/side-switch/side_switch.cpp
+++ b/side-switch/side_switch.cpp
@@ -66,10 +66,10 @@
std::vector<std::string> allSoftwarePaths;
try
{
- auto method = bus.new_method_call("xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper",
- "GetSubTreePaths");
+ auto method = bus.new_method_call(
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths");
method.append("/xyz/openbmc_project/software");
method.append(0); // Depth 0 to search all
method.append(
diff --git a/sync_watch.cpp b/sync_watch.cpp
index 225bf18..f3bf636 100644
--- a/sync_watch.cpp
+++ b/sync_watch.cpp
@@ -22,8 +22,8 @@
void SyncWatch::addInotifyWatch(const fs::path& path)
{
- auto wd = inotify_add_watch(inotifyFd, path.c_str(),
- IN_CLOSE_WRITE | IN_DELETE);
+ auto wd =
+ inotify_add_watch(inotifyFd, path.c_str(), IN_CLOSE_WRITE | IN_DELETE);
if (-1 == wd)
{
error("inotify_add_watch on {PATH} failed: {ERRNO}", "ERRNO", errno,
@@ -36,8 +36,7 @@
SyncWatch::SyncWatch(sd_event& loop,
std::function<int(int, fs::path&)> syncCallback) :
- inotifyFd(-1),
- syncCallback(std::move(syncCallback)), loop(loop)
+ inotifyFd(-1), syncCallback(std::move(syncCallback)), loop(loop)
{
auto fd = inotify_init1(IN_NONBLOCK);
if (-1 == fd)
diff --git a/ubi/flash.cpp b/ubi/flash.cpp
index 64c9ea5..cb3e045 100644
--- a/ubi/flash.cpp
+++ b/ubi/flash.cpp
@@ -41,8 +41,8 @@
auto rwServiceFile = "obmc-flash-bmc-ubirw.service";
auto roServiceFile = "obmc-flash-bmc-ubiro@" + versionId + ".service";
auto flashId = parent.versions.find(versionId)->second->path();
- auto ubootVarsServiceFile = "obmc-flash-bmc-updateubootvars@" + flashId +
- ".service";
+ auto ubootVarsServiceFile =
+ "obmc-flash-bmc-updateubootvars@" + flashId + ".service";
if (newStateUnit == rwServiceFile && newStateResult == "done")
{
diff --git a/ubi/item_updater_helper.cpp b/ubi/item_updater_helper.cpp
index 486577a..ae00ea5 100644
--- a/ubi/item_updater_helper.cpp
+++ b/ubi/item_updater_helper.cpp
@@ -66,8 +66,8 @@
{
auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
SYSTEMD_INTERFACE, "StartUnit");
- auto updateEnvVarsFile = "obmc-flash-bmc-updateubootvars@" + flashId +
- ".service";
+ auto updateEnvVarsFile =
+ "obmc-flash-bmc-updateubootvars@" + flashId + ".service";
method.append(updateEnvVarsFile, "replace");
try
diff --git a/usb/usb_manager.hpp b/usb/usb_manager.hpp
index 0e781f7..98d6796 100644
--- a/usb/usb_manager.hpp
+++ b/usb/usb_manager.hpp
@@ -26,8 +26,7 @@
explicit USBManager(sdbusplus::bus_t& bus, sdeventplus::Event& event,
const fs::path& devPath, const fs::path& usbPath) :
- bus(bus),
- event(event), devicePath(devPath), usbPath(usbPath),
+ bus(bus), event(event), devicePath(devPath), usbPath(usbPath),
isUSBCodeUpdate(false),
fwUpdateMatcher(bus,
MatchRules::interfacesAdded() +
diff --git a/version.cpp b/version.cpp
index 54b8c27..ed447f8 100644
--- a/version.cpp
+++ b/version.cpp
@@ -43,9 +43,8 @@
return values.at(0);
}
-std::vector<std::string>
- Version::getRepeatedValues(const std::string& manifestFilePath,
- std::string key)
+std::vector<std::string> Version::getRepeatedValues(
+ const std::string& manifestFilePath, std::string key)
{
key = key + "=";
auto keySize = key.length();
@@ -208,8 +207,8 @@
// is 0 for the unquoted case, so substr() is called with a len
// parameter of npos (-1) which according to the documentation
// indicates to use all characters until the end of the string.
- version = versionValue.substr(pos,
- versionValue.find_last_of('"') - pos);
+ version =
+ versionValue.substr(pos, versionValue.find_last_of('"') - pos);
break;
}
}
diff --git a/watch.cpp b/watch.cpp
index 991bf48..76bb680 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -44,8 +44,8 @@
// Store a copy of errno, because the string creation below will
// invalidate errno due to one more system calls.
auto error = errno;
- throw std::runtime_error("inotify_init1 failed, errno="s +
- std::strerror(error));
+ throw std::runtime_error(
+ "inotify_init1 failed, errno="s + std::strerror(error));
}
wd = inotify_add_watch(fd, IMG_UPLOAD_DIR, IN_CLOSE_WRITE);
@@ -53,15 +53,15 @@
{
auto error = errno;
close(fd);
- throw std::runtime_error("inotify_add_watch failed, errno="s +
- std::strerror(error));
+ throw std::runtime_error(
+ "inotify_add_watch failed, errno="s + std::strerror(error));
}
auto rc = sd_event_add_io(loop, nullptr, fd, EPOLLIN, callback, this);
if (0 > rc)
{
- throw std::runtime_error("failed to add to event loop, rc="s +
- std::strerror(-rc));
+ throw std::runtime_error(
+ "failed to add to event loop, rc="s + std::strerror(-rc));
}
}
@@ -91,8 +91,8 @@
if (0 > bytes)
{
auto error = errno;
- throw std::runtime_error("failed to read inotify event, errno="s +
- std::strerror(error));
+ throw std::runtime_error(
+ "failed to read inotify event, errno="s + std::strerror(error));
}
auto offset = 0;