diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 52db9fb..6747575 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -96,8 +96,8 @@
     std::span<const MessageEntry>::iterator messageIt =
         std::find_if(registry.begin(), registry.end(),
                      [&messageKey](const MessageEntry& messageEntry) {
-                         return messageKey == messageEntry.first;
-                     });
+        return messageKey == messageEntry.first;
+        });
     if (messageIt != registry.end())
     {
         return &messageIt->second;
@@ -1183,91 +1183,89 @@
 
         static std::array<char, 1024> readBuffer;
 
-        inotifyConn->async_read_some(
-            boost::asio::buffer(readBuffer),
-            [&](const boost::system::error_code& ec,
-                const std::size_t& bytesTransferred) {
-                if (ec)
+        inotifyConn->async_read_some(boost::asio::buffer(readBuffer),
+                                     [&](const boost::system::error_code& ec,
+                                         const std::size_t& bytesTransferred) {
+            if (ec)
+            {
+                BMCWEB_LOG_ERROR << "Callback Error: " << ec.message();
+                return;
+            }
+            std::size_t index = 0;
+            while ((index + iEventSize) <= bytesTransferred)
+            {
+                struct inotify_event event
+                {};
+                std::memcpy(&event, &readBuffer[index], iEventSize);
+                if (event.wd == dirWatchDesc)
                 {
-                    BMCWEB_LOG_ERROR << "Callback Error: " << ec.message();
-                    return;
-                }
-                std::size_t index = 0;
-                while ((index + iEventSize) <= bytesTransferred)
-                {
-                    struct inotify_event event
-                    {};
-                    std::memcpy(&event, &readBuffer[index], iEventSize);
-                    if (event.wd == dirWatchDesc)
+                    if ((event.len == 0) ||
+                        (index + iEventSize + event.len > bytesTransferred))
                     {
-                        if ((event.len == 0) ||
-                            (index + iEventSize + event.len > bytesTransferred))
+                        index += (iEventSize + event.len);
+                        continue;
+                    }
+
+                    std::string fileName(&readBuffer[index + iEventSize]);
+                    if (fileName != "redfish")
+                    {
+                        index += (iEventSize + event.len);
+                        continue;
+                    }
+
+                    BMCWEB_LOG_DEBUG
+                        << "Redfish log file created/deleted. event.name: "
+                        << fileName;
+                    if (event.mask == IN_CREATE)
+                    {
+                        if (fileWatchDesc != -1)
                         {
-                            index += (iEventSize + event.len);
-                            continue;
+                            BMCWEB_LOG_DEBUG
+                                << "Remove and Add inotify watcher on "
+                                   "redfish event log file";
+                            // Remove existing inotify watcher and add
+                            // with new redfish event log file.
+                            inotify_rm_watch(inotifyFd, fileWatchDesc);
+                            fileWatchDesc = -1;
                         }
 
-                        std::string fileName(&readBuffer[index + iEventSize]);
-                        if (fileName != "redfish")
+                        fileWatchDesc = inotify_add_watch(
+                            inotifyFd, redfishEventLogFile, IN_MODIFY);
+                        if (fileWatchDesc == -1)
                         {
-                            index += (iEventSize + event.len);
-                            continue;
+                            BMCWEB_LOG_ERROR << "inotify_add_watch failed for "
+                                                "redfish log file.";
+                            return;
                         }
 
-                        BMCWEB_LOG_DEBUG
-                            << "Redfish log file created/deleted. event.name: "
-                            << fileName;
-                        if (event.mask == IN_CREATE)
+                        EventServiceManager::getInstance()
+                            .resetRedfishFilePosition();
+                        EventServiceManager::getInstance()
+                            .readEventLogsFromFile();
+                    }
+                    else if ((event.mask == IN_DELETE) ||
+                             (event.mask == IN_MOVED_TO))
+                    {
+                        if (fileWatchDesc != -1)
                         {
-                            if (fileWatchDesc != -1)
-                            {
-                                BMCWEB_LOG_DEBUG
-                                    << "Remove and Add inotify watcher on "
-                                       "redfish event log file";
-                                // Remove existing inotify watcher and add
-                                // with new redfish event log file.
-                                inotify_rm_watch(inotifyFd, fileWatchDesc);
-                                fileWatchDesc = -1;
-                            }
-
-                            fileWatchDesc = inotify_add_watch(
-                                inotifyFd, redfishEventLogFile, IN_MODIFY);
-                            if (fileWatchDesc == -1)
-                            {
-                                BMCWEB_LOG_ERROR
-                                    << "inotify_add_watch failed for "
-                                       "redfish log file.";
-                                return;
-                            }
-
-                            EventServiceManager::getInstance()
-                                .resetRedfishFilePosition();
-                            EventServiceManager::getInstance()
-                                .readEventLogsFromFile();
-                        }
-                        else if ((event.mask == IN_DELETE) ||
-                                 (event.mask == IN_MOVED_TO))
-                        {
-                            if (fileWatchDesc != -1)
-                            {
-                                inotify_rm_watch(inotifyFd, fileWatchDesc);
-                                fileWatchDesc = -1;
-                            }
+                            inotify_rm_watch(inotifyFd, fileWatchDesc);
+                            fileWatchDesc = -1;
                         }
                     }
-                    else if (event.wd == fileWatchDesc)
-                    {
-                        if (event.mask == IN_MODIFY)
-                        {
-                            EventServiceManager::getInstance()
-                                .readEventLogsFromFile();
-                        }
-                    }
-                    index += (iEventSize + event.len);
                 }
+                else if (event.wd == fileWatchDesc)
+                {
+                    if (event.mask == IN_MODIFY)
+                    {
+                        EventServiceManager::getInstance()
+                            .readEventLogsFromFile();
+                    }
+                }
+                index += (iEventSize + event.len);
+            }
 
-                watchRedfishEventLogFile();
-            });
+            watchRedfishEventLogFile();
+        });
     }
 
     static int startEventLogMonitor(boost::asio::io_context& ioc)
diff --git a/redfish-core/include/query.hpp b/redfish-core/include/query.hpp
index 88859e1..1f7774f 100644
--- a/redfish-core/include/query.hpp
+++ b/redfish-core/include/query.hpp
@@ -50,8 +50,8 @@
     res.setCompleteRequestHandler(
         [&app, handler(std::move(handler)),
          query{*queryOpt}](crow::Response& res) mutable {
-            processAllParams(app, query, handler, res);
-        });
+        processAllParams(app, query, handler, res);
+    });
     return true;
 }
 
diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp
index d076c6c..67ed929 100644
--- a/redfish-core/include/redfish_aggregator.hpp
+++ b/redfish-core/include/redfish_aggregator.hpp
@@ -33,32 +33,32 @@
         crow::connections::systemBus->async_method_call(
             [handler](const boost::system::error_code ec,
                       const dbus::utility::ManagedObjectType& objects) {
-                if (ec)
-                {
-                    BMCWEB_LOG_ERROR << "DBUS response error " << ec.value()
-                                     << ", " << ec.message();
-                    return;
-                }
+            if (ec)
+            {
+                BMCWEB_LOG_ERROR << "DBUS response error " << ec.value() << ", "
+                                 << ec.message();
+                return;
+            }
 
-                // Maps a chosen alias representing a satellite BMC to a url
-                // containing the information required to create a http
-                // connection to the satellite
-                std::unordered_map<std::string, boost::urls::url> satelliteInfo;
+            // Maps a chosen alias representing a satellite BMC to a url
+            // containing the information required to create a http
+            // connection to the satellite
+            std::unordered_map<std::string, boost::urls::url> satelliteInfo;
 
-                findSatelliteConfigs(objects, satelliteInfo);
+            findSatelliteConfigs(objects, satelliteInfo);
 
-                if (!satelliteInfo.empty())
-                {
-                    BMCWEB_LOG_DEBUG << "Redfish Aggregation enabled with "
-                                     << std::to_string(satelliteInfo.size())
-                                     << " satellite BMCs";
-                }
-                else
-                {
-                    BMCWEB_LOG_DEBUG
-                        << "No satellite BMCs detected.  Redfish Aggregation not enabled";
-                }
-                handler(satelliteInfo);
+            if (!satelliteInfo.empty())
+            {
+                BMCWEB_LOG_DEBUG << "Redfish Aggregation enabled with "
+                                 << std::to_string(satelliteInfo.size())
+                                 << " satellite BMCs";
+            }
+            else
+            {
+                BMCWEB_LOG_DEBUG
+                    << "No satellite BMCs detected.  Redfish Aggregation not enabled";
+            }
+            handler(satelliteInfo);
             },
             "xyz.openbmc_project.EntityManager", "/",
             "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
diff --git a/redfish-core/include/server_sent_events.hpp b/redfish-core/include/server_sent_events.hpp
index 13840d3..6663f66 100644
--- a/redfish-core/include/server_sent_events.hpp
+++ b/redfish-core/include/server_sent_events.hpp
@@ -109,30 +109,30 @@
             [self(shared_from_this())](
                 boost::beast::error_code ec,
                 [[maybe_unused]] const std::size_t& bytesTransferred) {
-                self->outBuffer.erase(0, bytesTransferred);
+            self->outBuffer.erase(0, bytesTransferred);
 
-                if (ec == boost::asio::error::eof)
-                {
-                    // Send is successful, Lets remove data from queue
-                    // check for next request data in queue.
-                    self->requestDataQueue.pop();
-                    self->state = SseConnState::idle;
-                    self->checkQueue();
-                    return;
-                }
+            if (ec == boost::asio::error::eof)
+            {
+                // Send is successful, Lets remove data from queue
+                // check for next request data in queue.
+                self->requestDataQueue.pop();
+                self->state = SseConnState::idle;
+                self->checkQueue();
+                return;
+            }
 
-                if (ec)
-                {
-                    BMCWEB_LOG_ERROR << "async_write_some() failed: "
-                                     << ec.message();
-                    self->state = SseConnState::sendFailed;
-                    self->checkQueue();
-                    return;
-                }
-                BMCWEB_LOG_DEBUG << "async_write_some() bytes transferred: "
-                                 << bytesTransferred;
+            if (ec)
+            {
+                BMCWEB_LOG_ERROR << "async_write_some() failed: "
+                                 << ec.message();
+                self->state = SseConnState::sendFailed;
+                self->checkQueue();
+                return;
+            }
+            BMCWEB_LOG_DEBUG << "async_write_some() bytes transferred: "
+                             << bytesTransferred;
 
-                self->doWrite();
+            self->doWrite();
             });
     }
 
@@ -166,17 +166,17 @@
             [this, response,
              serializer](const boost::beast::error_code& ec,
                          [[maybe_unused]] const std::size_t& bytesTransferred) {
-                if (ec)
-                {
-                    BMCWEB_LOG_ERROR << "Error sending header" << ec;
-                    state = SseConnState::initFailed;
-                    checkQueue();
-                    return;
-                }
-
-                BMCWEB_LOG_DEBUG << "startSSE  Header sent.";
-                state = SseConnState::initialized;
+            if (ec)
+            {
+                BMCWEB_LOG_ERROR << "Error sending header" << ec;
+                state = SseConnState::initFailed;
                 checkQueue();
+                return;
+            }
+
+            BMCWEB_LOG_DEBUG << "startSSE  Header sent.";
+            state = SseConnState::initialized;
+            checkQueue();
             });
     }
 
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index f4e37b5..7a845d1 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -33,46 +33,46 @@
         [collectionPath, aResp{std::move(aResp)}](
             const boost::system::error_code ec,
             const dbus::utility::MapperGetSubTreePathsResponse& objects) {
-            if (ec == boost::system::errc::io_error)
-            {
-                aResp->res.jsonValue["Members"] = nlohmann::json::array();
-                aResp->res.jsonValue["Members@odata.count"] = 0;
-                return;
-            }
+        if (ec == boost::system::errc::io_error)
+        {
+            aResp->res.jsonValue["Members"] = nlohmann::json::array();
+            aResp->res.jsonValue["Members@odata.count"] = 0;
+            return;
+        }
 
-            if (ec)
-            {
-                BMCWEB_LOG_DEBUG << "DBUS response error " << ec.value();
-                messages::internalError(aResp->res);
-                return;
-            }
+        if (ec)
+        {
+            BMCWEB_LOG_DEBUG << "DBUS response error " << ec.value();
+            messages::internalError(aResp->res);
+            return;
+        }
 
-            std::vector<std::string> pathNames;
-            for (const auto& object : objects)
+        std::vector<std::string> pathNames;
+        for (const auto& object : objects)
+        {
+            sdbusplus::message::object_path path(object);
+            std::string leaf = path.filename();
+            if (leaf.empty())
             {
-                sdbusplus::message::object_path path(object);
-                std::string leaf = path.filename();
-                if (leaf.empty())
-                {
-                    continue;
-                }
-                pathNames.push_back(leaf);
+                continue;
             }
-            std::sort(pathNames.begin(), pathNames.end(),
-                      AlphanumLess<std::string>());
+            pathNames.push_back(leaf);
+        }
+        std::sort(pathNames.begin(), pathNames.end(),
+                  AlphanumLess<std::string>());
 
-            nlohmann::json& members = aResp->res.jsonValue["Members"];
-            members = nlohmann::json::array();
-            for (const std::string& leaf : pathNames)
-            {
-                std::string newPath = collectionPath;
-                newPath += '/';
-                newPath += leaf;
-                nlohmann::json::object_t member;
-                member["@odata.id"] = std::move(newPath);
-                members.push_back(std::move(member));
-            }
-            aResp->res.jsonValue["Members@odata.count"] = members.size();
+        nlohmann::json& members = aResp->res.jsonValue["Members"];
+        members = nlohmann::json::array();
+        for (const std::string& leaf : pathNames)
+        {
+            std::string newPath = collectionPath;
+            newPath += '/';
+            newPath += leaf;
+            nlohmann::json::object_t member;
+            member["@odata.id"] = std::move(newPath);
+            members.push_back(std::move(member));
+        }
+        aResp->res.jsonValue["Members@odata.count"] = members.size();
         },
         "xyz.openbmc_project.ObjectMapper",
         "/xyz/openbmc_project/object_mapper",
diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp
index d80ce71..c4c323d 100644
--- a/redfish-core/include/utils/fw_utils.hpp
+++ b/redfish-core/include/utils/fw_utils.hpp
@@ -46,199 +46,183 @@
         [aResp, fwVersionPurpose, activeVersionPropName,
          populateLinkToImages](const boost::system::error_code ec,
                                const std::vector<std::string>& functionalFw) {
-            BMCWEB_LOG_DEBUG << "populateFirmwareInformation enter";
-            if (ec)
+        BMCWEB_LOG_DEBUG << "populateFirmwareInformation enter";
+        if (ec)
+        {
+            BMCWEB_LOG_ERROR << "error_code = " << ec;
+            BMCWEB_LOG_ERROR << "error msg = " << ec.message();
+            messages::internalError(aResp->res);
+            return;
+        }
+
+        if (functionalFw.empty())
+        {
+            // Could keep going and try to populate SoftwareImages but
+            // something is seriously wrong, so just fail
+            BMCWEB_LOG_ERROR << "Zero functional software in system";
+            messages::internalError(aResp->res);
+            return;
+        }
+
+        std::vector<std::string> functionalFwIds;
+        // example functionalFw:
+        // v as 2 "/xyz/openbmc_project/software/ace821ef"
+        //        "/xyz/openbmc_project/software/230fb078"
+        for (const auto& fw : functionalFw)
+        {
+            sdbusplus::message::object_path path(fw);
+            std::string leaf = path.filename();
+            if (leaf.empty())
             {
-                BMCWEB_LOG_ERROR << "error_code = " << ec;
-                BMCWEB_LOG_ERROR << "error msg = " << ec.message();
+                continue;
+            }
+
+            functionalFwIds.push_back(leaf);
+        }
+
+        crow::connections::systemBus->async_method_call(
+            [aResp, fwVersionPurpose, activeVersionPropName,
+             populateLinkToImages, functionalFwIds](
+                const boost::system::error_code ec2,
+                const dbus::utility::MapperGetSubTreeResponse& subtree) {
+            if (ec2)
+            {
+                BMCWEB_LOG_ERROR << "error_code = " << ec2;
+                BMCWEB_LOG_ERROR << "error msg = " << ec2.message();
                 messages::internalError(aResp->res);
                 return;
             }
 
-            if (functionalFw.empty())
-            {
-                // Could keep going and try to populate SoftwareImages but
-                // something is seriously wrong, so just fail
-                BMCWEB_LOG_ERROR << "Zero functional software in system";
-                messages::internalError(aResp->res);
-                return;
-            }
+            BMCWEB_LOG_DEBUG << "Found " << subtree.size() << " images";
 
-            std::vector<std::string> functionalFwIds;
-            // example functionalFw:
-            // v as 2 "/xyz/openbmc_project/software/ace821ef"
-            //        "/xyz/openbmc_project/software/230fb078"
-            for (const auto& fw : functionalFw)
+            for (const std::pair<std::string,
+                                 std::vector<std::pair<
+                                     std::string, std::vector<std::string>>>>&
+                     obj : subtree)
             {
-                sdbusplus::message::object_path path(fw);
-                std::string leaf = path.filename();
-                if (leaf.empty())
+
+                sdbusplus::message::object_path path(obj.first);
+                std::string swId = path.filename();
+                if (swId.empty())
                 {
-                    continue;
+                    messages::internalError(aResp->res);
+                    BMCWEB_LOG_ERROR << "Invalid firmware ID";
+
+                    return;
                 }
 
-                functionalFwIds.push_back(leaf);
-            }
+                bool runningImage = false;
+                // Look at Ids from
+                // /xyz/openbmc_project/software/functional
+                // to determine if this is a running image
+                if (std::find(functionalFwIds.begin(), functionalFwIds.end(),
+                              swId) != functionalFwIds.end())
+                {
+                    runningImage = true;
+                }
 
-            crow::connections::systemBus->async_method_call(
-                [aResp, fwVersionPurpose, activeVersionPropName,
-                 populateLinkToImages, functionalFwIds](
-                    const boost::system::error_code ec2,
-                    const dbus::utility::MapperGetSubTreeResponse& subtree) {
-                    if (ec2)
+                // Now grab its version info
+                crow::connections::systemBus->async_method_call(
+                    [aResp, swId, runningImage, fwVersionPurpose,
+                     activeVersionPropName, populateLinkToImages](
+                        const boost::system::error_code ec3,
+                        const dbus::utility::DBusPropertiesMap&
+                            propertiesList) {
+                    if (ec3)
                     {
-                        BMCWEB_LOG_ERROR << "error_code = " << ec2;
-                        BMCWEB_LOG_ERROR << "error msg = " << ec2.message();
+                        BMCWEB_LOG_ERROR << "error_code = " << ec3;
+                        BMCWEB_LOG_ERROR << "error msg = " << ec3.message();
                         messages::internalError(aResp->res);
                         return;
                     }
-
-                    BMCWEB_LOG_DEBUG << "Found " << subtree.size() << " images";
-
-                    for (const std::pair<
-                             std::string,
-                             std::vector<std::pair<
-                                 std::string, std::vector<std::string>>>>& obj :
-                         subtree)
+                    // example propertiesList
+                    // a{sv} 2 "Version" s
+                    // "IBM-witherspoon-OP9-v2.0.10-2.22" "Purpose"
+                    // s
+                    // "xyz.openbmc_project.Software.Version.VersionPurpose.Host"
+                    std::string version;
+                    std::string swInvPurpose;
+                    for (const auto& propertyPair : propertiesList)
                     {
-
-                        sdbusplus::message::object_path path(obj.first);
-                        std::string swId = path.filename();
-                        if (swId.empty())
+                        if (propertyPair.first == "Purpose")
                         {
-                            messages::internalError(aResp->res);
-                            BMCWEB_LOG_ERROR << "Invalid firmware ID";
-
-                            return;
+                            const std::string* purpose =
+                                std::get_if<std::string>(&propertyPair.second);
+                            if (purpose == nullptr)
+                            {
+                                messages::internalError(aResp->res);
+                                return;
+                            }
+                            swInvPurpose = *purpose;
                         }
-
-                        bool runningImage = false;
-                        // Look at Ids from
-                        // /xyz/openbmc_project/software/functional
-                        // to determine if this is a running image
-                        if (std::find(functionalFwIds.begin(),
-                                      functionalFwIds.end(),
-                                      swId) != functionalFwIds.end())
+                        if (propertyPair.first == "Version")
                         {
-                            runningImage = true;
+                            const std::string* versionPtr =
+                                std::get_if<std::string>(&propertyPair.second);
+                            if (versionPtr == nullptr)
+                            {
+                                messages::internalError(aResp->res);
+                                return;
+                            }
+                            version = *versionPtr;
                         }
+                    }
 
-                        // Now grab its version info
-                        crow::connections::systemBus->async_method_call(
-                            [aResp, swId, runningImage, fwVersionPurpose,
-                             activeVersionPropName, populateLinkToImages](
-                                const boost::system::error_code ec3,
-                                const dbus::utility::DBusPropertiesMap&
-                                    propertiesList) {
-                                if (ec3)
-                                {
-                                    BMCWEB_LOG_ERROR << "error_code = " << ec3;
-                                    BMCWEB_LOG_ERROR << "error msg = "
-                                                     << ec3.message();
-                                    messages::internalError(aResp->res);
-                                    return;
-                                }
-                                // example propertiesList
-                                // a{sv} 2 "Version" s
-                                // "IBM-witherspoon-OP9-v2.0.10-2.22" "Purpose"
-                                // s
-                                // "xyz.openbmc_project.Software.Version.VersionPurpose.Host"
-                                std::string version;
-                                std::string swInvPurpose;
-                                for (const auto& propertyPair : propertiesList)
-                                {
-                                    if (propertyPair.first == "Purpose")
-                                    {
-                                        const std::string* purpose =
-                                            std::get_if<std::string>(
-                                                &propertyPair.second);
-                                        if (purpose == nullptr)
-                                        {
-                                            messages::internalError(aResp->res);
-                                            return;
-                                        }
-                                        swInvPurpose = *purpose;
-                                    }
-                                    if (propertyPair.first == "Version")
-                                    {
-                                        const std::string* versionPtr =
-                                            std::get_if<std::string>(
-                                                &propertyPair.second);
-                                        if (versionPtr == nullptr)
-                                        {
-                                            messages::internalError(aResp->res);
-                                            return;
-                                        }
-                                        version = *versionPtr;
-                                    }
-                                }
+                    BMCWEB_LOG_DEBUG << "Image ID: " << swId;
+                    BMCWEB_LOG_DEBUG << "Image purpose: " << swInvPurpose;
+                    BMCWEB_LOG_DEBUG << "Running image: " << runningImage;
 
-                                BMCWEB_LOG_DEBUG << "Image ID: " << swId;
-                                BMCWEB_LOG_DEBUG << "Image purpose: "
-                                                 << swInvPurpose;
-                                BMCWEB_LOG_DEBUG << "Running image: "
-                                                 << runningImage;
+                    if (version.empty())
+                    {
+                        messages::internalError(aResp->res);
+                        return;
+                    }
+                    if (swInvPurpose != fwVersionPurpose)
+                    {
+                        // Not purpose we're looking for
+                        return;
+                    }
 
-                                if (version.empty())
-                                {
-                                    messages::internalError(aResp->res);
-                                    return;
-                                }
-                                if (swInvPurpose != fwVersionPurpose)
-                                {
-                                    // Not purpose we're looking for
-                                    return;
-                                }
+                    if (populateLinkToImages)
+                    {
+                        nlohmann::json& softwareImageMembers =
+                            aResp->res.jsonValue["Links"]["SoftwareImages"];
+                        // Firmware images are at
+                        // /redfish/v1/UpdateService/FirmwareInventory/<Id>
+                        // e.g. .../FirmwareInventory/82d3ec86
+                        softwareImageMembers.push_back(
+                            {{"@odata.id", "/redfish/v1/UpdateService/"
+                                           "FirmwareInventory/" +
+                                               swId}});
+                        aResp->res
+                            .jsonValue["Links"]["SoftwareImages@odata.count"] =
+                            softwareImageMembers.size();
 
-                                if (populateLinkToImages)
-                                {
-                                    nlohmann::json& softwareImageMembers =
-                                        aResp->res.jsonValue["Links"]
-                                                            ["SoftwareImages"];
-                                    // Firmware images are at
-                                    // /redfish/v1/UpdateService/FirmwareInventory/<Id>
-                                    // e.g. .../FirmwareInventory/82d3ec86
-                                    softwareImageMembers.push_back(
-                                        {{"@odata.id",
-                                          "/redfish/v1/UpdateService/"
-                                          "FirmwareInventory/" +
-                                              swId}});
-                                    aResp->res.jsonValue
-                                        ["Links"]
-                                        ["SoftwareImages@odata.count"] =
-                                        softwareImageMembers.size();
-
-                                    if (runningImage)
-                                    {
-                                        // Create the link to the running image
-                                        aResp->res
-                                            .jsonValue["Links"]
-                                                      ["ActiveSoftwareImage"] =
-                                            {{"@odata.id",
-                                              "/redfish/v1/UpdateService/"
+                        if (runningImage)
+                        {
+                            // Create the link to the running image
+                            aResp->res
+                                .jsonValue["Links"]["ActiveSoftwareImage"] = {
+                                {"@odata.id", "/redfish/v1/UpdateService/"
                                               "FirmwareInventory/" +
                                                   swId}};
-                                    }
-                                }
-                                if (!activeVersionPropName.empty() &&
-                                    runningImage)
-                                {
-                                    aResp->res
-                                        .jsonValue[activeVersionPropName] =
-                                        version;
-                                }
-                            },
-                            obj.second[0].first, obj.first,
-                            "org.freedesktop.DBus.Properties", "GetAll",
-                            "xyz.openbmc_project.Software.Version");
+                        }
                     }
-                },
-                "xyz.openbmc_project.ObjectMapper",
-                "/xyz/openbmc_project/object_mapper",
-                "xyz.openbmc_project.ObjectMapper", "GetSubTree",
-                "/xyz/openbmc_project/software", static_cast<int32_t>(0),
-                std::array<const char*, 1>{
-                    "xyz.openbmc_project.Software.Version"});
+                    if (!activeVersionPropName.empty() && runningImage)
+                    {
+                        aResp->res.jsonValue[activeVersionPropName] = version;
+                    }
+                    },
+                    obj.second[0].first, obj.first,
+                    "org.freedesktop.DBus.Properties", "GetAll",
+                    "xyz.openbmc_project.Software.Version");
+            }
+            },
+            "xyz.openbmc_project.ObjectMapper",
+            "/xyz/openbmc_project/object_mapper",
+            "xyz.openbmc_project.ObjectMapper", "GetSubTree",
+            "/xyz/openbmc_project/software", static_cast<int32_t>(0),
+            std::array<const char*, 1>{"xyz.openbmc_project.Software.Version"});
         });
 }
 
@@ -317,33 +301,32 @@
         [asyncResp,
          swId](const boost::system::error_code errorCode,
                const dbus::utility::DBusPropertiesMap& propertiesList) {
-            if (errorCode)
+        if (errorCode)
+        {
+            // not all fwtypes are updateable, this is ok
+            asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
+            return;
+        }
+        const std::string* swInvActivation = nullptr;
+        for (const auto& property : propertiesList)
+        {
+            if (property.first == "Activation")
             {
-                // not all fwtypes are updateable, this is ok
-                asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
-                return;
+                swInvActivation = std::get_if<std::string>(&property.second);
             }
-            const std::string* swInvActivation = nullptr;
-            for (const auto& property : propertiesList)
-            {
-                if (property.first == "Activation")
-                {
-                    swInvActivation =
-                        std::get_if<std::string>(&property.second);
-                }
-            }
+        }
 
-            if (swInvActivation == nullptr)
-            {
-                BMCWEB_LOG_DEBUG << "wrong types for property\"Activation\"!";
-                messages::internalError(asyncResp->res);
-                return;
-            }
-            BMCWEB_LOG_DEBUG << "getFwStatus: Activation " << *swInvActivation;
-            asyncResp->res.jsonValue["Status"]["State"] =
-                getRedfishFWState(*swInvActivation);
-            asyncResp->res.jsonValue["Status"]["Health"] =
-                getRedfishFWHealth(*swInvActivation);
+        if (swInvActivation == nullptr)
+        {
+            BMCWEB_LOG_DEBUG << "wrong types for property\"Activation\"!";
+            messages::internalError(asyncResp->res);
+            return;
+        }
+        BMCWEB_LOG_DEBUG << "getFwStatus: Activation " << *swInvActivation;
+        asyncResp->res.jsonValue["Status"]["State"] =
+            getRedfishFWState(*swInvActivation);
+        asyncResp->res.jsonValue["Status"]["Health"] =
+            getRedfishFWHealth(*swInvActivation);
         },
         dbusSvc, "/xyz/openbmc_project/software/" + *swId,
         "org.freedesktop.DBus.Properties", "GetAll",
@@ -370,22 +353,22 @@
         "xyz.openbmc_project.Association", "endpoints",
         [asyncResp, fwId](const boost::system::error_code ec,
                           const std::vector<std::string>& objPaths) {
-            if (ec)
-            {
-                BMCWEB_LOG_DEBUG << " error_code = " << ec
-                                 << " error msg =  " << ec.message();
-                // System can exist with no updateable firmware,
-                // so don't throw error here.
-                return;
-            }
-            std::string reqFwObjPath = "/xyz/openbmc_project/software/" + *fwId;
+        if (ec)
+        {
+            BMCWEB_LOG_DEBUG << " error_code = " << ec
+                             << " error msg =  " << ec.message();
+            // System can exist with no updateable firmware,
+            // so don't throw error here.
+            return;
+        }
+        std::string reqFwObjPath = "/xyz/openbmc_project/software/" + *fwId;
 
-            if (std::find(objPaths.begin(), objPaths.end(), reqFwObjPath) !=
-                objPaths.end())
-            {
-                asyncResp->res.jsonValue["Updateable"] = true;
-                return;
-            }
+        if (std::find(objPaths.begin(), objPaths.end(), reqFwObjPath) !=
+            objPaths.end())
+        {
+            asyncResp->res.jsonValue["Updateable"] = true;
+            return;
+        }
         });
 }
 
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp
index 317cf11..de608df 100644
--- a/redfish-core/include/utils/json_utils.hpp
+++ b/redfish-core/include/utils/json_utils.hpp
@@ -451,15 +451,14 @@
                 break;
             }
 
-            result =
-                std::visit(
-                    [&item, &unpackSpec, &res](auto&& val) {
-                        using ContainedT =
-                            std::remove_pointer_t<std::decay_t<decltype(val)>>;
-                        return details::unpackValue<ContainedT>(
-                            item.value(), unpackSpec.key, res, *val);
-                    },
-                    unpackSpec.value) &&
+            result = std::visit(
+                         [&item, &unpackSpec, &res](auto&& val) {
+                using ContainedT =
+                    std::remove_pointer_t<std::decay_t<decltype(val)>>;
+                return details::unpackValue<ContainedT>(
+                    item.value(), unpackSpec.key, res, *val);
+                         },
+                         unpackSpec.value) &&
                 result;
 
             unpackSpec.complete = true;
@@ -479,9 +478,9 @@
         {
             bool isOptional = std::visit(
                 [](auto&& val) {
-                    using ContainedType =
-                        std::remove_pointer_t<std::decay_t<decltype(val)>>;
-                    return details::IsOptional<ContainedType>::value;
+                using ContainedType =
+                    std::remove_pointer_t<std::decay_t<decltype(val)>>;
+                return details::IsOptional<ContainedType>::value;
                 },
                 perUnpack.value);
             if (isOptional)
@@ -541,8 +540,8 @@
     }
     std::erase_if(*object,
                   [](const std::pair<std::string, nlohmann::json>& item) {
-                      return item.first.starts_with("@odata.");
-                  });
+        return item.first.starts_with("@odata.");
+    });
     if (object->empty())
     {
         //  If the update request only contains OData annotations, the service
