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: I39f8c77091744c8516e043054b4ed7207d85aa08
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index ddfe2d7..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
@@ -75,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
@@ -85,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
@@ -111,6 +124,6 @@
SpacesInSquareBrackets: false
Standard: Latest
TabWidth: 4
-UseCRLF: false
UseTab: Never
...
+
diff --git a/occ_command.cpp b/occ_command.cpp
index 1620156..6d0851e 100644
--- a/occ_command.cpp
+++ b/occ_command.cpp
@@ -210,8 +210,8 @@
// Validate checksum (last 2 bytes of response)
const unsigned int csumIndex = response.size() - 2;
- const uint32_t rspChecksum =
- (response[csumIndex] << 8) + response[csumIndex + 1];
+ const uint32_t rspChecksum = (response[csumIndex] << 8) +
+ response[csumIndex + 1];
uint32_t calcChecksum = 0;
for (unsigned int index = 0; index < csumIndex; ++index)
{
diff --git a/occ_dbus.cpp b/occ_dbus.cpp
index 6bc1a46..811f1ab 100644
--- a/occ_dbus.cpp
+++ b/occ_dbus.cpp
@@ -242,8 +242,8 @@
void OccDBusSensors::setDvfsTemp(const std::string& path, double value)
{
- dvfsTemps[path] =
- std::make_unique<SensorIntf>(utils::getBus(), path.c_str());
+ dvfsTemps[path] = std::make_unique<SensorIntf>(utils::getBus(),
+ path.c_str());
dvfsTemps[path]->value(value);
}
diff --git a/occ_dbus.hpp b/occ_dbus.hpp
index 90fc498..f20ffc3 100644
--- a/occ_dbus.hpp
+++ b/occ_dbus.hpp
@@ -30,8 +30,7 @@
class OccDBusSensors
{
private:
- OccDBusSensors()
- {}
+ OccDBusSensors() {}
public:
OccDBusSensors(const OccDBusSensors&) = delete;
diff --git a/occ_errors.hpp b/occ_errors.hpp
index ba4610e..9a59b08 100644
--- a/occ_errors.hpp
+++ b/occ_errors.hpp
@@ -64,8 +64,7 @@
Descriptor(Descriptor&&) = default;
Descriptor& operator=(Descriptor&&) = default;
- Descriptor() : log(false), err(0), callout(nullptr), path(nullptr)
- {}
+ Descriptor() : log(false), err(0), callout(nullptr), path(nullptr) {}
/** @brief Constructs the Descriptor object
*
diff --git a/occ_ffdc.cpp b/occ_ffdc.cpp
index f83f74a..1119a9d 100644
--- a/occ_ffdc.cpp
+++ b/occ_ffdc.cpp
@@ -56,8 +56,8 @@
}
// Add journal traces to PEL FFDC
- auto occJournalFile =
- addJournalEntries(pelFFDCInfo, "openpower-occ-control", 25);
+ auto occJournalFile = addJournalEntries(pelFFDCInfo,
+ "openpower-occ-control", 25);
std::map<std::string, std::string> additionalData;
additionalData.emplace("SRC6", std::to_string(src6));
@@ -68,11 +68,11 @@
try
{
- std::string service =
- utils::getService(loggingObjectPath, opLoggingInterface);
- auto method =
- bus.new_method_call(service.c_str(), loggingObjectPath,
- opLoggingInterface, "CreatePELWithFFDCFiles");
+ std::string service = utils::getService(loggingObjectPath,
+ opLoggingInterface);
+ auto method = bus.new_method_call(service.c_str(), loggingObjectPath,
+ opLoggingInterface,
+ "CreatePELWithFFDCFiles");
// Set level to Notice (Informational). Error should trigger an OCC
// reset and if it does not recover, HTMGT/HBRT will create an
@@ -127,14 +127,14 @@
{
FFDCFiles ffdc;
// Add journal traces to PEL FFDC
- auto occJournalFile =
- addJournalEntries(ffdc, "openpower-occ-control", 25);
+ auto occJournalFile = addJournalEntries(ffdc, "openpower-occ-control",
+ 25);
- std::string service =
- utils::getService(loggingObjectPath, opLoggingInterface);
- auto method =
- bus.new_method_call(service.c_str(), loggingObjectPath,
- opLoggingInterface, "CreatePELWithFFDCFiles");
+ std::string service = utils::getService(loggingObjectPath,
+ opLoggingInterface);
+ auto method = bus.new_method_call(service.c_str(), loggingObjectPath,
+ opLoggingInterface,
+ "CreatePELWithFFDCFiles");
// Set level to Notice (Informational). Error should trigger an OCC
// reset and if it does not recover, HTMGT/HBRT will create an
@@ -194,8 +194,8 @@
if (total > sbe_status_header_size)
{
- std::string templateString =
- fs::temp_directory_path() / "OCC_FFDC_XXXXXX";
+ std::string templateString = fs::temp_directory_path() /
+ "OCC_FFDC_XXXXXX";
tfd = mkostemp(templateString.data(), O_RDWR);
if (tfd < 0)
{
diff --git a/occ_ffdc.hpp b/occ_ffdc.hpp
index 61bd714..143669a 100644
--- a/occ_ffdc.hpp
+++ b/occ_ffdc.hpp
@@ -217,8 +217,7 @@
JournalCloser& operator=(const JournalCloser&) = delete;
JournalCloser& operator=(JournalCloser&&) = delete;
- JournalCloser(sd_journal* journal) : journal{journal}
- {}
+ JournalCloser(sd_journal* journal) : journal{journal} {}
~JournalCloser()
{
diff --git a/occ_manager.cpp b/occ_manager.cpp
index 0fb5f1d..4833d5a 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -459,8 +459,8 @@
{
auto obj = std::find_if(statusObjects.begin(), statusObjects.end(),
[instance](const auto& obj) {
- return instance == obj->getOccInstanceID();
- });
+ return instance == obj->getOccInstanceID();
+ });
if (obj != statusObjects.end() && (*obj)->occActive())
{
@@ -478,8 +478,8 @@
{
auto obj = std::find_if(statusObjects.begin(), statusObjects.end(),
[instance](const auto& obj) {
- return instance == obj->getOccInstanceID();
- });
+ return instance == obj->getOccInstanceID();
+ });
const bool hostRunning = open_power::occ::utils::isHostRunning();
if (obj != statusObjects.end())
@@ -590,8 +590,8 @@
constexpr auto function = "CreateDump";
std::string service = utils::getService(path, interface);
- auto method =
- bus.new_method_call(service.c_str(), path, interface, function);
+ auto method = bus.new_method_call(service.c_str(), path, interface,
+ function);
std::map<std::string, std::variant<std::string, uint64_t>>
createParams{
@@ -792,8 +792,8 @@
continue;
}
- std::string sensorPath =
- OCC_SENSORS_ROOT + std::string("/temperature/");
+ std::string sensorPath = OCC_SENSORS_ROOT +
+ std::string("/temperature/");
std::string dvfsTempPath;
diff --git a/occ_status.cpp b/occ_status.cpp
index ceaf6fb..85b70ee 100644
--- a/occ_status.cpp
+++ b/occ_status.cpp
@@ -352,9 +352,9 @@
}
// Build the base HWMON path
- fs::path prefixPath =
- fs::path{OCC_HWMON_PATH + "occ-hwmon."s +
- std::to_string(instance + 1) + "/hwmon/"s};
+ fs::path prefixPath = fs::path{OCC_HWMON_PATH + "occ-hwmon."s +
+ std::to_string(instance + 1) +
+ "/hwmon/"s};
// Get the hwmonXX directory name
try
diff --git a/pldm.cpp b/pldm.cpp
index 1bcf7a1..652e214 100644
--- a/pldm.cpp
+++ b/pldm.cpp
@@ -122,7 +122,7 @@
}
open_power::occ::instanceID count = start;
- for (auto const& pair : entityInstMap)
+ for (const auto& pair : entityInstMap)
{
sensorInstanceMap.emplace(pair.second, count);
count++;
@@ -369,7 +369,7 @@
}
open_power::occ::instanceID position = start;
- for (auto const& pair : entityInstMap)
+ for (const auto& pair : entityInstMap)
{
instanceToEffecterMap.emplace(position, pair.second);
position++;
@@ -579,8 +579,8 @@
pldmResponseReceived = false;
pldmResponseTimeout = false;
pldmResponseOcc = instance;
- auto pldmRc =
- pldm_send(mctpEid, pldmFd, request.data(), request.size());
+ auto pldmRc = pldm_send(mctpEid, pldmFd, request.data(),
+ request.size());
auto sendErrno = errno;
if (pldmRc != PLDM_REQUESTER_SUCCESS)
{
@@ -827,8 +827,8 @@
}
bitfield8_t sRearm = {0};
- const size_t msgSize =
- sizeof(pldm_msg_hdr) + PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES;
+ const size_t msgSize = sizeof(pldm_msg_hdr) +
+ PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES;
std::vector<uint8_t> request(msgSize);
auto msg = reinterpret_cast<pldm_msg*>(request.data());
diff --git a/powercap.cpp b/powercap.cpp
index 6a9c67f..edfae9c 100644
--- a/powercap.cpp
+++ b/powercap.cpp
@@ -464,8 +464,8 @@
try
{
- prop =
- utils::getProperty(PCAP_PATH, PCAP_INTERFACE, POWER_CAP_SOFT_MIN);
+ prop = utils::getProperty(PCAP_PATH, PCAP_INTERFACE,
+ POWER_CAP_SOFT_MIN);
softMin = std::get<uint32_t>(prop);
}
catch (const sdbusplus::exception_t& e)
@@ -480,8 +480,8 @@
try
{
- prop =
- utils::getProperty(PCAP_PATH, PCAP_INTERFACE, POWER_CAP_HARD_MIN);
+ prop = utils::getProperty(PCAP_PATH, PCAP_INTERFACE,
+ POWER_CAP_HARD_MIN);
hardMin = std::get<uint32_t>(prop);
}
catch (const sdbusplus::exception_t& e)
diff --git a/powermode.cpp b/powermode.cpp
index 14c3840..e367afc 100644
--- a/powermode.cpp
+++ b/powermode.cpp
@@ -684,7 +684,6 @@
// Loads the OEM mode data in the filesystem using cereal.
void OccPersistData::load()
{
-
std::filesystem::path ipath =
std::filesystem::path{OCC_CONTROL_PERSIST_PATH} / powerModeFilename;
@@ -751,9 +750,9 @@
std::string path = "/";
std::string service =
utils::getServiceUsingSubTree(PMODE_DEFAULT_INTERFACE, path);
- auto method =
- bus.new_method_call(service.c_str(), path.c_str(),
- "org.freedesktop.DBus.Properties", "Get");
+ auto method = bus.new_method_call(service.c_str(), path.c_str(),
+ "org.freedesktop.DBus.Properties",
+ "Get");
method.append(PMODE_DEFAULT_INTERFACE, "PowerMode");
auto reply = bus.call(method);
@@ -761,8 +760,8 @@
reply.read(stateEntryValue);
auto propVal = std::get<std::string>(stateEntryValue);
- const std::string fullModeString =
- PMODE_INTERFACE + ".PowerMode."s + propVal;
+ const std::string fullModeString = PMODE_INTERFACE + ".PowerMode."s +
+ propVal;
defaultMode = powermode::convertStringToMode(fullModeString);
if (!VALID_POWER_MODE_SETTING(defaultMode))
{
@@ -809,9 +808,9 @@
std::string path = "/";
std::string service =
utils::getServiceUsingSubTree(PMODE_DEFAULT_INTERFACE, path);
- auto method =
- bus.new_method_call(service.c_str(), path.c_str(),
- "org.freedesktop.DBus.Properties", "GetAll");
+ auto method = bus.new_method_call(service.c_str(), path.c_str(),
+ "org.freedesktop.DBus.Properties",
+ "GetAll");
method.append(PMODE_DEFAULT_INTERFACE);
auto reply = bus.call(method);
reply.read(ipsProperties);
diff --git a/test/occ_dbus_test.cpp b/test/occ_dbus_test.cpp
index d11a373..58843c7 100644
--- a/test/occ_dbus_test.cpp
+++ b/test/occ_dbus_test.cpp
@@ -71,4 +71,4 @@
EXPECT_EQ(true, retStatus);
ASSERT_THROW(OccDBusSensors::getOccDBus().getOperationalStatus("/abcd/"),
std::invalid_argument);
-}
\ No newline at end of file
+}
diff --git a/test/utest.cpp b/test/utest.cpp
index 05c8f71..cf3401a 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -21,8 +21,7 @@
EXPECT_GE(rc, 0);
event = nullptr;
}
- ~VerifyOccInput()
- {}
+ ~VerifyOccInput() {}
sd_event* event;
int rc;
diff --git a/utils.cpp b/utils.cpp
index 9c60443..97e33dd 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -29,7 +29,6 @@
const std::string getService(const std::string& path,
const std::string& interface)
{
-
using InterfaceList = std::vector<std::string>;
std::map<std::string, std::vector<std::string>> mapperResponse;
@@ -200,9 +199,9 @@
throw std::runtime_error("getStateValue: Failed to get service");
}
- auto method =
- bus.new_method_call(service.c_str(), objPath.c_str(),
- "org.freedesktop.DBus.Properties", "Get");
+ auto method = bus.new_method_call(service.c_str(), objPath.c_str(),
+ "org.freedesktop.DBus.Properties",
+ "Get");
method.append(intf, state);