update clang-format

use openbmc standard clang-format

Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
Change-Id: Ia4bcacb680b6652f0e0a762981639a5ecd924b3e
diff --git a/.clang-format b/.clang-format
index dd27708..ef6f54e 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: false
+AlwaysBreakTemplateDeclarations: Yes
 BinPackArguments: true
 BinPackParameters: true
 BraceWrapping:
+  AfterCaseLabel:  true
   AfterClass:      true
   AfterControlStatement: true
   AfterEnum:       true
@@ -29,20 +29,27 @@
   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
 Cpp11BracedListStyle: true
-DerivePointerAlignment: true
+DerivePointerAlignment: false
 PointerAlignment: Left
 DisableFormat:   false
 ExperimentalAutoDetectBinPacking: false
@@ -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
@@ -79,12 +90,17 @@
 PenaltyBreakString: 1000
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
-PointerAlignment: Right
 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
@@ -96,3 +112,4 @@
 TabWidth:        4
 UseTab:          Never
 ...
+
diff --git a/include/pulse_event_monitor.hpp b/include/pulse_event_monitor.hpp
index 15d2531..bdd1ee4 100644
--- a/include/pulse_event_monitor.hpp
+++ b/include/pulse_event_monitor.hpp
@@ -22,7 +22,7 @@
 inline static sdbusplus::bus::match::match
     startPulseEventMonitor(std::shared_ptr<sdbusplus::asio::connection> conn)
 {
-    auto pulseEventMatcherCallback = [](sdbusplus::message::message &msg) {
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
         std::string thresholdInterface;
         boost::container::flat_map<std::string, std::variant<std::string>>
             propertiesChanged;
@@ -68,7 +68,7 @@
     };
 
     sdbusplus::bus::match::match pulseEventMatcher(
-        static_cast<sdbusplus::bus::bus &>(*conn),
+        static_cast<sdbusplus::bus::bus&>(*conn),
         "type='signal',interface='org.freedesktop.DBus.Properties',member='"
         "PropertiesChanged',arg0namespace='xyz.openbmc_project.State.Host'",
         std::move(pulseEventMatcherCallback));
diff --git a/include/sel_logger.hpp b/include/sel_logger.hpp
index bd40dff..58c7cc6 100644
--- a/include/sel_logger.hpp
+++ b/include/sel_logger.hpp
@@ -17,14 +17,14 @@
 #pragma once
 #include <filesystem>
 
-static constexpr char const *ipmiSelObject = "xyz.openbmc_project.Logging.IPMI";
-static constexpr char const *ipmiSelPath = "/xyz/openbmc_project/Logging/IPMI";
-static constexpr char const *ipmiSelAddInterface =
+static constexpr char const* ipmiSelObject = "xyz.openbmc_project.Logging.IPMI";
+static constexpr char const* ipmiSelPath = "/xyz/openbmc_project/Logging/IPMI";
+static constexpr char const* ipmiSelAddInterface =
     "xyz.openbmc_project.Logging.IPMI";
 
 // ID string generated using journalctl to include in the MESSAGE_ID field for
 // SEL entries.  Helps with filtering SEL entries in the journal.
-static constexpr char const *selMessageId = "b370836ccf2f4850ac5bee185b77893a";
+static constexpr char const* selMessageId = "b370836ccf2f4850ac5bee185b77893a";
 static constexpr int selPriority = 5; // notice
 static constexpr uint8_t selSystemType = 0x02;
 static constexpr uint16_t selBMCGenID = 0x0020;
@@ -38,6 +38,6 @@
 
 template <typename... T>
 static uint16_t
-    selAddSystemRecord(const std::string &message, const std::string &path,
-                       const std::vector<uint8_t> &selData, const bool &assert,
-                       const uint16_t &genId, T &&... metadata);
+    selAddSystemRecord(const std::string& message, const std::string& path,
+                       const std::vector<uint8_t>& selData, const bool& assert,
+                       const uint16_t& genId, T&&... metadata);
diff --git a/include/sensorutils.hpp b/include/sensorutils.hpp
index ce5d775..16eb8ce 100644
--- a/include/sensorutils.hpp
+++ b/include/sensorutils.hpp
@@ -15,9 +15,10 @@
 */
 
 #pragma once
+#include <phosphor-logging/log.hpp>
+
 #include <cmath>
 #include <iostream>
-#include <phosphor-logging/log.hpp>
 
 namespace ipmi
 {
@@ -27,7 +28,8 @@
  */
 struct VariantToDoubleVisitor
 {
-    template <typename T> double operator()(const T& t) const
+    template <typename T>
+    double operator()(const T& t) const
     {
         static_assert(std::is_arithmetic_v<T>,
                       "Cannot translate type to double");
diff --git a/include/threshold_event_monitor.hpp b/include/threshold_event_monitor.hpp
index b1f2eed..da63e0d 100644
--- a/include/threshold_event_monitor.hpp
+++ b/include/threshold_event_monitor.hpp
@@ -17,6 +17,7 @@
 #pragma once
 #include <sel_logger.hpp>
 #include <sensorutils.hpp>
+
 #include <string_view>
 #include <variant>
 
@@ -37,7 +38,7 @@
     std::shared_ptr<sdbusplus::asio::connection> conn)
 {
     auto thresholdEventMatcherCallback = [conn](
-                                             sdbusplus::message::message &msg) {
+                                             sdbusplus::message::message& msg) {
         // This static set of std::pair<path, event> tracks asserted events to
         // avoid duplicate logs or deasserts logged without an assert
         static boost::container::flat_set<std::pair<std::string, std::string>>
@@ -51,7 +52,7 @@
             propertiesChanged;
         msg.read(thresholdInterface, propertiesChanged);
         std::string event = propertiesChanged.begin()->first;
-        bool *pval = std::get_if<bool>(&propertiesChanged.begin()->second);
+        bool* pval = std::get_if<bool>(&propertiesChanged.begin()->second);
         if (!pval)
         {
             std::cerr << "threshold event direction has invalid type\n";
@@ -121,7 +122,7 @@
                 conn->call(getSensorValue);
             getSensorValueResp.read(sensorValue);
         }
-        catch (sdbusplus::exception_t &)
+        catch (sdbusplus::exception_t&)
         {
             std::cerr << "error getting sensor value from " << msg.get_path()
                       << "\n";
@@ -159,7 +160,7 @@
         {
             eventData[1] = ipmi::getScaledIPMIValue(sensorVal, max, min);
         }
-        catch (const std::exception &e)
+        catch (const std::exception& e)
         {
             std::cerr << e.what();
             eventData[1] = 0xFF;
@@ -185,7 +186,7 @@
                 conn->call(getThreshold);
             getThresholdResp.read(thresholdValue);
         }
-        catch (sdbusplus::exception_t &)
+        catch (sdbusplus::exception_t&)
         {
             std::cerr << "error getting sensor threshold from "
                       << msg.get_path() << "\n";
@@ -201,7 +202,7 @@
         {
             eventData[2] = ipmi::getScaledIPMIValue(thresholdVal, max, min);
         }
-        catch (const std::exception &e)
+        catch (const std::exception& e)
         {
             std::cerr << e.what();
             eventData[2] = 0xFF;
@@ -286,7 +287,7 @@
             sensorName.data(), sensorVal, thresholdVal);
     };
     sdbusplus::bus::match::match thresholdEventMatcher(
-        static_cast<sdbusplus::bus::bus &>(*conn),
+        static_cast<sdbusplus::bus::bus&>(*conn),
         "type='signal',interface='org.freedesktop.DBus.Properties',member='"
         "PropertiesChanged',arg0namespace='xyz.openbmc_project.Sensor."
         "Threshold'",
diff --git a/src/sel_logger.cpp b/src/sel_logger.cpp
index 7fe52fb..fadcc17 100644
--- a/src/sel_logger.cpp
+++ b/src/sel_logger.cpp
@@ -18,37 +18,38 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/container/flat_map.hpp>
 #include <boost/container/flat_set.hpp>
+#include <pulse_event_monitor.hpp>
+#include <sdbusplus/asio/object_server.hpp>
+#include <sel_logger.hpp>
+#include <threshold_event_monitor.hpp>
+
 #include <filesystem>
 #include <fstream>
 #include <iomanip>
 #include <iostream>
-#include <pulse_event_monitor.hpp>
-#include <sdbusplus/asio/object_server.hpp>
-#include <sel_logger.hpp>
 #include <sstream>
-#include <threshold_event_monitor.hpp>
 
 struct DBusInternalError final : public sdbusplus::exception_t
 {
-    const char *name() const noexcept override
+    const char* name() const noexcept override
     {
         return "org.freedesktop.DBus.Error.Failed";
     };
-    const char *description() const noexcept override
+    const char* description() const noexcept override
     {
         return "internal error";
     };
-    const char *what() const noexcept override
+    const char* what() const noexcept override
     {
         return "org.freedesktop.DBus.Error.Failed: "
                "internal error";
     };
 };
 
-static bool getSELLogFiles(std::vector<std::filesystem::path> &selLogFiles)
+static bool getSELLogFiles(std::vector<std::filesystem::path>& selLogFiles)
 {
     // Loop through the directory looking for ipmi_sel log files
-    for (const std::filesystem::directory_entry &dirEnt :
+    for (const std::filesystem::directory_entry& dirEnt :
          std::filesystem::directory_iterator(selLogDir))
     {
         std::string filename = dirEnt.path().filename();
@@ -114,11 +115,11 @@
     return recordId;
 }
 
-static void toHexStr(const std::vector<uint8_t> &data, std::string &hexStr)
+static void toHexStr(const std::vector<uint8_t>& data, std::string& hexStr)
 {
     std::stringstream stream;
     stream << std::hex << std::uppercase << std::setfill('0');
-    for (const int &v : data)
+    for (const int& v : data)
     {
         stream << std::setw(2) << v;
     }
@@ -127,9 +128,9 @@
 
 template <typename... T>
 static uint16_t
-    selAddSystemRecord(const std::string &message, const std::string &path,
-                       const std::vector<uint8_t> &selData, const bool &assert,
-                       const uint16_t &genId, T &&... metadata)
+    selAddSystemRecord(const std::string& message, const std::string& path,
+                       const std::vector<uint8_t>& selData, const bool& assert,
+                       const uint16_t& genId, T&&... metadata)
 {
     // Only 3 bytes of SEL event data are allowed in a system record
     if (selData.size() > selEvtDataMaxSize)
@@ -150,9 +151,9 @@
     return recordId;
 }
 
-static uint16_t selAddOemRecord(const std::string &message,
-                                const std::vector<uint8_t> &selData,
-                                const uint8_t &recordType)
+static uint16_t selAddOemRecord(const std::string& message,
+                                const std::vector<uint8_t>& selData,
+                                const uint8_t& recordType)
 {
     // A maximum of 13 bytes of SEL event data are allowed in an OEM record
     if (selData.size() > selOemDataMaxSize)
@@ -170,7 +171,7 @@
     return recordId;
 }
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
     // setup connection to dbus
     boost::asio::io_service io;
@@ -186,16 +187,16 @@
 
     // Add a new SEL entry
     ifaceAddSel->register_method(
-        "IpmiSelAdd", [](const std::string &message, const std::string &path,
-                         const std::vector<uint8_t> &selData,
-                         const bool &assert, const uint16_t &genId) {
+        "IpmiSelAdd", [](const std::string& message, const std::string& path,
+                         const std::vector<uint8_t>& selData,
+                         const bool& assert, const uint16_t& genId) {
             return selAddSystemRecord(message, path, selData, assert, genId);
         });
     // Add a new OEM SEL entry
     ifaceAddSel->register_method(
         "IpmiSelAddOem",
-        [](const std::string &message, const std::vector<uint8_t> &selData,
-           const uint8_t &recordType) {
+        [](const std::string& message, const std::vector<uint8_t>& selData,
+           const uint8_t& recordType) {
             return selAddOemRecord(message, selData, recordType);
         });
     ifaceAddSel->initialize();