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: I3942bdbbb0fc2d46d755a74f481bb44fa63dc486
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index ea71ad6..d92a3f1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,22 +5,24 @@
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: false
-AlignOperands: true
-AlignTrailingComments: true
+AlignEscapedNewlines: Right
+AlignOperands: Align
+AlignTrailingComments:
+ Kind: Always
+ OverEmptyLines: 1
AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
+AllowShortFunctionsOnASingleLine: Empty
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,19 +31,28 @@
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
+ AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
+BreakAfterAttributes: Never
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
+BreakInheritanceList: AfterColon
+BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
+DeriveLineEnding: false
DerivePointerAlignment: false
PointerAlignment: Left
DisableFormat: false
@@ -51,21 +62,29 @@
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
+IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -73,18 +92,29 @@
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
+SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
@@ -92,7 +122,7 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
UseTab: Never
...
diff --git a/evdev.hpp b/evdev.hpp
index b5d1394..9efe14e 100644
--- a/evdev.hpp
+++ b/evdev.hpp
@@ -4,9 +4,10 @@
#include <libevdev/libevdev.h>
#include <systemd/sd-event.h>
+#include <sdbusplus/message.hpp>
+
#include <map>
#include <memory>
-#include <sdbusplus/message.hpp>
#include <string>
namespace phosphor
@@ -50,7 +51,6 @@
*/
class Evdev
{
-
using Property = std::string;
using Value = std::variant<bool, std::string>;
// Association between property and its value
diff --git a/gpio-util/gpio.cpp b/gpio-util/gpio.cpp
index c6b7704..0b671a8 100644
--- a/gpio-util/gpio.cpp
+++ b/gpio-util/gpio.cpp
@@ -18,9 +18,10 @@
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <cassert>
#include <phosphor-logging/log.hpp>
+#include <cassert>
+
namespace phosphor
{
namespace gpio
diff --git a/gpio-util/gpio.hpp b/gpio-util/gpio.hpp
index bcb036c..46b6fba 100644
--- a/gpio-util/gpio.hpp
+++ b/gpio-util/gpio.hpp
@@ -62,8 +62,7 @@
*/
GPIO(const std::string& device, gpioNum_t gpio, Direction direction) :
device(device), gpio(gpio), direction(direction)
- {
- }
+ {}
/**
* Sets the GPIO value
diff --git a/gpio-util/main.cpp b/gpio-util/main.cpp
index 82cbed4..27da697 100644
--- a/gpio-util/main.cpp
+++ b/gpio-util/main.cpp
@@ -26,11 +26,12 @@
#include "argument.hpp"
#include "gpio.hpp"
+#include <phosphor-logging/log.hpp>
+
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
-#include <phosphor-logging/log.hpp>
#include <thread>
using namespace phosphor::gpio;
diff --git a/gpioMon.cpp b/gpioMon.cpp
index fcdf8f5..0b5bbd9 100644
--- a/gpioMon.cpp
+++ b/gpioMon.cpp
@@ -36,18 +36,17 @@
void GpioMonitor::scheduleEventHandler()
{
-
gpioEventDescriptor.async_wait(
boost::asio::posix::stream_descriptor::wait_read,
[this](const boost::system::error_code& ec) {
- if (ec)
- {
- std::string msg = gpioLineMsg + "event handler error" +
- std::string(ec.message());
- log<level::ERR>(msg.c_str());
- return;
- }
- gpioEventHandler();
+ if (ec)
+ {
+ std::string msg = gpioLineMsg + "event handler error" +
+ std::string(ec.message());
+ log<level::ERR>(msg.c_str());
+ return;
+ }
+ gpioEventHandler();
});
}
@@ -125,7 +124,6 @@
int GpioMonitor::requestGPIOEvents()
{
-
/* Request an event to monitor for respected gpio line */
if (gpiod_line_request(gpioLine, &gpioConfig, 0) < 0)
{
diff --git a/gpioMon.hpp b/gpioMon.hpp
index 5750d39..a645e02 100644
--- a/gpioMon.hpp
+++ b/gpioMon.hpp
@@ -4,6 +4,7 @@
#include <boost/asio/io_context.hpp>
#include <boost/asio/posix/stream_descriptor.hpp>
+
#include <map>
#include <vector>
diff --git a/gpioMonMain.cpp b/gpioMonMain.cpp
index 8530ffc..83e14b6 100644
--- a/gpioMonMain.cpp
+++ b/gpioMonMain.cpp
@@ -18,10 +18,11 @@
#include <CLI/CLI.hpp>
#include <boost/asio/io_context.hpp>
-#include <fstream>
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
+#include <fstream>
+
using namespace phosphor::logging;
namespace phosphor
@@ -42,7 +43,6 @@
int main(int argc, char** argv)
{
-
boost::asio::io_context io;
CLI::App app{"Monitor GPIO line for requested state change"};
@@ -81,7 +81,6 @@
for (auto& obj : gpioMonObj)
{
-
/* GPIO Line message */
std::string lineMsg = "GPIO Line ";
diff --git a/mainapp.cpp b/mainapp.cpp
index 2663f8f..4816b84 100644
--- a/mainapp.cpp
+++ b/mainapp.cpp
@@ -19,8 +19,9 @@
#include <systemd/sd-event.h>
-#include <iostream>
#include <phosphor-logging/log.hpp>
+
+#include <iostream>
#include <string>
using namespace phosphor::logging;
diff --git a/monitor.cpp b/monitor.cpp
index e2e912a..2c8569e 100644
--- a/monitor.cpp
+++ b/monitor.cpp
@@ -47,8 +47,7 @@
{
// Data returned
struct input_event ev
- {
- };
+ {};
int rc = 0;
// While testing, observed that not having a loop here was leading
diff --git a/monitor.hpp b/monitor.hpp
index 771492a..7578d9d 100644
--- a/monitor.hpp
+++ b/monitor.hpp
@@ -7,6 +7,7 @@
#include <unistd.h>
#include <sdbusplus/bus.hpp>
+
#include <string>
namespace phosphor
diff --git a/presence/gpio_presence.cpp b/presence/gpio_presence.cpp
index e473fea..c6e26b5 100644
--- a/presence/gpio_presence.cpp
+++ b/presence/gpio_presence.cpp
@@ -5,11 +5,12 @@
#include <fcntl.h>
#include <libevdev/libevdev.h>
-#include <fstream>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
+#include <fstream>
+
namespace phosphor
{
namespace gpio
@@ -63,8 +64,8 @@
{
auto present = false;
auto value = static_cast<int>(0);
- auto fetch_rc =
- libevdev_fetch_event_value(devicePtr.get(), EV_KEY, key, &value);
+ auto fetch_rc = libevdev_fetch_event_value(devicePtr.get(), EV_KEY, key,
+ &value);
if (0 == fetch_rc)
{
log<level::ERR>("Device does not support event type",
@@ -92,11 +93,9 @@
// Analyzes the GPIO event
void Presence::analyzeEvent()
{
-
// Data returned
struct input_event ev
- {
- };
+ {};
int rc = 0;
// While testing, observed that not having a loop here was leading
diff --git a/presence/gpio_presence.hpp b/presence/gpio_presence.hpp
index 4b9b24c..b72e84e 100644
--- a/presence/gpio_presence.hpp
+++ b/presence/gpio_presence.hpp
@@ -3,9 +3,10 @@
#include <systemd/sd-event.h>
+#include <sdbusplus/bus.hpp>
+
#include <cstdlib>
#include <experimental/filesystem>
-#include <sdbusplus/bus.hpp>
#include <string>
namespace phosphor
@@ -29,7 +30,6 @@
*/
class Presence : public Evdev
{
-
using Property = std::string;
using Value = std::variant<bool, std::string>;
// Association between property and its value
diff --git a/presence/main.cpp b/presence/main.cpp
index eace07e..56ab8a1 100644
--- a/presence/main.cpp
+++ b/presence/main.cpp
@@ -3,9 +3,10 @@
#include <systemd/sd-event.h>
-#include <iostream>
#include <phosphor-logging/log.hpp>
+#include <iostream>
+
using namespace phosphor::logging;
using namespace phosphor::gpio;
using namespace phosphor::gpio::presence;