Add clang-format

Refer:https://github.com/openbmc/docs/blob/ac5d544553934f8083c61c5986a1420261bc8a4c/style/cpp/.clang-format

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Id0fcac058234d99d1a82673a217f30d58c616b2f
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..79a474d
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,116 @@
+---
+Language:        Cpp
+# BasedOnStyle:  LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Right
+AlignOperands:   true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: Yes
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterCaseLabel:  true
+  AfterClass:      true
+  AfterControlStatement: true
+  AfterEnum:       true
+  AfterFunction:   true
+  AfterNamespace:  true
+  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: false
+ColumnLimit:     80
+CommentPragmas:  '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DeriveLineEnding: false
+DerivePointerAlignment: false
+PointerAlignment: Left
+DisableFormat:   false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeBlocks: Regroup
+IncludeCategories:
+  - Regex:           '^[<"](gtest|gmock)'
+    Priority:        7
+  - Regex:           '^"config.h"'
+    Priority:        -1
+  - Regex:           '^".*\.h"'
+    Priority:        1
+  - Regex:           '^".*\.hpp"'
+    Priority:        2
+  - Regex:           '^<.*\.h>'
+    Priority:        3
+  - Regex:           '^<.*\.hpp>'
+    Priority:        4
+  - Regex:           '^<.*'
+    Priority:        5
+  - Regex:           '.*'
+    Priority:        6
+IndentCaseLabels: true
+IndentWidth:     4
+IndentWrappedFunctionNames: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+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
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Latest
+TabWidth:        4
+UseCRLF: false
+UseTab:          Never
+...
diff --git a/chassiskill.cpp b/chassiskill.cpp
index a051f90..ba694c9 100644
--- a/chassiskill.cpp
+++ b/chassiskill.cpp
@@ -1,11 +1,12 @@
 #include "utility.hpp"
 
+#include <nlohmann/json.hpp>
+#include <phosphor-logging/log.hpp>
+
 #include <algorithm>
 #include <cstring>
 #include <experimental/filesystem>
 #include <fstream>
-#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
 
 using json = nlohmann::json;
 using namespace phosphor::logging;
@@ -50,10 +51,10 @@
 
     for (const auto& gpio : gpios)
     {
-        auto gpioEntry = std::find_if(defs.begin(), defs.end(),
-                            [&gpio](const auto& g) {
-                                return g["name"] == gpio["name"];
-                            });
+        auto gpioEntry =
+            std::find_if(defs.begin(), defs.end(), [&gpio](const auto& g) {
+                return g["name"] == gpio["name"];
+            });
 
         if (gpioEntry != defs.end())
         {
diff --git a/utility.hpp b/utility.hpp
index 7e2eaff..007ad37 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -4,6 +4,7 @@
 #include <gpioplus/handle.hpp>
 #include <gpioplus/utility/aspeed.hpp>
 #include <phosphor-logging/log.hpp>
+
 #include <exception>
 #include <string>
 
@@ -25,23 +26,22 @@
     {
         gpioOffset = gpioplus::utility::aspeed::nameToOffset(gpioName);
     }
-    catch(const std::logic_error& e)
+    catch (const std::logic_error& e)
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(
-                            "Error in gpioplus - nameToOffset",
-                            phosphor::logging::entry("ERROR=%s", e.what()));
+            "Error in gpioplus - nameToOffset",
+            phosphor::logging::entry("ERROR=%s", e.what()));
         return false;
     }
 
     try
     {
-        //TODO: openbmc/phosphor-power-control#1 - Handle cases where gpiochip
-        //      could be non-zero.
+        // TODO: openbmc/phosphor-power-control#1 - Handle cases where gpiochip
+        //       could be non-zero.
         gpioplus::Chip chip(0);
         gpioplus::HandleFlags flags(chip.getLineInfo(gpioOffset).flags);
         flags.output = true;
-        gpioplus::Handle handle(chip, {{gpioOffset, 0}}, flags,
-                                "chassiskill");
+        gpioplus::Handle handle(chip, {{gpioOffset, 0}}, flags, "chassiskill");
 
         bool value = (asserted ^ activeLow);
         handle.setValues({value});
@@ -49,8 +49,8 @@
     catch (const std::exception& e)
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(
-                            "Error in gpioplus",
-                            phosphor::logging::entry("ERROR=%s", e.what()));
+            "Error in gpioplus",
+            phosphor::logging::entry("ERROR=%s", e.what()));
         return false;
     }