add clang-format to repo
Add clang-format to repo.
Change-Id: Ic856886375af1b92648932e7b7239272307d38f3
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..ea71ad6
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,99 @@
+---
+Language: Cpp
+# BasedOnStyle: LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: false
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterObjCDeclaration: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: AfterColon
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+PointerAlignment: Left
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeBlocks: Regroup
+IncludeCategories:
+ - Regex: '^[<"](gtest|gmock)'
+ Priority: 5
+ - Regex: '^"config.h"'
+ Priority: -1
+ - Regex: '^".*\.hpp"'
+ Priority: 1
+ - Regex: '^<.*\.h>'
+ Priority: 2
+ - Regex: '^<.*'
+ Priority: 3
+ - Regex: '.*'
+ Priority: 4
+IndentCaseLabels: true
+IndentWidth: 4
+IndentWrappedFunctionNames: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+ReflowComments: true
+SortIncludes: true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp11
+TabWidth: 4
+UseTab: Never
+...
+
diff --git a/gpio/inc/gpio.hpp b/gpio/inc/gpio.hpp
index 0c29381..876b5ce 100644
--- a/gpio/inc/gpio.hpp
+++ b/gpio/inc/gpio.hpp
@@ -15,5 +15,8 @@
*/
#pragma once
-int configGpio(const char *gpioName, int *fd, sdbusplus::bus::bus &bus);
-int closeGpio(int fd);
\ No newline at end of file
+
+#include <sdbusplus/bus.hpp>
+
+int configGpio(const char* gpioName, int* fd, sdbusplus::bus::bus& bus);
+int closeGpio(int fd);
diff --git a/gpio/src/gpio.cpp b/gpio/src/gpio.cpp
index de669eb..d31782f 100644
--- a/gpio/src/gpio.cpp
+++ b/gpio/src/gpio.cpp
@@ -14,17 +14,19 @@
// limitations under the License.
*/
-#include <experimental/filesystem>
-#include <fcntl.h>
-#include <fstream>
-#include <phosphor-logging/elog-errors.hpp>
-#include <unistd.h>
-#include <xyz/openbmc_project/Common/error.hpp>
#include "gpio.hpp"
-const static constexpr char *SYSMGR_SERVICE = "org.openbmc.managers.System";
-const static constexpr char *SYSMGR_OBJ_PATH = "/org/openbmc/managers/System";
-const static constexpr char *SYSMGR_INTERFACE = "org.openbmc.managers.System";
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <experimental/filesystem>
+#include <fstream>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
+const static constexpr char* SYSMGR_SERVICE = "org.openbmc.managers.System";
+const static constexpr char* SYSMGR_OBJ_PATH = "/org/openbmc/managers/System";
+const static constexpr char* SYSMGR_INTERFACE = "org.openbmc.managers.System";
int closeGpio(int fd)
{
@@ -35,7 +37,7 @@
return 0;
}
-int configGpio(const char *gpioName, int *fd, sdbusplus::bus::bus &bus)
+int configGpio(const char* gpioName, int* fd, sdbusplus::bus::bus& bus)
{
sdbusplus::message::message method = bus.new_method_call(
SYSMGR_SERVICE, SYSMGR_OBJ_PATH, SYSMGR_INTERFACE, "gpioInit");
@@ -124,7 +126,7 @@
stream >> currentValue;
stream.close();
- const char *direction = currentValue ? "high" : "low";
+ const char* direction = currentValue ? "high" : "low";
devPath = gpioDev + "/gpio" + std::to_string(gpioNum) + "/direction";
diff --git a/power-control/inc/power_control.hpp b/power-control/inc/power_control.hpp
index 4983fb7..6918f08 100644
--- a/power-control/inc/power_control.hpp
+++ b/power-control/inc/power_control.hpp
@@ -15,14 +15,16 @@
*/
#pragma once
+#include "gpio.hpp"
+
#include <fcntl.h>
#include <linux/aspeed-lpc-sio.h>
#include <unistd.h>
+
#include <phosphor-logging/elog-errors.hpp>
#include <xyz/openbmc_project/Chassis/Common/error.hpp>
#include <xyz/openbmc_project/Chassis/Control/Power/server.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
-#include "gpio.hpp"
static constexpr size_t POLLING_INTERVAL_MS = 500;
diff --git a/power-control/src/power_control.cpp b/power-control/src/power_control.cpp
index 74b64b8..df92108 100644
--- a/power-control/src/power_control.cpp
+++ b/power-control/src/power_control.cpp
@@ -31,12 +31,11 @@
phosphor::logging::entry("NEWSTATE=%d", newState));
return 0;
}
-
+
ret = ::lseek(power_up_fd, 0, SEEK_SET);
if (ret < 0)
{
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "lseek error!");
+ phosphor::logging::log<phosphor::logging::level::ERR>("lseek error!");
throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
IOError();
}
@@ -54,20 +53,20 @@
if (ret < 0)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
- "write error for setting 0 !");
+ "write error for setting 0 !");
throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
IOError();
}
std::this_thread::sleep_for(
- std::chrono::milliseconds(POWER_UP_PIN_PULSE_TIME_MS));
+ std::chrono::milliseconds(POWER_UP_PIN_PULSE_TIME_MS));
buf = '1';
ret = ::write(power_up_fd, &buf, sizeof(buf));
if (ret < 0)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
- "write error for setting 1 !");
+ "write error for setting 1 !");
throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
IOError();
}