clang-format: copy latest and re-format

clang-format-17 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: Ie6154ef3394b8e652a8cb1ac33d68e3c3cec8cd8
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d92a3f1..d43e884 100644
--- a/.clang-format
+++ b/.clang-format
@@ -14,26 +14,30 @@
 AllowShortBlocksOnASingleLine: Empty
 AllowShortCaseLabelsOnASingleLine: false
 AllowShortFunctionsOnASingleLine: Empty
-AllowShortIfStatementsOnASingleLine: false
+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
@@ -48,17 +52,16 @@
 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 ]
+ForEachMacros:
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
 IncludeBlocks: Regroup
 IncludeCategories:
   - Regex:           '^[<"](gtest|gmock)'
@@ -78,6 +81,7 @@
   - Regex:           '.*'
     Priority:        6
 IndentCaseLabels: true
+IndentExternBlock: NoIndent
 IndentRequiresClause: true
 IndentWidth:     4
 IndentWrappedFunctionNames: true
@@ -92,6 +96,7 @@
 ObjCBlockIndentWidth: 2
 ObjCSpaceAfterProperty: false
 ObjCSpaceBeforeProtocolList: true
+PackConstructorInitializers: BinPack
 PenaltyBreakAssignment: 25
 PenaltyBreakBeforeFirstCallParameter: 19
 PenaltyBreakComment: 300
@@ -100,12 +105,13 @@
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
 PenaltyIndentedWhitespace: 0
+PointerAlignment: Left
 QualifierAlignment: Left
 ReferenceAlignment: Left
 ReflowComments:  true
 RequiresClausePosition: OwnLine
 RequiresExpressionIndentation: Keyword
-SortIncludes:    true
+SortIncludes: CaseSensitive
 SortUsingDeclarations: true
 SpaceAfterCStyleCast: false
 SpaceAfterTemplateKeyword: true
@@ -117,7 +123,7 @@
 SpaceBeforeRangeBasedForLoopColon: true
 SpaceInEmptyParentheses: false
 SpacesBeforeTrailingComments: 1
-SpacesInAngles:  false
+SpacesInAngles: Never
 SpacesInContainerLiterals: true
 SpacesInCStyleCastParentheses: false
 SpacesInParentheses: false
diff --git a/bmc/firmware-handler/firmware_handler.cpp b/bmc/firmware-handler/firmware_handler.cpp
index d11702f..dc19b23 100644
--- a/bmc/firmware-handler/firmware_handler.cpp
+++ b/bmc/firmware-handler/firmware_handler.cpp
@@ -57,10 +57,9 @@
 
     std::vector<std::string> blobs;
     blobs.reserve(firmwares.size());
-    std::for_each(firmwares.begin(), firmwares.end(),
-                  [&blobs](const auto& blob) {
-        blobs.emplace_back(blob.blobName);
-    });
+    std::for_each(
+        firmwares.begin(), firmwares.end(),
+        [&blobs](const auto& blob) { blobs.emplace_back(blob.blobName); });
 
     if (0 == std::count(blobs.begin(), blobs.end(), hashBlobId))
     {
@@ -450,10 +449,9 @@
      * firmware handers (and file handlers, like this'll know where to write the
      * tarball, etc).
      */
-    auto h = std::find_if(handlers.begin(), handlers.end(),
-                          [&path](const auto& iter) {
-        return (iter.blobName == path);
-    });
+    auto h = std::find_if(
+        handlers.begin(), handlers.end(),
+        [&path](const auto& iter) { return (iter.blobName == path); });
     if (h == handlers.end())
     {
         return false;
diff --git a/bmc/firmware-handler/firmware_handler.hpp b/bmc/firmware-handler/firmware_handler.hpp
index 4f32b29..505f1a7 100644
--- a/bmc/firmware-handler/firmware_handler.hpp
+++ b/bmc/firmware-handler/firmware_handler.hpp
@@ -192,10 +192,9 @@
 
     void addBlobId(const std::string& blob)
     {
-        auto blobIdMatch = std::find_if(blobIDs.begin(), blobIDs.end(),
-                                        [&blob](const std::string& iter) {
-            return (iter == blob);
-        });
+        auto blobIdMatch = std::find_if(
+            blobIDs.begin(), blobIDs.end(),
+            [&blob](const std::string& iter) { return (iter == blob); });
         if (blobIdMatch == blobIDs.end())
         {
             blobIDs.push_back(blob);
diff --git a/bmc/firmware-handler/main.cpp b/bmc/firmware-handler/main.cpp
index a383d02..2726ce6 100644
--- a/bmc/firmware-handler/main.cpp
+++ b/bmc/firmware-handler/main.cpp
@@ -71,7 +71,7 @@
 
 extern "C"
 {
-    std::unique_ptr<blobs::GenericBlobInterface> createHandler();
+std::unique_ptr<blobs::GenericBlobInterface> createHandler();
 }
 
 std::unique_ptr<blobs::GenericBlobInterface> createHandler()
diff --git a/tools/helper.cpp b/tools/helper.cpp
index 15c363f..f419410 100644
--- a/tools/helper.cpp
+++ b/tools/helper.cpp
@@ -92,25 +92,24 @@
 {
     pollStat(session, blob,
              [](const ipmiblob::StatResponse& resp) -> std::optional<bool> {
-                 if (resp.metadata.size() != 1)
-                 {
-                     throw ToolException("Invalid stat metadata");
-                 }
-                 auto result =
-                     static_cast<ipmi_flash::ActionStatus>(resp.metadata[0]);
-                 switch (result)
-                 {
-                     case ipmi_flash::ActionStatus::failed:
-                         throw ToolException("BMC reported failure");
-                     case ipmi_flash::ActionStatus::unknown:
-                     case ipmi_flash::ActionStatus::running:
-                         return std::nullopt;
-                     case ipmi_flash::ActionStatus::success:
-                         return true;
-                     default:
-                         throw ToolException("Unrecognized action status");
-                 }
-             });
+        if (resp.metadata.size() != 1)
+        {
+            throw ToolException("Invalid stat metadata");
+        }
+        auto result = static_cast<ipmi_flash::ActionStatus>(resp.metadata[0]);
+        switch (result)
+        {
+            case ipmi_flash::ActionStatus::failed:
+                throw ToolException("BMC reported failure");
+            case ipmi_flash::ActionStatus::unknown:
+            case ipmi_flash::ActionStatus::running:
+                return std::nullopt;
+            case ipmi_flash::ActionStatus::success:
+                return true;
+            default:
+                throw ToolException("Unrecognized action status");
+        }
+    });
 }
 
 /* Poll an open blob session for reading.
@@ -132,16 +131,16 @@
     return pollStat(
         session, blob,
         [](const ipmiblob::StatResponse& resp) -> std::optional<uint32_t> {
-            if (resp.blob_state & ipmiblob::StateFlags::open_read)
-            {
-                return resp.size;
-            }
-            if (resp.blob_state & ipmiblob::StateFlags::committing)
-            {
-                return std::nullopt;
-            }
-            throw ToolException("BMC blob failed to become ready");
-        });
+        if (resp.blob_state & ipmiblob::StateFlags::open_read)
+        {
+            return resp.size;
+        }
+        if (resp.blob_state & ipmiblob::StateFlags::committing)
+        {
+            return std::nullopt;
+        }
+        throw ToolException("BMC blob failed to become ready");
+    });
 }
 
 void* memcpyAligned(void* destination, const void* source, std::size_t size)
diff --git a/tools/test/tools_bt_unittest.cpp b/tools/test/tools_bt_unittest.cpp
index 3d2c181..e1a091b 100644
--- a/tools/test/tools_bt_unittest.cpp
+++ b/tools/test/tools_bt_unittest.cpp
@@ -58,11 +58,10 @@
 
     EXPECT_CALL(sysMock, read(fd, NotNull(), _))
         .WillOnce(Invoke([&](int, void* buf, std::size_t count) {
-            EXPECT_TRUE(count > bytes.size());
-            std::memcpy(buf, bytes.data(), bytes.size());
-            return bytes.size();
-        }))
-        .WillOnce(Return(0));
+        EXPECT_TRUE(count > bytes.size());
+        std::memcpy(buf, bytes.data(), bytes.size());
+        return bytes.size();
+    })).WillOnce(Return(0));
 
     EXPECT_CALL(progMock, updateProgress(bytes.size()));
 
@@ -100,10 +99,10 @@
 
     EXPECT_CALL(sysMock, read(fd, NotNull(), _))
         .WillOnce(Invoke([&](int, void* buf, std::size_t count) {
-            EXPECT_TRUE(count > bytes.size());
-            std::memcpy(buf, bytes.data(), bytes.size());
-            return bytes.size();
-        }));
+        EXPECT_TRUE(count > bytes.size());
+        std::memcpy(buf, bytes.data(), bytes.size());
+        return bytes.size();
+    }));
 
     EXPECT_CALL(blobMock, writeBytes(session, 0, ContainerEq(bytes)))
         .WillOnce(Throw(ipmiblob::BlobException("failure")));
diff --git a/tools/test/tools_lpc_unittest.cpp b/tools/test/tools_lpc_unittest.cpp
index b180df5..2ecbaf0 100644
--- a/tools/test/tools_lpc_unittest.cpp
+++ b/tools/test/tools_lpc_unittest.cpp
@@ -56,17 +56,16 @@
         .WillOnce(Return(fakeFileSize));
     EXPECT_CALL(sysMock, read(_, NotNull(), Gt(data.size())))
         .WillOnce(Invoke([&data](int, void* buf, std::size_t) {
-            std::memcpy(buf, data.data(), data.size());
-            return data.size();
-        }))
-        .WillOnce(Return(0));
+        std::memcpy(buf, data.data(), data.size());
+        return data.size();
+    })).WillOnce(Return(0));
 
     EXPECT_CALL(ioMock, write(_, data.size(), _))
         .WillOnce(Invoke([&data](const std::size_t, const std::size_t,
                                  const void* const source) {
-            EXPECT_THAT(std::memcmp(source, data.data(), data.size()), 0);
-            return true;
-        }));
+        EXPECT_THAT(std::memcmp(source, data.data(), data.size()), 0);
+        return true;
+    }));
 
     EXPECT_CALL(blobMock, writeBytes(session, 0, _));
 
diff --git a/tools/test/tools_net_unittest.cpp b/tools/test/tools_net_unittest.cpp
index b291e1c..cb8776f 100644
--- a/tools/test/tools_net_unittest.cpp
+++ b/tools/test/tools_net_unittest.cpp
@@ -232,9 +232,9 @@
         InSequence seq;
         EXPECT_CALL(sysMock, sendfile(connFd, inFd, _, _))
             .WillOnce([](int, int, off_t*, size_t) {
-                errno = EINVAL;
-                return -1;
-            });
+            errno = EINVAL;
+            return -1;
+        });
 
         std::vector<uint8_t> chunk(chunkSize);
         for (std::uint32_t offset = 0; offset < fakeFileSize;
@@ -246,16 +246,16 @@
             }
             EXPECT_CALL(sysMock, read(inFd, _, Ge(chunkSize)))
                 .WillOnce([chunk](int, void* buf, size_t) {
-                    memcpy(buf, chunk.data(), chunkSize);
-                    return chunkSize;
-                });
+                memcpy(buf, chunk.data(), chunkSize);
+                return chunkSize;
+            });
             EXPECT_CALL(sysMock, send(connFd, _, chunkSize, 0))
                 .WillOnce([chunk](int, const void* data, size_t len, int) {
-                    std::vector<uint8_t> dcopy(len);
-                    memcpy(dcopy.data(), data, len);
-                    EXPECT_THAT(dcopy, ContainerEq(chunk));
-                    return chunkSize;
-                });
+                std::vector<uint8_t> dcopy(len);
+                memcpy(dcopy.data(), data, len);
+                EXPECT_THAT(dcopy, ContainerEq(chunk));
+                return chunkSize;
+            });
             EXPECT_CALL(blobMock,
                         writeBytes(session, offset, ContainerEq(chunkBytes)));
             EXPECT_CALL(progMock, updateProgress(chunkSize));