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: I50e60f2b1a9db9039cb5450ae509064eaeaa9d2e
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index cab3139..d92a3f1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -6,12 +6,14 @@
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
-AlignOperands: true
-AlignTrailingComments: true
+AlignOperands: Align
+AlignTrailingComments:
+ Kind: Always
+ OverEmptyLines: 1
AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
+AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
@@ -36,6 +38,7 @@
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
+BreakAfterAttributes: Never
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
@@ -49,6 +52,7 @@
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
+DeriveLineEnding: false
DerivePointerAlignment: false
PointerAlignment: Left
DisableFormat: false
@@ -74,9 +78,13 @@
- Regex: '.*'
Priority: 6
IndentCaseLabels: true
+IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -84,13 +92,19 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyIndentedWhitespace: 0
+QualifierAlignment: Left
+ReferenceAlignment: Left
ReflowComments: true
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: Keyword
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
diff --git a/activation.cpp b/activation.cpp
index 7c1f735..d9ee2d0 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
@@ -366,7 +366,6 @@
}
else
{
-
auto method = bus.new_method_call(service.c_str(), applyTimeObjPath,
dbusPropIntf, "Get");
method.append(applyTimeIntf, applyTimeProp);
diff --git a/download_manager.cpp b/download_manager.cpp
index fdffcb9..1197851 100644
--- a/download_manager.cpp
+++ b/download_manager.cpp
@@ -112,7 +112,6 @@
}
else if (WEXITSTATUS(status) != 0)
{
-
error("Failed ({STATUS}) to launch tftp", "STATUS", status);
}
}
diff --git a/image_manager.cpp b/image_manager.cpp
index f998871..baa0571 100644
--- a/image_manager.cpp
+++ b/image_manager.cpp
@@ -45,8 +45,7 @@
{
fs::path path;
- explicit RemovablePath(const fs::path& path) : path(path)
- {}
+ explicit RemovablePath(const fs::path& path) : path(path) {}
~RemovablePath()
{
if (!path.empty())
@@ -143,8 +142,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)
@@ -189,8 +188,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 =
@@ -209,8 +208,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
diff --git a/image_verify.cpp b/image_verify.cpp
index 2b20340..1c81abe 100644
--- a/image_verify.cpp
+++ b/image_verify.cpp
@@ -200,8 +200,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}",
@@ -301,7 +301,6 @@
const fs::path& publicKey,
const std::string& hashFunc)
{
-
// Check existence of the files in the system.
std::error_code ec;
if (!(fs::exists(file, ec) && fs::exists(sigFile, ec)))
@@ -402,7 +401,6 @@
CustomMap Signature::mapFile(const fs::path& path, size_t size)
{
-
CustomFd fd(open(path.c_str(), O_RDONLY));
return CustomMap(mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd(), 0),
diff --git a/image_verify.hpp b/image_verify.hpp
index 38129f9..97c1e2f 100644
--- a/image_verify.hpp
+++ b/image_verify.hpp
@@ -52,8 +52,7 @@
*
* @param[in] fd - File descriptor
*/
- explicit CustomFd(int fd) : fd(fd)
- {}
+ explicit CustomFd(int fd) : fd(fd) {}
~CustomFd()
{
@@ -98,8 +97,7 @@
* @param[in] addr - Starting address of the map
* @param[in] length - length of the map
*/
- CustomMap(void* addr, size_t length) : addr(addr), length(length)
- {}
+ CustomMap(void* addr, size_t length) : addr(addr), length(length) {}
~CustomMap()
{
diff --git a/item_updater.cpp b/item_updater.cpp
index 3ea954c..5613a49 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -41,7 +41,6 @@
void ItemUpdater::createActivation(sdbusplus::message_t& msg)
{
-
using SVersion = server::Version;
using VersionPurpose = SVersion::VersionPurpose;
using VersionClass = phosphor::software::manager::Version;
@@ -381,8 +380,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();
}
@@ -526,8 +525,8 @@
cmpPriority cmpPriorityFunc =
[](std::pair<std::string, uint8_t> priority1,
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(
@@ -609,8 +608,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)
{
diff --git a/msl_verify.cpp b/msl_verify.cpp
index fd1fccd..049ac9a 100644
--- a/msl_verify.cpp
+++ b/msl_verify.cpp
@@ -58,7 +58,6 @@
bool minimum_ship_level::verify(const std::string& versionManifest)
{
-
// If there is no msl or mslRegex return upgrade is needed.
std::string msl{BMC_MSL};
std::string mslRegex{REGEX_BMC_MSL};
diff --git a/side-switch/side_switch.cpp b/side-switch/side_switch.cpp
index 9eedae5..25f6fce 100644
--- a/side-switch/side_switch.cpp
+++ b/side-switch/side_switch.cpp
@@ -14,7 +14,6 @@
bool sideSwitchNeeded(sdbusplus::bus_t& bus)
{
-
std::string fwRunningVersionPath;
uint8_t fwRunningPriority = 0;
@@ -126,7 +125,6 @@
bool powerOffSystem(sdbusplus::bus_t& bus)
{
-
try
{
utils::PropertyValue chassOff =
diff --git a/sync_watch.cpp b/sync_watch.cpp
index ecf6cef..653a22d 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,
@@ -114,8 +114,8 @@
}
// fileMap<wd, path>
- auto rc =
- syncWatch->syncCallback(event->mask, syncWatch->fileMap[event->wd]);
+ auto rc = syncWatch->syncCallback(event->mask,
+ syncWatch->fileMap[event->wd]);
if (rc)
{
return rc;
diff --git a/ubi/flash.cpp b/ubi/flash.cpp
index b445a56..15c5492 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 ae00ea5..486577a 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/version.cpp b/version.cpp
index 847148e..b8b1247 100644
--- a/version.cpp
+++ b/version.cpp
@@ -104,7 +104,6 @@
std::string Version::getId(const std::string& version)
{
-
if (version.empty())
{
error("Version is empty.");
@@ -209,8 +208,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;
}
}