clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version.  The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.

See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.

Change-Id: Iceec1dc95b6c908ec6c21fb40093de9dd18bf11a
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index 8fe2bbc..b6e7b20 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -71,29 +71,29 @@
         [callback = std::forward<CallbackFunc>(callback),
          asyncResp](const boost::system::error_code& ec,
                     const dbus::utility::MapperGetSubTreeResponse& subtree) {
-        if (ec)
-        {
-            BMCWEB_LOG_ERROR("{}", ec);
-            return;
-        }
-        if (subtree.empty())
-        {
-            BMCWEB_LOG_DEBUG("Can't find chassis!");
-            return;
-        }
+            if (ec)
+            {
+                BMCWEB_LOG_ERROR("{}", ec);
+                return;
+            }
+            if (subtree.empty())
+            {
+                BMCWEB_LOG_DEBUG("Can't find chassis!");
+                return;
+            }
 
-        std::size_t idPos = subtree[0].first.rfind('/');
-        if (idPos == std::string::npos ||
-            (idPos + 1) >= subtree[0].first.size())
-        {
-            messages::internalError(asyncResp->res);
-            BMCWEB_LOG_DEBUG("Can't parse chassis ID!");
-            return;
-        }
-        std::string chassisId = subtree[0].first.substr(idPos + 1);
-        BMCWEB_LOG_DEBUG("chassisId = {}", chassisId);
-        callback(chassisId, asyncResp);
-    });
+            std::size_t idPos = subtree[0].first.rfind('/');
+            if (idPos == std::string::npos ||
+                (idPos + 1) >= subtree[0].first.size())
+            {
+                messages::internalError(asyncResp->res);
+                BMCWEB_LOG_DEBUG("Can't parse chassis ID!");
+                return;
+            }
+            std::string chassisId = subtree[0].first.substr(idPos + 1);
+            BMCWEB_LOG_DEBUG("chassisId = {}", chassisId);
+            callback(chassisId, asyncResp);
+        });
 }
 
 template <typename CallbackFunc>
@@ -106,99 +106,101 @@
         [protocolToDBus, callback = std::forward<CallbackFunc>(callback)](
             const boost::system::error_code& ec,
             const std::vector<UnitStruct>& r) {
-        std::vector<std::tuple<std::string, std::string, bool>> socketData;
-        if (ec)
-        {
-            BMCWEB_LOG_ERROR("{}", ec);
-            // return error code
-            callback(ec, socketData);
-            return;
-        }
-
-        // save all service output into vector
-        for (const UnitStruct& unit : r)
-        {
-            // Only traverse through <xyz>.socket units
-            const std::string& unitName = std::get<NET_PROTO_UNIT_NAME>(unit);
-
-            // find "." into unitsName
-            size_t lastCharPos = unitName.rfind('.');
-            if (lastCharPos == std::string::npos)
+            std::vector<std::tuple<std::string, std::string, bool>> socketData;
+            if (ec)
             {
-                continue;
+                BMCWEB_LOG_ERROR("{}", ec);
+                // return error code
+                callback(ec, socketData);
+                return;
             }
 
-            // is unitsName end with ".socket"
-            std::string unitNameEnd = unitName.substr(lastCharPos);
-            if (unitNameEnd != ".socket")
+            // save all service output into vector
+            for (const UnitStruct& unit : r)
             {
-                continue;
-            }
+                // Only traverse through <xyz>.socket units
+                const std::string& unitName =
+                    std::get<NET_PROTO_UNIT_NAME>(unit);
 
-            // find "@" into unitsName
-            if (size_t atCharPos = unitName.rfind('@');
-                atCharPos != std::string::npos)
-            {
-                lastCharPos = atCharPos;
-            }
-
-            // unitsName without "@eth(x).socket", only <xyz>
-            // unitsName without ".socket", only <xyz>
-            std::string unitNameStr = unitName.substr(0, lastCharPos);
-
-            for (const auto& kv : protocolToDBus)
-            {
-                // We are interested in services, which starts with
-                // mapped service name
-                if (unitNameStr != kv.second)
+                // find "." into unitsName
+                size_t lastCharPos = unitName.rfind('.');
+                if (lastCharPos == std::string::npos)
                 {
                     continue;
                 }
 
-                const std::string& socketPath =
-                    std::get<NET_PROTO_UNIT_OBJ_PATH>(unit);
-                const std::string& unitState =
-                    std::get<NET_PROTO_UNIT_SUB_STATE>(unit);
-
-                bool isProtocolEnabled = ((unitState == "running") ||
-                                          (unitState == "listening"));
-
-                // Some protocols may have multiple services associated with
-                // them (for example IPMI). Look to see if we've already added
-                // an entry for the current protocol.
-                auto find = std::ranges::find_if(
-                    socketData,
-                    [&kv](const std::tuple<std::string, std::string, bool>& i) {
-                    return std::get<1>(i) == kv.first;
-                });
-                if (find != socketData.end())
+                // is unitsName end with ".socket"
+                std::string unitNameEnd = unitName.substr(lastCharPos);
+                if (unitNameEnd != ".socket")
                 {
-                    // It only takes one enabled systemd service to consider a
-                    // protocol enabled so if the current entry already has it
-                    // enabled (or the new one is disabled) then just continue,
-                    // otherwise remove the current one and add this new one.
-                    if (std::get<2>(*find) || !isProtocolEnabled)
-                    {
-                        // Already registered as enabled or current one is not
-                        // enabled, nothing to do
-                        BMCWEB_LOG_DEBUG(
-                            "protocolName: {}, already true or current one is false: {}",
-                            kv.first, isProtocolEnabled);
-                        break;
-                    }
-                    // Remove existing entry and replace with new one (below)
-                    socketData.erase(find);
+                    continue;
                 }
 
-                socketData.emplace_back(socketPath, std::string(kv.first),
-                                        isProtocolEnabled);
-                // We found service, return from inner loop.
-                break;
-            }
-        }
+                // find "@" into unitsName
+                if (size_t atCharPos = unitName.rfind('@');
+                    atCharPos != std::string::npos)
+                {
+                    lastCharPos = atCharPos;
+                }
 
-        callback(ec, socketData);
-    },
+                // unitsName without "@eth(x).socket", only <xyz>
+                // unitsName without ".socket", only <xyz>
+                std::string unitNameStr = unitName.substr(0, lastCharPos);
+
+                for (const auto& kv : protocolToDBus)
+                {
+                    // We are interested in services, which starts with
+                    // mapped service name
+                    if (unitNameStr != kv.second)
+                    {
+                        continue;
+                    }
+
+                    const std::string& socketPath =
+                        std::get<NET_PROTO_UNIT_OBJ_PATH>(unit);
+                    const std::string& unitState =
+                        std::get<NET_PROTO_UNIT_SUB_STATE>(unit);
+
+                    bool isProtocolEnabled = ((unitState == "running") ||
+                                              (unitState == "listening"));
+
+                    // Some protocols may have multiple services associated with
+                    // them (for example IPMI). Look to see if we've already
+                    // added an entry for the current protocol.
+                    auto find = std::ranges::find_if(
+                        socketData,
+                        [&kv](const std::tuple<std::string, std::string, bool>&
+                                  i) { return std::get<1>(i) == kv.first; });
+                    if (find != socketData.end())
+                    {
+                        // It only takes one enabled systemd service to consider
+                        // a protocol enabled so if the current entry already
+                        // has it enabled (or the new one is disabled) then just
+                        // continue, otherwise remove the current one and add
+                        // this new one.
+                        if (std::get<2>(*find) || !isProtocolEnabled)
+                        {
+                            // Already registered as enabled or current one is
+                            // not enabled, nothing to do
+                            BMCWEB_LOG_DEBUG(
+                                "protocolName: {}, already true or current one is false: {}",
+                                kv.first, isProtocolEnabled);
+                            break;
+                        }
+                        // Remove existing entry and replace with new one
+                        // (below)
+                        socketData.erase(find);
+                    }
+
+                    socketData.emplace_back(socketPath, std::string(kv.first),
+                                            isProtocolEnabled);
+                    // We found service, return from inner loop.
+                    break;
+                }
+            }
+
+            callback(ec, socketData);
+        },
         "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
         "org.freedesktop.systemd1.Manager", "ListUnits");
 }
@@ -213,46 +215,46 @@
         [callback = std::forward<CallbackFunc>(callback)](
             const boost::system::error_code& ec,
             const std::vector<std::tuple<std::string, std::string>>& resp) {
-        if (ec)
-        {
-            BMCWEB_LOG_ERROR("{}", ec);
-            callback(ec, 0);
-            return;
-        }
-        if (resp.empty())
-        {
-            // Network Protocol Listen Response Elements is empty
-            boost::system::error_code ec1 =
-                boost::system::errc::make_error_code(
-                    boost::system::errc::bad_message);
-            // return error code
-            callback(ec1, 0);
-            BMCWEB_LOG_ERROR("{}", ec1);
-            return;
-        }
-        const std::string& listenStream =
-            std::get<NET_PROTO_LISTEN_STREAM>(resp[0]);
-        const char* pa = &listenStream[listenStream.rfind(':') + 1];
-        int port{0};
-        if (auto [p, ec2] = std::from_chars(pa, nullptr, port);
-            ec2 != std::errc())
-        {
-            // there is only two possibility invalid_argument and
-            // result_out_of_range
-            boost::system::error_code ec3 =
-                boost::system::errc::make_error_code(
-                    boost::system::errc::invalid_argument);
-            if (ec2 == std::errc::result_out_of_range)
+            if (ec)
             {
-                ec3 = boost::system::errc::make_error_code(
-                    boost::system::errc::result_out_of_range);
+                BMCWEB_LOG_ERROR("{}", ec);
+                callback(ec, 0);
+                return;
             }
-            // return error code
-            callback(ec3, 0);
-            BMCWEB_LOG_ERROR("{}", ec3);
-        }
-        callback(ec, port);
-    });
+            if (resp.empty())
+            {
+                // Network Protocol Listen Response Elements is empty
+                boost::system::error_code ec1 =
+                    boost::system::errc::make_error_code(
+                        boost::system::errc::bad_message);
+                // return error code
+                callback(ec1, 0);
+                BMCWEB_LOG_ERROR("{}", ec1);
+                return;
+            }
+            const std::string& listenStream =
+                std::get<NET_PROTO_LISTEN_STREAM>(resp[0]);
+            const char* pa = &listenStream[listenStream.rfind(':') + 1];
+            int port{0};
+            if (auto [p, ec2] = std::from_chars(pa, nullptr, port);
+                ec2 != std::errc())
+            {
+                // there is only two possibility invalid_argument and
+                // result_out_of_range
+                boost::system::error_code ec3 =
+                    boost::system::errc::make_error_code(
+                        boost::system::errc::invalid_argument);
+                if (ec2 == std::errc::result_out_of_range)
+                {
+                    ec3 = boost::system::errc::make_error_code(
+                        boost::system::errc::result_out_of_range);
+                }
+                // return error code
+                callback(ec3, 0);
+                BMCWEB_LOG_ERROR("{}", ec3);
+            }
+            callback(ec, port);
+        });
 }
 
 } // namespace redfish