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: I86d194886a4dcd325364041d4c7745f4ea22fd65
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/blobs-ipmid/blobs.hpp b/blobs-ipmid/blobs.hpp
index ab0b567..f394953 100644
--- a/blobs-ipmid/blobs.hpp
+++ b/blobs-ipmid/blobs.hpp
@@ -177,16 +177,17 @@
 } // namespace blobs
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 
-/**
- * All Blob handlers need to implement this method.  It is called after loading
- * the library to then get a handle to the blob handler.
- *
- * @return a unique pointer to your blob handler instance.
- */
-std::unique_ptr<blobs::GenericBlobInterface> createHandler();
+    /**
+     * All Blob handlers need to implement this method.  It is called after
+     * loading the library to then get a handle to the blob handler.
+     *
+     * @return a unique pointer to your blob handler instance.
+     */
+    std::unique_ptr<blobs::GenericBlobInterface> createHandler();
 
 #ifdef __cplusplus
 }
diff --git a/example/example.cpp b/example/example.cpp
index 4a3c248..f1e7ee7 100644
--- a/example/example.cpp
+++ b/example/example.cpp
@@ -1,9 +1,10 @@
 #include "example/example.hpp"
 
+#include <phosphor-logging/log.hpp>
+
 #include <algorithm>
 #include <cstring>
 #include <memory>
-#include <phosphor-logging/log.hpp>
 #include <string>
 #include <vector>
 
diff --git a/example/example.hpp b/example/example.hpp
index a53d6c0..7ceebd6 100644
--- a/example/example.hpp
+++ b/example/example.hpp
@@ -1,20 +1,22 @@
 #pragma once
 
 #include <blobs-ipmid/blobs.hpp>
+
 #include <memory>
 #include <string>
 #include <unordered_map>
 #include <vector>
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 
-/**
- * This method must be declared as extern C for blob manager to lookup the
- * symbol.
- */
-std::unique_ptr<blobs::GenericBlobInterface> createHandler();
+    /**
+     * This method must be declared as extern C for blob manager to lookup the
+     * symbol.
+     */
+    std::unique_ptr<blobs::GenericBlobInterface> createHandler();
 
 #ifdef __cplusplus
 }
@@ -31,8 +33,7 @@
     ExampleBlob(uint16_t id, uint16_t flags) :
         sessionId(id), flags(flags),
         state(StateFlags::open_read | StateFlags::open_write), length(0)
-    {
-    }
+    {}
 
     /* The blob handler session id. */
     uint16_t sessionId;
diff --git a/ipmi.cpp b/ipmi.cpp
index 5718e3c..3151559 100644
--- a/ipmi.cpp
+++ b/ipmi.cpp
@@ -256,8 +256,8 @@
     }
     std::memcpy(&request, data.data(), sizeof(request));
 
-    std::vector<uint8_t> result =
-        mgr->read(request.sessionId, request.offset, request.requestedSize);
+    std::vector<uint8_t> result = mgr->read(request.sessionId, request.offset,
+                                            request.requestedSize);
 
     /* If the Read fails, it returns success but with only the crc and 0 bytes
      * of data.
diff --git a/ipmi.hpp b/ipmi.hpp
index 51a9d79..f73065c 100644
--- a/ipmi.hpp
+++ b/ipmi.hpp
@@ -6,6 +6,7 @@
 
 #include <blobs-ipmid/blobs.hpp>
 #include <ipmid/api-types.hpp>
+
 #include <span>
 #include <string>
 #include <vector>
diff --git a/main.cpp b/main.cpp
index cfa0de9..b34e52c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -23,17 +23,18 @@
 
 #include <ipmid/api.h>
 
-#include <cstdio>
 #include <ipmid/api-types.hpp>
 #include <ipmid/handler.hpp>
 #include <ipmid/iana.hpp>
 #include <ipmid/oemopenbmc.hpp>
 #include <ipmid/oemrouter.hpp>
-#include <memory>
 #include <phosphor-logging/log.hpp>
-#include <span>
 #include <user_channel/channel_layer.hpp>
 
+#include <cstdio>
+#include <memory>
+#include <span>
+
 namespace blobs
 {
 
@@ -47,16 +48,15 @@
                  "Registering OEM:[%#08X], Cmd:[%#04X] for Blob Commands\n",
                  oem::obmcOemNumber, oem::Cmd::blobTransferCmd);
 
-    ipmi::registerOemHandler(
-        ipmi::prioOemBase, oem::obmcOemNumber, oem::Cmd::blobTransferCmd,
-        ::ipmi::Privilege::User,
-        [](ipmi::Context::ptr ctx, uint8_t cmd,
-           const std::vector<uint8_t>& data) {
-            // Get current IPMI channel and get the max transfer size
-            // (assuming that it does not change).
-            return handleBlobCommand(
-                cmd, data, ipmi::getChannelMaxTransferSize(ctx->channel));
-        });
+    ipmi::registerOemHandler(ipmi::prioOemBase, oem::obmcOemNumber,
+                             oem::Cmd::blobTransferCmd, ::ipmi::Privilege::User,
+                             [](ipmi::Context::ptr ctx, uint8_t cmd,
+                                const std::vector<uint8_t>& data) {
+        // Get current IPMI channel and get the max transfer size
+        // (assuming that it does not change).
+        return handleBlobCommand(cmd, data,
+                                 ipmi::getChannelMaxTransferSize(ctx->channel));
+    });
 
     /* Install handlers. */
     try
diff --git a/manager.cpp b/manager.cpp
index ba019d4..b462c82 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -245,9 +245,10 @@
 GenericBlobInterface* BlobManager::getHandler(const std::string& path)
 {
     /* Find a handler. */
-    auto h = std::find_if(
-        handlers.begin(), handlers.end(),
-        [&path](const auto& iter) { return (iter->canHandleBlob(path)); });
+    auto h = std::find_if(handlers.begin(), handlers.end(),
+                          [&path](const auto& iter) {
+        return (iter->canHandleBlob(path));
+    });
     if (h != handlers.end())
     {
         return h->get();
diff --git a/manager.hpp b/manager.hpp
index 31da10f..02b9e8a 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -1,9 +1,10 @@
 #pragma once
 
 #include <blobs-ipmid/blobs.hpp>
+#include <ipmid/oemrouter.hpp>
+
 #include <chrono>
 #include <ctime>
-#include <ipmid/oemrouter.hpp>
 #include <memory>
 #include <set>
 #include <string>
@@ -23,8 +24,7 @@
                 uint16_t flags) :
         blobId(path),
         handler(handler), flags(flags)
-    {
-    }
+    {}
     ~SessionInfo() = default;
 
     std::string blobId;
diff --git a/process.cpp b/process.cpp
index 2cbecb1..b44189b 100644
--- a/process.cpp
+++ b/process.cpp
@@ -18,9 +18,10 @@
 
 #include "ipmi.hpp"
 
-#include <cstring>
 #include <ipmiblob/crc.hpp>
 #include <ipmid/api-types.hpp>
+
+#include <cstring>
 #include <span>
 #include <unordered_map>
 #include <utility>
diff --git a/process.hpp b/process.hpp
index 494df71..dc30f9a 100644
--- a/process.hpp
+++ b/process.hpp
@@ -5,8 +5,9 @@
 
 #include <ipmid/api.h>
 
-#include <functional>
 #include <ipmid/api-types.hpp>
+
+#include <functional>
 #include <span>
 #include <utility>
 #include <vector>
diff --git a/test/helper.cpp b/test/helper.cpp
index 0a67458..bbb0410 100644
--- a/test/helper.cpp
+++ b/test/helper.cpp
@@ -1,6 +1,7 @@
 #include "helper.hpp"
 
 #include <ipmid/api-types.hpp>
+
 #include <optional>
 #include <span>
 #include <tuple>
diff --git a/test/helper.hpp b/test/helper.hpp
index 8d33f5c..ac2c572 100644
--- a/test/helper.hpp
+++ b/test/helper.hpp
@@ -1,4 +1,5 @@
 #include <ipmid/api-types.hpp>
+
 #include <optional>
 #include <span>
 #include <tuple>
diff --git a/test/ipmi_validate_unittest.cpp b/test/ipmi_validate_unittest.cpp
index 6bf4200..af6cce9 100644
--- a/test/ipmi_validate_unittest.cpp
+++ b/test/ipmi_validate_unittest.cpp
@@ -10,7 +10,6 @@
 
 TEST(IpmiValidateTest, VerifyCommandMinimumLengths)
 {
-
     struct TestCase
     {
         BlobOEMCommands cmd;
diff --git a/test/manager_mock.hpp b/test/manager_mock.hpp
index 5a94cf4..e43a856 100644
--- a/test/manager_mock.hpp
+++ b/test/manager_mock.hpp
@@ -3,6 +3,7 @@
 #include "manager.hpp"
 
 #include <blobs-ipmid/blobs.hpp>
+
 #include <memory>
 #include <string>
 
diff --git a/test/process_unittest.cpp b/test/process_unittest.cpp
index 1a0d6e4..9d0d06c 100644
--- a/test/process_unittest.cpp
+++ b/test/process_unittest.cpp
@@ -3,8 +3,9 @@
 #include "manager_mock.hpp"
 #include "process.hpp"
 
-#include <cstring>
 #include <ipmiblob/test/crc_mock.hpp>
+
+#include <cstring>
 #include <span>
 
 #include <gtest/gtest.h>
@@ -212,8 +213,8 @@
     std::vector<uint8_t> request(MAX_IPMI_BUFFER - 1);
     uint32_t payloadLen = sizeof(uint16_t) + sizeof(uint8_t);
 
-    IpmiBlobHandler h = [payloadLen](ManagerInterface*,
-                                     std::span<const uint8_t>) {
+    IpmiBlobHandler h =
+        [payloadLen](ManagerInterface*, std::span<const uint8_t>) {
         std::vector<uint8_t> output(payloadLen, 0);
         output[2] = 0x56;
         return ipmi::responseSuccess(output);
@@ -238,8 +239,8 @@
     std::vector<uint8_t> request(MAX_IPMI_BUFFER - 1);
     uint32_t payloadLen = sizeof(uint16_t) + sizeof(uint8_t);
 
-    IpmiBlobHandler h = [payloadLen](ManagerInterface*,
-                                     std::span<const uint8_t>) {
+    IpmiBlobHandler h =
+        [payloadLen](ManagerInterface*, std::span<const uint8_t>) {
         std::vector<uint8_t> output(payloadLen, 0);
         output[2] = 0x56;
         return ipmi::responseSuccess(output);
diff --git a/utils.cpp b/utils.cpp
index d0a5e5e..7744868 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -21,8 +21,9 @@
 
 #include <dlfcn.h>
 
-#include <memory>
 #include <phosphor-logging/log.hpp>
+
+#include <memory>
 #include <regex>
 #include <string>
 #include <unordered_set>