clang-format: update to latest version
Pick up latest .clang-format file from the docs repository.
Fix formatting on all files.
Minor compile fixes due to GCC10 and sdbusplus changes.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie1f7a4e59b6cf015310effef50d558ff59731024
diff --git a/.clang-format b/.clang-format
index ea71ad6..52ac0a1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,7 +5,7 @@
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: false
+AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
@@ -14,13 +14,13 @@
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
-AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: true
+AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
+ AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
@@ -29,15 +29,22 @@
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
+ AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
+BreakInheritanceList: AfterColon
+BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
@@ -51,17 +58,21 @@
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^[<"](gtest|gmock)'
- Priority: 5
+ Priority: 7
- Regex: '^"config.h"'
Priority: -1
- - Regex: '^".*\.hpp"'
+ - Regex: '^".*\.h"'
Priority: 1
- - Regex: '^<.*\.h>'
+ - Regex: '^".*\.hpp"'
Priority: 2
- - Regex: '^<.*'
+ - Regex: '^<.*\.h>'
Priority: 3
- - Regex: '.*'
+ - Regex: '^<.*\.hpp>'
Priority: 4
+ - Regex: '^<.*'
+ Priority: 5
+ - Regex: '.*'
+ Priority: 6
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
@@ -83,8 +94,13 @@
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
@@ -92,7 +108,7 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
UseTab: Never
...
diff --git a/device.hpp b/device.hpp
index 2513506..16056a7 100644
--- a/device.hpp
+++ b/device.hpp
@@ -31,8 +31,7 @@
* @param inst - the device instance
*/
Device(const std::string& name, size_t inst) : name(name), instance(inst)
- {
- }
+ {}
/**
* Returns the instance number
@@ -61,8 +60,7 @@
* is required
*/
virtual void onFailure()
- {
- }
+ {}
/**
* Pure virtual function to clear faults on the device
diff --git a/device_monitor.hpp b/device_monitor.hpp
index 2d55af3..658d22e 100644
--- a/device_monitor.hpp
+++ b/device_monitor.hpp
@@ -43,8 +43,7 @@
std::chrono::milliseconds i) :
device(std::move(d)),
timer(e, std::bind(&DeviceMonitor::analyze, this), i)
- {
- }
+ {}
/**
* Starts the timer to monitor the device on an interval.
diff --git a/elog-errors.hpp b/elog-errors.hpp
index 44bc5eb..9b0d9af 100644
--- a/elog-errors.hpp
+++ b/elog-errors.hpp
@@ -5,6 +5,7 @@
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/exception.hpp>
+
#include <string>
#include <tuple>
#include <type_traits>
@@ -1032,9 +1033,7 @@
namespace Fault
{
namespace _Shutdown
-{
-
-} // namespace _Shutdown
+{} // namespace _Shutdown
struct Shutdown
{
@@ -1068,9 +1067,7 @@
namespace Fault
{
namespace _PowerOnFailure
-{
-
-} // namespace _PowerOnFailure
+{} // namespace _PowerOnFailure
struct PowerOnFailure
{
diff --git a/file.hpp b/file.hpp
index d762012..e23c3ce 100644
--- a/file.hpp
+++ b/file.hpp
@@ -28,8 +28,7 @@
* @param[in] fd - File descriptor
*/
FileDescriptor(int fd) : fd(fd)
- {
- }
+ {}
~FileDescriptor()
{
diff --git a/gpio.cpp b/gpio.cpp
index 2dad86d..3365c98 100644
--- a/gpio.cpp
+++ b/gpio.cpp
@@ -18,12 +18,13 @@
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <cassert>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <cassert>
+
namespace witherspoon
{
namespace gpio
diff --git a/gpio.hpp b/gpio.hpp
index 2742d4f..9fa8e63 100644
--- a/gpio.hpp
+++ b/gpio.hpp
@@ -62,8 +62,7 @@
*/
GPIO(const std::string& device, gpioNum_t gpio, Direction direction) :
device(device), gpio(gpio), direction(direction)
- {
- }
+ {}
/**
* Reads the GPIO value
diff --git a/pmbus.cpp b/pmbus.cpp
index f755e99..aca2d49 100644
--- a/pmbus.cpp
+++ b/pmbus.cpp
@@ -15,13 +15,14 @@
*/
#include "pmbus.hpp"
-#include <filesystem>
-#include <fstream>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
#include <xyz/openbmc_project/Common/Device/error.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <filesystem>
+#include <fstream>
+
namespace witherspoon
{
namespace pmbus
diff --git a/power-sequencer/main.cpp b/power-sequencer/main.cpp
index 3e1ca52..7e9d47e 100644
--- a/power-sequencer/main.cpp
+++ b/power-sequencer/main.cpp
@@ -18,11 +18,12 @@
#include "runtime_monitor.hpp"
#include "ucd90160.hpp"
-#include <chrono>
-#include <iostream>
#include <phosphor-logging/log.hpp>
#include <sdeventplus/event.hpp>
+#include <chrono>
+#include <iostream>
+
using namespace witherspoon::power;
using namespace phosphor::logging;
diff --git a/power-sequencer/pgood_monitor.hpp b/power-sequencer/pgood_monitor.hpp
index 7dbabf9..70a6f89 100644
--- a/power-sequencer/pgood_monitor.hpp
+++ b/power-sequencer/pgood_monitor.hpp
@@ -47,8 +47,7 @@
std::chrono::milliseconds& t) :
DeviceMonitor(std::move(d), e, t),
bus(b)
- {
- }
+ {}
/**
* Analyzes the power sequencer for fails and then
diff --git a/power-sequencer/runtime_monitor.hpp b/power-sequencer/runtime_monitor.hpp
index 934aef1..93e398f 100644
--- a/power-sequencer/runtime_monitor.hpp
+++ b/power-sequencer/runtime_monitor.hpp
@@ -55,8 +55,7 @@
bus(b), match(bus, getMatchString(),
std::bind(std::mem_fn(&RuntimeMonitor::onPowerLost), this,
std::placeholders::_1))
- {
- }
+ {}
/**
* Clears faults and then runs DeviceMonitor::run to
diff --git a/power-sequencer/templates/ucd90160_defs.mako.cpp b/power-sequencer/templates/ucd90160_defs.mako.cpp
index 1775158..069e5f0 100644
--- a/power-sequencer/templates/ucd90160_defs.mako.cpp
+++ b/power-sequencer/templates/ucd90160_defs.mako.cpp
@@ -10,7 +10,8 @@
using namespace ucd90160;
using namespace std::string_literals;
-const DeviceMap UCD90160::deviceMap{
+const DeviceMap UCD90160::deviceMap
+{
%for ucd_data in ucd90160s:
{${ucd_data['index']},
DeviceDefinition{
@@ -38,7 +39,7 @@
"${gpio_analysis['path']}",
gpio::Value::${gpio_analysis['gpio_value']},
[](auto& ucd, const auto& callout) {
- ucd.${gpio_analysis['error_function']}(callout);
+ ucd.${gpio_analysis['error_function']}(callout);
},
optionFlags::${gpio_analysis['option_flags']},
GPIODefinitions{
diff --git a/power-sequencer/ucd90160.cpp b/power-sequencer/ucd90160.cpp
index d0d176c..c060ebe 100644
--- a/power-sequencer/ucd90160.cpp
+++ b/power-sequencer/ucd90160.cpp
@@ -19,13 +19,14 @@
#include "utility.hpp"
#include <elog-errors.hpp>
-#include <map>
-#include <memory>
#include <org/open_power/Witherspoon/Fault/error.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/Device/error.hpp>
+#include <map>
+#include <memory>
+
namespace witherspoon
{
namespace power
@@ -54,8 +55,7 @@
interface(std::get<ucd90160::pathField>(deviceMap.find(instance)->second),
DRIVER_NAME, instance),
gpioDevice(findGPIODevice(interface.path())), bus(bus)
-{
-}
+{}
void UCD90160::onFailure()
{
diff --git a/power-sequencer/ucd90160.hpp b/power-sequencer/ucd90160.hpp
index 3169de6..b66bb82 100644
--- a/power-sequencer/ucd90160.hpp
+++ b/power-sequencer/ucd90160.hpp
@@ -5,10 +5,11 @@
#include "pmbus.hpp"
#include "types.hpp"
+#include <sdbusplus/bus.hpp>
+
#include <algorithm>
#include <filesystem>
#include <map>
-#include <sdbusplus/bus.hpp>
#include <vector>
namespace witherspoon
@@ -60,8 +61,7 @@
* Clears faults in the device
*/
void clearFaults() override
- {
- }
+ {}
private:
/**
diff --git a/power-supply/average.hpp b/power-supply/average.hpp
index a61a436..cf54a7d 100644
--- a/power-supply/average.hpp
+++ b/power-supply/average.hpp
@@ -1,7 +1,8 @@
#pragma once
-#include <functional>
#include <org/open_power/Sensor/Aggregation/History/Average/server.hpp>
+#include <functional>
+
namespace witherspoon
{
namespace power
diff --git a/power-supply/main.cpp b/power-supply/main.cpp
index 93b4b77..7c5fcad 100644
--- a/power-supply/main.cpp
+++ b/power-supply/main.cpp
@@ -19,10 +19,11 @@
#include "device_monitor.hpp"
#include "power_supply.hpp"
-#include <iostream>
#include <phosphor-logging/log.hpp>
#include <sdeventplus/event.hpp>
+#include <iostream>
+
using namespace witherspoon::power;
using namespace phosphor::logging;
diff --git a/power-supply/maximum.hpp b/power-supply/maximum.hpp
index d952d2b..d48f60f 100644
--- a/power-supply/maximum.hpp
+++ b/power-supply/maximum.hpp
@@ -1,7 +1,8 @@
#pragma once
-#include <functional>
#include <org/open_power/Sensor/Aggregation/History/Maximum/server.hpp>
+#include <functional>
+
namespace witherspoon
{
namespace power
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index d2d3e9c..d936d28 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -21,13 +21,14 @@
#include "pmbus.hpp"
#include "utility.hpp"
-#include <functional>
#include <org/open_power/Witherspoon/Fault/error.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/Device/error.hpp>
#include <xyz/openbmc_project/Software/Version/server.hpp>
+#include <functional>
+
namespace witherspoon
{
namespace power
@@ -664,36 +665,32 @@
sn = pmbusIntf.readString(SERIAL_NUMBER, Type::HwmonDeviceDebug);
}
catch (ReadFailure& e)
- {
- }
+ {}
try
{
pn = pmbusIntf.readString(PART_NUMBER, Type::HwmonDeviceDebug);
}
catch (ReadFailure& e)
- {
- }
+ {}
try
{
ccin = pmbusIntf.readString(CCIN, Type::HwmonDeviceDebug);
}
catch (ReadFailure& e)
- {
- }
+ {}
try
{
version = pmbusIntf.readString(FW_VERSION, Type::HwmonDeviceDebug);
}
catch (ReadFailure& e)
- {
- }
+ {}
}
// Build the object map and send it to the inventory
- using Properties = std::map<std::string, variant<std::string>>;
+ using Properties = std::map<std::string, std::variant<std::string>>;
using Interfaces = std::map<std::string, Properties>;
using Object = std::map<object_path, Interfaces>;
Properties assetProps;
diff --git a/power-supply/record_manager.cpp b/power-supply/record_manager.cpp
index b585ba0..336d0c5 100644
--- a/power-supply/record_manager.cpp
+++ b/power-supply/record_manager.cpp
@@ -17,9 +17,10 @@
#include <math.h>
-#include <chrono>
#include <phosphor-logging/log.hpp>
+#include <chrono>
+
namespace witherspoon
{
namespace power
diff --git a/power-supply/record_manager.hpp b/power-supply/record_manager.hpp
index 7ebcc3f..98382c7 100644
--- a/power-supply/record_manager.hpp
+++ b/power-supply/record_manager.hpp
@@ -1,6 +1,8 @@
#pragma once
+#include <cstdint>
#include <deque>
+#include <stdexcept>
#include <tuple>
#include <vector>
@@ -27,8 +29,7 @@
{
public:
InvalidRecordException() : std::runtime_error("Invalid history record")
- {
- }
+ {}
};
/**
@@ -70,8 +71,7 @@
* records to keep at a time
*/
RecordManager(size_t maxRec) : RecordManager(maxRec, LAST_SEQUENCE_ID)
- {
- }
+ {}
/**
* @brief Constructor
@@ -83,8 +83,7 @@
*/
RecordManager(size_t maxRec, size_t lastSequenceID) :
maxRecords(maxRec), lastSequenceID(lastSequenceID)
- {
- }
+ {}
/**
* @brief Adds a new entry to the history
diff --git a/utility.hpp b/utility.hpp
index 13c6e36..e2487f6 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -3,6 +3,7 @@
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
+
#include <string>
namespace witherspoon