Move and update clang-format

Use a single clang-format file at the root, so CI can find it, and
update it to the latest.

Change-Id: I07e1bf659466ee79e2215dba905226af04e23d32
Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
diff --git a/callback-manager/.clang-format b/.clang-format
similarity index 72%
rename from callback-manager/.clang-format
rename to .clang-format
index 625a0a0..e5530e6 100644
--- a/callback-manager/.clang-format
+++ b/.clang-format
@@ -6,55 +6,62 @@
 AlignConsecutiveAssignments: false
 AlignConsecutiveDeclarations: false
 AlignEscapedNewlines: Right
-AlignOperands:   true
-AlignTrailingComments: true
+AlignOperands:  Align
+AlignTrailingComments:
+  Kind: Always
+  OverEmptyLines: 1
 AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Empty
 AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
-AllowShortIfStatementsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Empty
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: true
 AllowShortLoopsOnASingleLine: false
-AlwaysBreakAfterReturnType: None
 AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: Yes
 BinPackArguments: true
 BinPackParameters: true
+BitFieldColonSpacing: None
 BraceWrapping:
   AfterCaseLabel:  true
   AfterClass:      true
   AfterControlStatement: true
   AfterEnum:       true
+  AfterExternBlock: true
   AfterFunction:   true
   AfterNamespace:  true
   AfterObjCDeclaration: true
   AfterStruct:     true
   AfterUnion:      true
-  AfterExternBlock: true
   BeforeCatch:     true
   BeforeElse:      true
+  BeforeLambdaBody: false
+  BeforeWhile:     false
   IndentBraces:    false
   SplitEmptyFunction:   false
   SplitEmptyRecord:     false
   SplitEmptyNamespace:  false
+BreakAfterAttributes: Never
+BreakAfterReturnType: Automatic
 BreakBeforeBinaryOperators: None
 BreakBeforeBraces: Custom
 BreakBeforeTernaryOperators: true
 BreakConstructorInitializers: AfterColon
 BreakInheritanceList: AfterColon
-BreakStringLiterals: true
+BreakStringLiterals: false
+BreakTemplateDeclarations: Yes
 ColumnLimit:     80
 CommentPragmas:  '^ IWYU pragma:'
 CompactNamespaces: false
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
 ConstructorInitializerIndentWidth: 4
 ContinuationIndentWidth: 4
 Cpp11BracedListStyle: true
 DerivePointerAlignment: false
-PointerAlignment: Left
 DisableFormat:   false
-ExperimentalAutoDetectBinPacking: false
 FixNamespaceComments: true
-ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+ForEachMacros:
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
 IncludeBlocks: Regroup
 IncludeCategories:
   - Regex:           '^[<"](gtest|gmock)'
@@ -74,9 +81,14 @@
   - Regex:           '.*'
     Priority:        6
 IndentCaseLabels: true
+IndentExternBlock: NoIndent
+IndentRequiresClause: true
 IndentWidth:     4
 IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: Signature
+LineEnding: LF
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
 MaxEmptyLinesToKeep: 1
@@ -84,14 +96,23 @@
 ObjCBlockIndentWidth: 2
 ObjCSpaceAfterProperty: false
 ObjCSpaceBeforeProtocolList: true
-PenaltyBreakBeforeFirstCallParameter: 19
+PackConstructorInitializers: BinPack
+PenaltyBreakAssignment: 25
+PenaltyBreakBeforeFirstCallParameter: 50
 PenaltyBreakComment: 300
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
 PenaltyExcessCharacter: 1000000
-PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyReturnTypeOnItsOwnLine: 150
+PenaltyIndentedWhitespace: 1
+PointerAlignment: Left
+QualifierAlignment: Left
+ReferenceAlignment: Left
 ReflowComments:  true
-SortIncludes:    true
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: Keyword
+SortIncludes: CaseSensitive
 SortUsingDeclarations: true
 SpaceAfterCStyleCast: false
 SpaceAfterTemplateKeyword: true
@@ -103,7 +124,7 @@
 SpaceBeforeRangeBasedForLoopColon: true
 SpaceInEmptyParentheses: false
 SpacesBeforeTrailingComments: 1
-SpacesInAngles:  false
+SpacesInAngles: Never
 SpacesInContainerLiterals: true
 SpacesInCStyleCastParentheses: false
 SpacesInParentheses: false
@@ -112,3 +133,4 @@
 TabWidth:        4
 UseTab:          Never
 ...
+
diff --git a/callback-manager/src/callback_manager.cpp b/callback-manager/src/callback_manager.cpp
index 9d67808..97f74f1 100644
--- a/callback-manager/src/callback_manager.cpp
+++ b/callback-manager/src/callback_manager.cpp
@@ -199,9 +199,9 @@
                 }
                 if constexpr (debug)
                 {
-                    std::cerr << "Set " << ledPair.first << " to "
-                              << std::boolalpha
-                              << std::get<bool>(ledPair.second) << "\n";
+                    std::cerr
+                        << "Set " << ledPair.first << " to " << std::boolalpha
+                        << std::get<bool>(ledPair.second) << "\n";
                 }
             },
             ledManagerBusname, ledPair.first, "org.freedesktop.DBus.Properties",
@@ -211,7 +211,6 @@
 
 void createThresholdMatch(std::shared_ptr<sdbusplus::asio::connection>& conn)
 {
-
     static sdbusplus::bus::match_t match(
         static_cast<sdbusplus::bus_t&>(*conn),
         "type='signal',member='ThresholdAsserted'",
@@ -361,8 +360,9 @@
     std::shared_ptr<sdbusplus::asio::dbus_interface> rootIface =
         objServer.add_interface(rootPath,
                                 "xyz.openbmc_project.CallbackManager");
-    rootIface->register_method("RetriggerLEDUpdate",
-                               [&conn]() { updateLedStatus(conn, true); });
+    rootIface->register_method("RetriggerLEDUpdate", [&conn]() {
+        updateLedStatus(conn, true);
+    });
     rootIface->initialize();
 
     std::shared_ptr<sdbusplus::asio::dbus_interface> inventoryIface =
diff --git a/hsbp-manager/.clang-format b/hsbp-manager/.clang-format
deleted file mode 100644
index ea71ad6..0000000
--- a/hsbp-manager/.clang-format
+++ /dev/null
@@ -1,99 +0,0 @@
----
-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/hsbp-manager/include/utils.hpp b/hsbp-manager/include/utils.hpp
index bfe549c..304ea5b 100644
--- a/hsbp-manager/include/utils.hpp
+++ b/hsbp-manager/include/utils.hpp
@@ -20,11 +20,12 @@
 #include <boost/asio/io_context.hpp>
 #include <boost/asio/steady_timer.hpp>
 #include <boost/container/flat_map.hpp>
-#include <cstdint>
-#include <iostream>
 #include <sdbusplus/asio/connection.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/bus/match.hpp>
+
+#include <cstdint>
+#include <iostream>
 #include <string>
 #include <variant>
 #include <vector>
diff --git a/hsbp-manager/src/hsbp_manager.cpp b/hsbp-manager/src/hsbp_manager.cpp
index 1f66558..4f3f3c5 100644
--- a/hsbp-manager/src/hsbp_manager.cpp
+++ b/hsbp-manager/src/hsbp_manager.cpp
@@ -16,25 +16,27 @@
 
 #include "utils.hpp"
 
-#include <algorithm>
-#include <bitset>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/asio/posix/stream_descriptor.hpp>
 #include <boost/asio/steady_timer.hpp>
 #include <boost/container/flat_set.hpp>
-#include <filesystem>
-#include <forward_list>
-#include <fstream>
 #include <gpiod.hpp>
-#include <iostream>
-#include <list>
 #include <sdbusplus/asio/connection.hpp>
 #include <sdbusplus/asio/object_server.hpp>
 #include <sdbusplus/bus/match.hpp>
+
+#include <algorithm>
+#include <bitset>
+#include <filesystem>
+#include <forward_list>
+#include <fstream>
+#include <iostream>
+#include <list>
 #include <string>
 #include <utility>
 
-extern "C" {
+extern "C"
+{
 #include <i2c/smbus.h>
 #include <linux/i2c-dev.h>
 }
@@ -209,8 +211,8 @@
         size_t outCtrlBaseAddrIn, size_t outCtrlByteCountIn,
         std::unordered_map<std::string, std::vector<std::string>>& byteMapIn,
         std::string& nameIn, std::string& typeIn) :
-        bus(busIn),
-        address(addressIn), modeOfOperation(std::move(modeOfOperationIn)),
+        bus(busIn), address(addressIn),
+        modeOfOperation(std::move(modeOfOperationIn)),
         outCtrlBaseAddr(outCtrlBaseAddrIn),
         outCtrlByteCount(outCtrlByteCountIn), byteMap(std::move(byteMapIn)),
         name(std::move(nameIn)), type(std::move(typeIn))
@@ -454,8 +456,7 @@
         size_t outCtrlBaseAddrIn, size_t outCtrlByteCountIn,
         std::unordered_map<std::string, std::vector<std::string>>& ioMapIn,
         std::string& nameIn, std::string& typeIn) :
-        bus(busIn),
-        address(addressIn), confIORegAddr(confIORegAddrIn),
+        bus(busIn), address(addressIn), confIORegAddr(confIORegAddrIn),
         outCtrlBaseAddr(outCtrlBaseAddrIn),
         outCtrlByteCount(outCtrlByteCountIn), ioMap(std::move(ioMapIn)),
         name(std::move(nameIn)), type(std::move(typeIn))
@@ -595,8 +596,7 @@
 {
     Mux(size_t busIn, size_t addressIn, size_t channelsIn, size_t indexIn) :
         bus(busIn), address(addressIn), channels(channelsIn), index(indexIn)
-    {
-    }
+    {}
     size_t bus;
     size_t address;
     size_t channels;
@@ -683,9 +683,7 @@
 struct Drive
 {
     Drive(std::string driveName, bool present, bool isOperational, bool nvme,
-          bool rebuilding) :
-        isNvme(nvme),
-        isPresent(present), name(driveName)
+          bool rebuilding) : isNvme(nvme), isPresent(present), name(driveName)
     {
         constexpr const char* basePath =
             "/xyz/openbmc_project/inventory/item/drive/";
@@ -853,15 +851,12 @@
 
 struct Backplane : std::enable_shared_from_this<Backplane>
 {
-
     Backplane(size_t busIn, size_t addressIn, size_t backplaneIndexIn,
               const std::string& nameIn) :
-        bus(busIn),
-        address(addressIn), backplaneIndex(backplaneIndexIn - 1), name(nameIn),
-        timer(boost::asio::steady_timer(io)),
+        bus(busIn), address(addressIn), backplaneIndex(backplaneIndexIn - 1),
+        name(nameIn), timer(boost::asio::steady_timer(io)),
         muxes(std::make_shared<boost::container::flat_set<Mux>>())
-    {
-    }
+    {}
     void populateAsset(const std::string& rootPath, const std::string& busname)
     {
         conn->async_method_call(
@@ -944,9 +939,9 @@
         versionIface =
             objServer.add_interface("/xyz/openbmc_project/software/" + dbusName,
                                     "xyz.openbmc_project.Software.Version");
-        versionIface->register_property("Version", zeroPad(bootVer) + "." +
-                                                       zeroPad(fpgaVer) + "." +
-                                                       zeroPad(securityRev));
+        versionIface->register_property(
+            "Version", zeroPad(bootVer) + "." + zeroPad(fpgaVer) + "." +
+                           zeroPad(securityRev));
         versionIface->register_property(
             "Purpose",
             std::string(
@@ -1327,10 +1322,8 @@
   public:
     explicit AsyncCallbackHandler(std::function<void()> onSuccessIn,
                                   std::function<void()> onErrorIn) :
-        onSuccess(std::move(onSuccessIn)),
-        onError(std::move(onErrorIn))
-    {
-    }
+        onSuccess(std::move(onSuccessIn)), onError(std::move(onErrorIn))
+    {}
 
     void setError()
     {
@@ -1586,8 +1579,8 @@
                     continue;
                 }
                 if (std::find(objDict.begin()->second.begin(),
-                              objDict.begin()->second.end(),
-                              assetTag) == objDict.begin()->second.end())
+                              objDict.begin()->second.end(), assetTag) ==
+                    objDict.begin()->second.end())
                 {
                     // no asset tag to associate to
                     continue;
@@ -1601,10 +1594,10 @@
                             values) {
                         if (ec2)
                         {
-                            std::cerr << __FUNCTION__
-                                      << ": Error Getting Config "
-                                      << ec2.message() << " "
-                                      << "\n";
+                            std::cerr
+                                << __FUNCTION__ << ": Error Getting Config "
+                                << ec2.message() << " "
+                                << "\n";
                             drivesLoadedCallback->setError();
                             return;
                         }
@@ -1612,9 +1605,9 @@
 
                         if (findBus == values.end())
                         {
-                            std::cerr << __FUNCTION__
-                                      << ": Illegal interface at " << path
-                                      << "\n";
+                            std::cerr
+                                << __FUNCTION__ << ": Illegal interface at "
+                                << path << "\n";
                             drivesLoadedCallback->setError();
                             return;
                         }
@@ -1655,9 +1648,9 @@
                         size_t muxIndex = 0;
 
                         // find the channel of the mux the drive is on
-                        std::ifstream nameFile("/sys/bus/i2c/devices/i2c-" +
-                                               std::to_string(muxBus) +
-                                               "/name");
+                        std::ifstream nameFile(
+                            "/sys/bus/i2c/devices/i2c-" +
+                            std::to_string(muxBus) + "/name");
                         if (!nameFile)
                         {
                             std::cerr << __FUNCTION__
@@ -1677,9 +1670,9 @@
                         if (findId == std::string::npos ||
                             findId + 1 >= nameStr.size())
                         {
-                            std::cerr << __FUNCTION__
-                                      << ": Illegal name file on bus " << muxBus
-                                      << "\n";
+                            std::cerr
+                                << __FUNCTION__ << ": Illegal name file on bus "
+                                << muxBus << "\n";
                         }
 
                         std::string indexStr =
@@ -1742,9 +1735,9 @@
 
                         if (parent->drives.size() <= driveIndex)
                         {
-                            std::cerr << __FUNCTION__
-                                      << ": Illegal drive index at " << path
-                                      << " " << driveIndex << "\n";
+                            std::cerr
+                                << __FUNCTION__ << ": Illegal drive index at "
+                                << path << " " << driveIndex << "\n";
                             drivesLoadedCallback->setError();
                             return;
                         }
@@ -1817,9 +1810,9 @@
                             values) {
                         if (ec2)
                         {
-                            std::cerr << __FUNCTION__
-                                      << ": Error Getting Config "
-                                      << ec2.message() << "\n";
+                            std::cerr
+                                << __FUNCTION__ << ": Error Getting Config "
+                                << ec2.message() << "\n";
                             return;
                         }
                         auto findBus = values.find("Bus");
@@ -1828,9 +1821,9 @@
                         if (findBus == values.end() ||
                             findAddress == values.end())
                         {
-                            std::cerr << __FUNCTION__
-                                      << ": Illegal configuration at " << path
-                                      << "\n";
+                            std::cerr
+                                << __FUNCTION__ << ": Illegal configuration at "
+                                << path << "\n";
                             return;
                         }
                         size_t bus = static_cast<size_t>(
@@ -1898,9 +1891,9 @@
                                 std::string, BasicVariantType>& resp) {
                         if (ec2)
                         {
-                            std::cerr << __FUNCTION__
-                                      << ": Error Getting Config "
-                                      << ec2.message() << "\n";
+                            std::cerr
+                                << __FUNCTION__ << ": Error Getting Config "
+                                << ec2.message() << "\n";
                             backplanesLoadedCallback->setError();
                             return;
                         }
@@ -1929,9 +1922,9 @@
                         }
                         if (!bus || !address || !name || !backplaneIndex)
                         {
-                            std::cerr << __FUNCTION__
-                                      << ": Illegal configuration at " << path
-                                      << "\n";
+                            std::cerr
+                                << __FUNCTION__ << ": Illegal configuration at "
+                                << path << "\n";
                             backplanesLoadedCallback->setError();
                             return;
                         }
@@ -2079,8 +2072,8 @@
                         /* Configuration is not loaded yet. Backplanes will be
                          * loaded
                          * once configuration and components are loaded. */
-                        std::cerr << __FUNCTION__
-                                  << ": Discarding Backplane match\n";
+                        std::cerr
+                            << __FUNCTION__ << ": Discarding Backplane match\n";
                         return;
                     }
 
@@ -2140,8 +2133,8 @@
                          * loaded once
                          * configuration, components and backplanes are loaded.
                          */
-                        std::cerr << __FUNCTION__
-                                  << ": Discarding Drive match\n";
+                        std::cerr
+                            << __FUNCTION__ << ": Discarding Drive match\n";
                         return;
                     }
 
@@ -2231,7 +2224,6 @@
 
             for (auto& [path, objDict] : subtree)
             {
-
                 if (objDict.empty())
                 {
                     std::cerr << __FUNCTION__ << ": Subtree data corrupted !\n";
@@ -2373,7 +2365,6 @@
 
             for (auto& [path, objDict] : subtree)
             {
-
                 if (objDict.empty())
                 {
                     std::cerr << __FUNCTION__ << ": Subtree data corrupted !\n";
@@ -2625,8 +2616,8 @@
                     for (const auto& [key, value] : resp)
                     {
                         if (std::find(hsbpConfig.supportedHsbps.begin(),
-                                      hsbpConfig.supportedHsbps.end(),
-                                      key) != hsbpConfig.supportedHsbps.end())
+                                      hsbpConfig.supportedHsbps.end(), key) !=
+                            hsbpConfig.supportedHsbps.end())
                         {
                             std::optional<std::vector<std::string>> hsbpMap;
                             hsbpMap = std::get<NvmeMapping>(value);
@@ -2793,9 +2784,8 @@
         [](const boost::system::error_code ec) {
             if (ec)
             {
-                std::cerr << __FUNCTION__
-                          << ": nvmealert event error: " << ec.message()
-                          << "\n";
+                std::cerr << __FUNCTION__ << ": nvmealert event error: "
+                          << ec.message() << "\n";
             }
             nvmeLvc3AlertHandler();
         });