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: I862ed296ce1f42dba7047a74540d9004ad78130c
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index 79a474d..d92a3f1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -6,12 +6,14 @@
 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
+AllowShortFunctionsOnASingleLine: Empty
 AllowShortIfStatementsOnASingleLine: false
 AllowShortLoopsOnASingleLine: false
 AlwaysBreakAfterReturnType: None
@@ -36,6 +38,7 @@
   SplitEmptyFunction:   false
   SplitEmptyRecord:     false
   SplitEmptyNamespace:  false
+BreakAfterAttributes: Never
 BreakBeforeBinaryOperators: None
 BreakBeforeBraces: Custom
 BreakBeforeTernaryOperators: true
@@ -75,9 +78,13 @@
   - Regex:           '.*'
     Priority:        6
 IndentCaseLabels: true
+IndentRequiresClause: true
 IndentWidth:     4
 IndentWrappedFunctionNames: true
+InsertNewlineAtEOF: true
 KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
 MaxEmptyLinesToKeep: 1
@@ -85,13 +92,19 @@
 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
@@ -111,6 +124,6 @@
 SpacesInSquareBrackets: false
 Standard:        Latest
 TabWidth:        4
-UseCRLF: false
 UseTab:          Never
 ...
+
diff --git a/command/channel_auth.cpp b/command/channel_auth.cpp
index 44d5cad..3308bf6 100644
--- a/command/channel_auth.cpp
+++ b/command/channel_auth.cpp
@@ -225,8 +225,8 @@
     static std::vector<uint8_t> supportedAlgorithms;
     static bool recordInit = false;
 
-    uint8_t rspChannel =
-        ipmi::convertCurrentChannelNum(channelNumber, getInterfaceIndex());
+    uint8_t rspChannel = ipmi::convertCurrentChannelNum(channelNumber,
+                                                        getInterfaceIndex());
 
     if (!ipmi::isValidChannel(rspChannel))
     {
@@ -253,8 +253,8 @@
         }
     }
 
-    const std::vector<uint8_t>& records =
-        algoSelectBit ? cipherRecords : supportedAlgorithms;
+    const std::vector<uint8_t>& records = algoSelectBit ? cipherRecords
+                                                        : supportedAlgorithms;
     static constexpr auto respSize = 16;
 
     // Session support is available in active LAN channels.
@@ -271,8 +271,8 @@
     // set of 16 and so on.
 
     // Calculate the number of record data bytes to be returned.
-    auto start =
-        std::min(static_cast<size_t>(listIndex) * respSize, records.size());
+    auto start = std::min(static_cast<size_t>(listIndex) * respSize,
+                          records.size());
     auto end = std::min((static_cast<size_t>(listIndex) * respSize) + respSize,
                         records.size());
     auto size = end - start;
diff --git a/command/channel_auth.hpp b/command/channel_auth.hpp
index c518ba7..a1f9af7 100644
--- a/command/channel_auth.hpp
+++ b/command/channel_auth.hpp
@@ -27,7 +27,7 @@
 {
     uint8_t completionCode; // Completion Code
 
-    uint8_t channelNumber; // Channel number that the request was
+    uint8_t channelNumber;  // Channel number that the request was
     // received on
 
 #if BYTE_ORDER == LITTLE_ENDIAN
diff --git a/command/guid.cpp b/command/guid.cpp
index 253a2dc..5d6c07a 100644
--- a/command/guid.cpp
+++ b/command/guid.cpp
@@ -73,8 +73,8 @@
         for (size_t iter = 0, inc = 0; iter < len && inc < BMC_GUID_LEN;
              iter += 2, inc++)
         {
-            uint8_t hexVal =
-                std::strtoul(readUUID.substr(iter, 2).c_str(), NULL, 16);
+            uint8_t hexVal = std::strtoul(readUUID.substr(iter, 2).c_str(),
+                                          NULL, 16);
             guid[inc] = hexVal;
         }
     } while (0);
diff --git a/command/payload_cmds.hpp b/command/payload_cmds.hpp
index 8778786..bbd220a 100644
--- a/command/payload_cmds.hpp
+++ b/command/payload_cmds.hpp
@@ -194,7 +194,7 @@
 {
     uint8_t completionCode; //!< Completion code.
 
-    uint8_t capacity; //!< Instance capacity.
+    uint8_t capacity;       //!< Instance capacity.
 
     /* @brief Activation Status. */
 #if BYTE_ORDER == LITTLE_ENDIAN
diff --git a/command/rakp12.cpp b/command/rakp12.cpp
index bcdcc35..a6b4f85 100644
--- a/command/rakp12.cpp
+++ b/command/rakp12.cpp
@@ -75,8 +75,8 @@
         return outPayload;
     }
 
-    auto rakp1Size =
-        sizeof(RAKP1request) - (userNameMaxLen - request->user_name_len);
+    auto rakp1Size = sizeof(RAKP1request) -
+                     (userNameMaxLen - request->user_name_len);
 
     std::string message = "Invalid login attempted via RCMPP interface ";
     // Validate user name length in the message
diff --git a/command/session_cmds.cpp b/command/session_cmds.cpp
index 1405b6b..1a7c266 100644
--- a/command/session_cmds.cpp
+++ b/command/session_cmds.cpp
@@ -153,10 +153,10 @@
 
                 auto itr = serviceMap.begin();
                 const std::string service = itr->first;
-                uint8_t closeSessionPriv =
-                    std::get<uint8_t>(ipmi::getDbusProperty(
-                        *busp, service, obj, session::sessionIntf,
-                        "CurrentPrivilege"));
+                uint8_t closeSessionPriv = std::get<uint8_t>(
+                    ipmi::getDbusProperty(*busp, service, obj,
+                                          session::sessionIntf,
+                                          "CurrentPrivilege"));
 
                 if (currentSessionPriv < closeSessionPriv)
                 {
diff --git a/command_table.cpp b/command_table.cpp
index c0e655a..668f19b 100644
--- a/command_table.cpp
+++ b/command_table.cpp
@@ -79,24 +79,24 @@
         bus->async_method_call(
             [handler, this](const boost::system::error_code& ec,
                             const IpmiDbusRspType& response) {
-                if (!ec)
-                {
-                    const uint8_t& cc = std::get<3>(response);
-                    const std::vector<uint8_t>& responseData =
-                        std::get<4>(response);
-                    std::vector<uint8_t> payload;
-                    payload.reserve(1 + responseData.size());
-                    payload.push_back(cc);
-                    payload.insert(payload.end(), responseData.begin(),
-                                   responseData.end());
-                    handler->outPayload = std::move(payload);
-                }
-                else
-                {
-                    std::vector<uint8_t> payload;
-                    payload.push_back(IPMI_CC_UNSPECIFIED_ERROR);
-                    handler->outPayload = std::move(payload);
-                }
+            if (!ec)
+            {
+                const uint8_t& cc = std::get<3>(response);
+                const std::vector<uint8_t>& responseData =
+                    std::get<4>(response);
+                std::vector<uint8_t> payload;
+                payload.reserve(1 + responseData.size());
+                payload.push_back(cc);
+                payload.insert(payload.end(), responseData.begin(),
+                               responseData.end());
+                handler->outPayload = std::move(payload);
+            }
+            else
+            {
+                std::vector<uint8_t> payload;
+                payload.push_back(IPMI_CC_UNSPECIFIED_ERROR);
+                handler->outPayload = std::move(payload);
+            }
             },
             "xyz.openbmc_project.Ipmi.Host", "/xyz/openbmc_project/Ipmi",
             "xyz.openbmc_project.Ipmi.Server", "execute", netFn, lun, cmd,
@@ -119,8 +119,8 @@
             }
         }
 
-        handler->outPayload =
-            iterator->second->executeCommand(commandData, handler);
+        handler->outPayload = iterator->second->executeCommand(commandData,
+                                                               handler);
 
         auto end = std::chrono::steady_clock::now();
 
diff --git a/command_table.hpp b/command_table.hpp
index 295c659..03e1a48 100644
--- a/command_table.hpp
+++ b/command_table.hpp
@@ -14,8 +14,7 @@
 struct CommandID
 {
     static constexpr size_t lunBits = 2;
-    CommandID(uint32_t command) : command(command)
-    {}
+    CommandID(uint32_t command) : command(command) {}
 
     uint8_t netFnLun() const
     {
@@ -216,8 +215,7 @@
     {};
 
   public:
-    explicit Table(const Private&)
-    {}
+    explicit Table(const Private&) {}
     Table() = delete;
     ~Table() = default;
     // Command Table is a singleton so copy, copy-assignment, move and
diff --git a/crypt_algo.hpp b/crypt_algo.hpp
index 1064772..6a8c25d 100644
--- a/crypt_algo.hpp
+++ b/crypt_algo.hpp
@@ -43,8 +43,7 @@
     /**
      * @brief Constructor for Interface
      */
-    explicit Interface(const std::vector<uint8_t>& k2) : k2(k2)
-    {}
+    explicit Interface(const std::vector<uint8_t>& k2) : k2(k2) {}
 
     Interface() = delete;
     virtual ~Interface() = default;
@@ -143,8 +142,7 @@
      *
      * @param[in] - Session Integrity key
      */
-    explicit AlgoAES128(const std::vector<uint8_t>& k2) : Interface(k2)
-    {}
+    explicit AlgoAES128(const std::vector<uint8_t>& k2) : Interface(k2) {}
 
     AlgoAES128() = delete;
     ~AlgoAES128() = default;
diff --git a/integrity_algo.hpp b/integrity_algo.hpp
index d451d0e..6ba6340 100644
--- a/integrity_algo.hpp
+++ b/integrity_algo.hpp
@@ -47,8 +47,7 @@
      *
      * @param[in] - AuthCode length
      */
-    explicit Interface(size_t authLength) : authCodeLength(authLength)
-    {}
+    explicit Interface(size_t authLength) : authCodeLength(authLength) {}
 
     Interface() = delete;
     virtual ~Interface() = default;
diff --git a/message.hpp b/message.hpp
index 7902b1e..1deef71 100644
--- a/message.hpp
+++ b/message.hpp
@@ -247,8 +247,8 @@
     uint32_t sessionSeqNum;     // Session Sequence Number
     ClassOfMsg rmcpMsgClass;    // Class of Message
 #ifdef RMCP_PING
-    uint8_t asfMsgTag; // ASF Message Tag
-#endif                 // RMCP_PING
+    uint8_t asfMsgTag;          // ASF Message Tag
+#endif                          // RMCP_PING
 
     /** @brief Message payload
      *
diff --git a/message_handler.cpp b/message_handler.cpp
index b7314b8..f5c4a1b 100644
--- a/message_handler.cpp
+++ b/message_handler.cpp
@@ -120,8 +120,8 @@
                 return;
             }
 
-            auto start =
-                inMessage->payload.begin() + sizeof(LAN::header::Request);
+            auto start = inMessage->payload.begin() +
+                         sizeof(LAN::header::Request);
             auto end = inMessage->payload.end() - sizeof(LAN::trailer::Request);
             std::vector<uint8_t> inPayload(start, end);
             command::Table::get().executeCommand(command, inPayload,
diff --git a/message_parsers.cpp b/message_parsers.cpp
index c6dd4f8..33b53c1 100644
--- a/message_parsers.cpp
+++ b/message_parsers.cpp
@@ -208,10 +208,10 @@
         throw std::runtime_error("Invalid data length");
     }
 
-    bool integrityMismatch =
-        session->isIntegrityAlgoEnabled() && !message->isPacketAuthenticated;
-    bool encryptMismatch =
-        session->isCryptAlgoEnabled() && !message->isPacketEncrypted;
+    bool integrityMismatch = session->isIntegrityAlgoEnabled() &&
+                             !message->isPacketAuthenticated;
+    bool encryptMismatch = session->isCryptAlgoEnabled() &&
+                           !message->isPacketEncrypted;
 
     if (sessionID != session::sessionZero &&
         (integrityMismatch || encryptMismatch))
@@ -232,8 +232,8 @@
     if (message->isPacketEncrypted)
     {
         // Assign the decrypted payload to the IPMI Message
-        message->payload =
-            internal::decryptPayload(inPacket, message, payloadLen, session);
+        message->payload = internal::decryptPayload(inPacket, message,
+                                                    payloadLen, session);
     }
     else
     {
diff --git a/sd_event_loop.cpp b/sd_event_loop.cpp
index df985c4..fa8319c 100644
--- a/sd_event_loop.cpp
+++ b/sd_event_loop.cpp
@@ -39,13 +39,12 @@
 {
     udpSocket->async_wait(boost::asio::socket_base::wait_read,
                           [this](const boost::system::error_code& ec) {
-                              if (!ec)
-                              {
-                                  boost::asio::post(
-                                      *io, [this]() { startRmcpReceive(); });
-                                  handleRmcpPacket();
-                              }
-                          });
+        if (!ec)
+        {
+            boost::asio::post(*io, [this]() { startRmcpReceive(); });
+            handleRmcpPacket();
+        }
+    });
 }
 
 int EventLoop::getVLANID(const std::string channel)
diff --git a/sessions_manager.cpp b/sessions_manager.cpp
index c18bf80..e878de1 100644
--- a/sessions_manager.cpp
+++ b/sessions_manager.cpp
@@ -62,8 +62,8 @@
     objManager = std::make_unique<sdbusplus::server::manager_t>(
         *getSdBus(), session::sessionManagerRootPath);
 
-    auto objPath =
-        std::string(session::sessionManagerRootPath) + "/" + channel + "/0";
+    auto objPath = std::string(session::sessionManagerRootPath) + "/" +
+                   channel + "/0";
 
     chName = channel;
     setNetworkInstance();
@@ -232,8 +232,8 @@
     // active idle time in seconds = 60 / overflow^3
     constexpr int baseIdleMicros = 60 * 1000 * 1000;
     // no +1 for the zero session here because this is just active sessions
-    int sessionDivisor =
-        getActiveSessionCount() - session::maxSessionCountPerChannel;
+    int sessionDivisor = getActiveSessionCount() -
+                         session::maxSessionCountPerChannel;
     sessionDivisor = std::max(0, sessionDivisor) + 1;
     sessionDivisor = sessionDivisor * sessionDivisor * sessionDivisor;
     int activeMicros = baseIdleMicros / sessionDivisor;
@@ -242,8 +242,8 @@
     // setup idle time in seconds = max(3, 60 / overflow^3)
 
     // +1 for the zero session here because size() counts that too
-    int setupDivisor =
-        sessionsMap.size() - (session::maxSessionCountPerChannel + 1);
+    int setupDivisor = sessionsMap.size() -
+                       (session::maxSessionCountPerChannel + 1);
     setupDivisor = std::max(0, setupDivisor) + 1;
     setupDivisor = setupDivisor * setupDivisor * setupDivisor;
     constexpr int maxSetupMicros = 3 * 1000 * 1000;
diff --git a/socket_channel.hpp b/socket_channel.hpp
index 0edfcd5..02e7040 100644
--- a/socket_channel.hpp
+++ b/socket_channel.hpp
@@ -76,8 +76,8 @@
             const sockaddr_in* sa =
                 reinterpret_cast<const sockaddr_in*>(&remoteSockAddr);
             remoteIpv4Addr = sa->sin_addr.s_addr;
-            retval =
-                inet_ntop(AF_INET, &(sa->sin_addr), ipv4addr, sizeof(ipv4addr));
+            retval = inet_ntop(AF_INET, &(sa->sin_addr), ipv4addr,
+                               sizeof(ipv4addr));
         }
         else if (sockAddrSize == sizeof(sockaddr_in6))
         {
diff --git a/sol/sol_context.cpp b/sol/sol_context.cpp
index 06dabcc..08a717a 100644
--- a/sol/sol_context.cpp
+++ b/sol/sol_context.cpp
@@ -46,12 +46,12 @@
         std::weak_ptr<Context> weakRef = weak_from_this();
         accumulateTimer.async_wait(
             [weakRef](const boost::system::error_code& ec) {
-                std::shared_ptr<Context> self = weakRef.lock();
-                if (!ec && self)
-                {
-                    self->charAccTimerHandler();
-                }
-            });
+            std::shared_ptr<Context> self = weakRef.lock();
+            if (!ec && self)
+            {
+                self->charAccTimerHandler();
+            }
+        });
     }
     else
     {
diff --git a/sol/sol_manager.cpp b/sol/sol_manager.cpp
index 8fabeeb..fd5ad2f 100644
--- a/sol/sol_manager.cpp
+++ b/sol/sol_manager.cpp
@@ -56,8 +56,8 @@
     }
     std::vector<uint8_t> buffer(readSize);
     ec.clear();
-    size_t readDataLen =
-        consoleSocket->read_some(boost::asio::buffer(buffer), ec);
+    size_t readDataLen = consoleSocket->read_some(boost::asio::buffer(buffer),
+                                                  ec);
     if (ec)
     {
         lg2::error("Reading from host console socket failed: {ERROR}", "ERROR",
@@ -101,12 +101,12 @@
 
     consoleSocket->async_wait(boost::asio::socket_base::wait_read,
                               [this](const boost::system::error_code& ec) {
-                                  if (!ec)
-                                  {
-                                      consoleInputHandler();
-                                      startHostConsole();
-                                  }
-                              });
+        if (!ec)
+        {
+            consoleInputHandler();
+            startHostConsole();
+        }
+    });
 } // namespace sol
 
 void Manager::stopHostConsole()
@@ -130,8 +130,8 @@
     {
         try
         {
-            solService =
-                ipmi::getService(dbus, solInterface, solPathWitheEthName);
+            solService = ipmi::getService(dbus, solInterface,
+                                          solPathWitheEthName);
         }
         catch (const std::runtime_error& e)
         {
@@ -251,21 +251,21 @@
                     type::signal() + member("PropertiesChanged") +
                     interface("org.freedesktop.DBus.Properties"),
                 [](sdbusplus::message_t& msg) {
-                    std::string intfName;
-                    std::map<std::string, std::variant<bool>> properties;
-                    msg.read(intfName, properties);
+                std::string intfName;
+                std::map<std::string, std::variant<bool>> properties;
+                msg.read(intfName, properties);
 
-                    const auto it = properties.find("Enabled");
-                    if (it != properties.end())
+                const auto it = properties.find("Enabled");
+                if (it != properties.end())
+                {
+                    const bool* state = std::get_if<bool>(&it->second);
+
+                    if (state != nullptr && *state == false)
                     {
-                        const bool* state = std::get_if<bool>(&it->second);
-
-                        if (state != nullptr && *state == false)
-                        {
-                            // Stop all the payload session.
-                            sol::Manager::get().stopAllPayloadInstance();
-                        }
+                        // Stop all the payload session.
+                        sol::Manager::get().stopAllPayloadInstance();
                     }
+                }
                 });
         }
     }
@@ -335,8 +335,8 @@
         }
         else if (prop.first == "RetryIntervalMS")
         {
-            sol::Manager::get().retryInterval =
-                std::get<uint8_t>(prop.second) * sol::retryIntervalFactor * 1ms;
+            sol::Manager::get().retryInterval = std::get<uint8_t>(prop.second) *
+                                                sol::retryIntervalFactor * 1ms;
         }
     }
 }