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: I8caffb39990bf9f0b54e6b1fee711e368a600b5c
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/service/src/mainapp.cpp b/service/src/mainapp.cpp
index 3749c93..83750c9 100644
--- a/service/src/mainapp.cpp
+++ b/service/src/mainapp.cpp
@@ -193,8 +193,8 @@
         return;
     }
 
-    std::string errorStr =
-        it->second.second + "(MinorCode:0x" + toHexString(minorErrorCode) + ")";
+    std::string errorStr = it->second.second + "(MinorCode:0x" +
+                           toHexString(minorErrorCode) + ")";
     std::string msgId = "OpenBMC.0.1." + it->second.first;
     sd_journal_send(
         "MESSAGE=%s", "Platform firmware resiliency error occurred.",
@@ -206,19 +206,19 @@
     handleLastCountChange(std::shared_ptr<sdbusplus::asio::connection> conn,
                           std::string eventName, uint8_t currentCount)
 {
-    sdbusplus::asio::setProperty(
-        *conn, "xyz.openbmc_project.Settings",
-        "/xyz/openbmc_project/pfr/last_events",
-        "xyz.openbmc_project.PFR.LastEvents", eventName, currentCount,
-        [](boost::system::error_code ec) {
-            if (ec)
-            {
-                phosphor::logging::log<phosphor::logging::level::ERR>(
-                    "PFR: Unable to update currentCount",
-                    phosphor::logging::entry("MSG=%s", ec.message().c_str()));
-                return;
-            }
-        });
+    sdbusplus::asio::setProperty(*conn, "xyz.openbmc_project.Settings",
+                                 "/xyz/openbmc_project/pfr/last_events",
+                                 "xyz.openbmc_project.PFR.LastEvents",
+                                 eventName, currentCount,
+                                 [](boost::system::error_code ec) {
+        if (ec)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "PFR: Unable to update currentCount",
+                phosphor::logging::entry("MSG=%s", ec.message().c_str()));
+            return;
+        }
+    });
     return;
 }
 
@@ -234,82 +234,81 @@
             const std::vector<
                 std::pair<std::string, std::variant<std::monostate, uint8_t>>>&
                 properties) {
-            if (ec)
-            {
-                phosphor::logging::log<phosphor::logging::level::ERR>(
-                    "PFR: Unable get PFR last events",
-                    phosphor::logging::entry("MSG=%s", ec.message().c_str()));
-                return;
-            }
-            uint8_t lastRecoveryCount = 0;
-            uint8_t lastPanicCount = 0;
-            uint8_t lastMajorErr = 0;
-            uint8_t lastMinorErr = 0;
+        if (ec)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "PFR: Unable get PFR last events",
+                phosphor::logging::entry("MSG=%s", ec.message().c_str()));
+            return;
+        }
+        uint8_t lastRecoveryCount = 0;
+        uint8_t lastPanicCount = 0;
+        uint8_t lastMajorErr = 0;
+        uint8_t lastMinorErr = 0;
 
-            try
-            {
-                sdbusplus::unpackProperties(
-                    properties, "lastRecoveryCount", lastRecoveryCount,
-                    "lastPanicCount", lastPanicCount, "lastMajorErr",
-                    lastMajorErr, "lastMinorErr", lastMinorErr);
-            }
-            catch (const sdbusplus::exception::UnpackPropertyError& error)
-            {
-                phosphor::logging::log<phosphor::logging::level::ERR>(
-                    "PFR: Unpack error",
-                    phosphor::logging::entry("MSG=%s", error.what()));
-                return;
-            }
+        try
+        {
+            sdbusplus::unpackProperties(
+                properties, "lastRecoveryCount", lastRecoveryCount,
+                "lastPanicCount", lastPanicCount, "lastMajorErr", lastMajorErr,
+                "lastMinorErr", lastMinorErr);
+        }
+        catch (const sdbusplus::exception::UnpackPropertyError& error)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "PFR: Unpack error",
+                phosphor::logging::entry("MSG=%s", error.what()));
+            return;
+        }
 
-            uint8_t currPanicCount = 0;
-            if (0 == readCpldReg(ActionType::panicCount, currPanicCount))
+        uint8_t currPanicCount = 0;
+        if (0 == readCpldReg(ActionType::panicCount, currPanicCount))
+        {
+            if (lastPanicCount != currPanicCount)
             {
-                if (lastPanicCount != currPanicCount)
+                // Update cached data to dbus and log redfish
+                // event by reading reason.
+                handleLastCountChange(conn, "lastPanicCount", currPanicCount);
+                if (currPanicCount)
                 {
-                    // Update cached data to dbus and log redfish
-                    // event by reading reason.
-                    handleLastCountChange(conn, "lastPanicCount",
-                                          currPanicCount);
-                    if (currPanicCount)
-                    {
-                        logLastPanicEvent();
-                    }
+                    logLastPanicEvent();
                 }
             }
+        }
 
-            uint8_t currRecoveryCount = 0;
-            if (0 == readCpldReg(ActionType::recoveryCount, currRecoveryCount))
+        uint8_t currRecoveryCount = 0;
+        if (0 == readCpldReg(ActionType::recoveryCount, currRecoveryCount))
+        {
+            if (lastRecoveryCount != currRecoveryCount)
             {
-                if (lastRecoveryCount != currRecoveryCount)
+                // Update cached data to dbus and log redfish
+                // event by reading reason.
+                handleLastCountChange(conn, "lastRecoveryCount",
+                                      currRecoveryCount);
+                if (currRecoveryCount)
                 {
-                    // Update cached data to dbus and log redfish
-                    // event by reading reason.
-                    handleLastCountChange(conn, "lastRecoveryCount",
-                                          currRecoveryCount);
-                    if (currRecoveryCount)
-                    {
-                        logLastRecoveryEvent();
-                    }
+                    logLastRecoveryEvent();
                 }
             }
+        }
 
-            uint8_t majorErr = 0;
-            uint8_t minorErr = 0;
-            if ((0 == readCpldReg(ActionType::majorError, majorErr)) &&
-                (0 == readCpldReg(ActionType::minorError, minorErr)))
+        uint8_t majorErr = 0;
+        uint8_t minorErr = 0;
+        if ((0 == readCpldReg(ActionType::majorError, majorErr)) &&
+            (0 == readCpldReg(ActionType::minorError, minorErr)))
+        {
+            if ((lastMajorErr != majorErr) || (lastMinorErr != minorErr))
             {
-                if ((lastMajorErr != majorErr) || (lastMinorErr != minorErr))
+                // Update cached data to dbus and log redfish event by
+                // reading reason.
+                handleLastCountChange(conn, "lastMajorErr", majorErr);
+                handleLastCountChange(conn, "lastMinorErr", minorErr);
+                if (majorErr && minorErr)
                 {
-                    // Update cached data to dbus and log redfish event by
-                    // reading reason.
-                    handleLastCountChange(conn, "lastMajorErr", majorErr);
-                    handleLastCountChange(conn, "lastMinorErr", minorErr);
-                    if (majorErr && minorErr)
-                    {
-                        logResiliencyErrorEvent(majorErr, minorErr);
-                    }
+                    logResiliencyErrorEvent(majorErr, minorErr);
                 }
             }
+        }
         });
 }
 
@@ -321,19 +320,19 @@
     stateTimer->expires_after(std::chrono::seconds(pollTimeout));
     stateTimer->async_wait(
         [&server, &conn](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
-            {
-                // Timer reset.
-                return;
-            }
-            if (ec)
-            {
-                // Platform State Monitor - Timer cancelled.
-                return;
-            }
-            checkAndLogEvents(conn);
-            monitorPlatformStateChange(server, conn);
-        });
+        if (ec == boost::asio::error::operation_aborted)
+        {
+            // Timer reset.
+            return;
+        }
+        if (ec)
+        {
+            // Platform State Monitor - Timer cancelled.
+            return;
+        }
+        checkAndLogEvents(conn);
+        monitorPlatformStateChange(server, conn);
+    });
 }
 
 void checkAndSetCheckpoint(sdbusplus::asio::object_server& server,
@@ -343,51 +342,51 @@
     conn->async_method_call(
         [&server, &conn](boost::system::error_code ec,
                          const std::variant<uint64_t>& value) {
-            if (!ec)
+        if (!ec)
+        {
+            if (std::get<uint64_t>(value))
             {
-                if (std::get<uint64_t>(value))
+                phosphor::logging::log<phosphor::logging::level::INFO>(
+                    "BMC boot completed. Setting checkpoint 9.");
+                if (!finishedSettingChkPoint)
                 {
-                    phosphor::logging::log<phosphor::logging::level::INFO>(
-                        "BMC boot completed. Setting checkpoint 9.");
-                    if (!finishedSettingChkPoint)
-                    {
-                        finishedSettingChkPoint = true;
-                        setBMCBootCheckpoint(bmcBootFinishedChkPoint);
-                    }
-                    return;
+                    finishedSettingChkPoint = true;
+                    setBMCBootCheckpoint(bmcBootFinishedChkPoint);
                 }
+                return;
             }
-            else
+        }
+        else
+        {
+            // Failed to get data from systemd. System might not
+            // be ready yet. Attempt again for data.
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "aync call failed to get FinishTimestamp.",
+                phosphor::logging::entry("MSG=%s", ec.message().c_str()));
+        }
+        // FIX-ME: Latest up-stream sync caused issue in receiving
+        // StartupFinished signal. Unable to get StartupFinished signal
+        // from systemd1 hence using poll method too, to trigger it
+        // properly.
+        constexpr size_t pollTimeout = 10; // seconds
+        initTimer->expires_after(std::chrono::seconds(pollTimeout));
+        initTimer->async_wait(
+            [&server, &conn](const boost::system::error_code& ec) {
+            if (ec == boost::asio::error::operation_aborted)
             {
-                // Failed to get data from systemd. System might not
-                // be ready yet. Attempt again for data.
-                phosphor::logging::log<phosphor::logging::level::ERR>(
-                    "aync call failed to get FinishTimestamp.",
-                    phosphor::logging::entry("MSG=%s", ec.message().c_str()));
+                // Timer reset.
+                phosphor::logging::log<phosphor::logging::level::INFO>(
+                    "Set boot Checkpoint - Timer aborted or stopped.");
+                return;
             }
-            // FIX-ME: Latest up-stream sync caused issue in receiving
-            // StartupFinished signal. Unable to get StartupFinished signal
-            // from systemd1 hence using poll method too, to trigger it
-            // properly.
-            constexpr size_t pollTimeout = 10; // seconds
-            initTimer->expires_after(std::chrono::seconds(pollTimeout));
-            initTimer->async_wait(
-                [&server, &conn](const boost::system::error_code& ec) {
-                    if (ec == boost::asio::error::operation_aborted)
-                    {
-                        // Timer reset.
-                        phosphor::logging::log<phosphor::logging::level::INFO>(
-                            "Set boot Checkpoint - Timer aborted or stopped.");
-                        return;
-                    }
-                    if (ec)
-                    {
-                        phosphor::logging::log<phosphor::logging::level::ERR>(
-                            "Set boot Checkpoint - async wait error.");
-                        return;
-                    }
-                    checkAndSetCheckpoint(server, conn);
-                });
+            if (ec)
+            {
+                phosphor::logging::log<phosphor::logging::level::ERR>(
+                    "Set boot Checkpoint - async wait error.");
+                return;
+            }
+            checkAndSetCheckpoint(server, conn);
+        });
         },
         "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
         "org.freedesktop.DBus.Properties", "Get",
@@ -405,14 +404,14 @@
         "member='StartupFinished',path='/org/freedesktop/systemd1',"
         "interface='org.freedesktop.systemd1.Manager'",
         [&server, &conn](sdbusplus::message_t& msg) {
-            if (!finishedSettingChkPoint)
-            {
-                phosphor::logging::log<phosphor::logging::level::INFO>(
-                    "BMC boot completed(StartupFinished). Setting "
-                    "checkpoint 9.");
-                finishedSettingChkPoint = true;
-                setBMCBootCheckpoint(bmcBootFinishedChkPoint);
-            }
+        if (!finishedSettingChkPoint)
+        {
+            phosphor::logging::log<phosphor::logging::level::INFO>(
+                "BMC boot completed(StartupFinished). Setting "
+                "checkpoint 9.");
+            finishedSettingChkPoint = true;
+            setBMCBootCheckpoint(bmcBootFinishedChkPoint);
+        }
         });
     checkAndSetCheckpoint(server, conn);
 
@@ -426,37 +425,36 @@
         "sender='xyz.openbmc_project.State.Chassis', "
         "arg0namespace='xyz.openbmc_project.State.Chassis'",
         [&server, &conn](sdbusplus::message_t& message) {
-            std::string intfName;
-            std::map<std::string, std::variant<std::string>> properties;
-            message.read(intfName, properties);
+        std::string intfName;
+        std::map<std::string, std::variant<std::string>> properties;
+        message.read(intfName, properties);
 
-            const auto it = properties.find("CurrentPowerState");
-            if (it != properties.end())
+        const auto it = properties.find("CurrentPowerState");
+        if (it != properties.end())
+        {
+            const std::string* state = std::get_if<std::string>(&it->second);
+            if (state != nullptr)
             {
-                const std::string* state =
-                    std::get_if<std::string>(&it->second);
-                if (state != nullptr)
+                if ((*state ==
+                     "xyz.openbmc_project.State.Chassis.PowerState.On") &&
+                    (!stateTimerRunning))
                 {
-                    if ((*state ==
-                         "xyz.openbmc_project.State.Chassis.PowerState.On") &&
-                        (!stateTimerRunning))
-                    {
-                        stateTimerRunning = true;
-                        monitorPlatformStateChange(server, conn);
-                    }
-                    else if ((*state == "xyz.openbmc_project.State.Chassis."
-                                        "PowerState.Off") &&
-                             (stateTimerRunning))
-                    {
-                        stateTimer->cancel();
-                        checkAndLogEvents(conn);
-                        stateTimerRunning = false;
-                    }
+                    stateTimerRunning = true;
+                    monitorPlatformStateChange(server, conn);
                 }
-
-                // Update the D-Bus properties when chassis state changes.
-                updateDbusPropertiesCache();
+                else if ((*state == "xyz.openbmc_project.State.Chassis."
+                                    "PowerState.Off") &&
+                         (stateTimerRunning))
+                {
+                    stateTimer->cancel();
+                    checkAndLogEvents(conn);
+                    stateTimerRunning = false;
+                }
             }
+
+            // Update the D-Bus properties when chassis state changes.
+            updateDbusPropertiesCache();
+        }
         });
 
     // Capture the Host state and Start the monitor timer
@@ -469,39 +467,38 @@
         "sender='xyz.openbmc_project.State.Chassis', "
         "arg0namespace='xyz.openbmc_project.State.Host'",
         [&server, &conn](sdbusplus::message_t& message) {
-            std::string intfName;
-            std::map<std::string, std::variant<std::string>> properties;
-            message.read(intfName, properties);
+        std::string intfName;
+        std::map<std::string, std::variant<std::string>> properties;
+        message.read(intfName, properties);
 
-            const auto it = properties.find("CurrentHostState");
-            if (it != properties.end())
+        const auto it = properties.find("CurrentHostState");
+        if (it != properties.end())
+        {
+            const std::string* state = std::get_if<std::string>(&it->second);
+            if (state != nullptr)
             {
-                const std::string* state =
-                    std::get_if<std::string>(&it->second);
-                if (state != nullptr)
+                if ((*state ==
+                     "xyz.openbmc_project.State.Host.HostState.Running") &&
+                    (!stateTimerRunning))
                 {
-                    if ((*state ==
-                         "xyz.openbmc_project.State.Host.HostState.Running") &&
-                        (!stateTimerRunning))
-                    {
-                        stateTimerRunning = true;
-                        monitorPlatformStateChange(server, conn);
-                    }
-                    else if (((*state == "xyz.openbmc_project.State.Host."
-                                         "HostState.Off") ||
-                              (*state == "xyz.openbmc_project.State.Host."
-                                         "HostState.Quiesced")) &&
-                             (stateTimerRunning))
-                    {
-                        stateTimer->cancel();
-                        checkAndLogEvents(conn);
-                        stateTimerRunning = false;
-                    }
+                    stateTimerRunning = true;
+                    monitorPlatformStateChange(server, conn);
                 }
-
-                // Update the D-Bus properties when host state changes.
-                updateDbusPropertiesCache();
+                else if (((*state == "xyz.openbmc_project.State.Host."
+                                     "HostState.Off") ||
+                          (*state == "xyz.openbmc_project.State.Host."
+                                     "HostState.Quiesced")) &&
+                         (stateTimerRunning))
+                {
+                    stateTimer->cancel();
+                    checkAndLogEvents(conn);
+                    stateTimerRunning = false;
+                }
             }
+
+            // Update the D-Bus properties when host state changes.
+            updateDbusPropertiesCache();
+        }
         });
 
     // Capture the OS state change and stop monitor timer
@@ -514,40 +511,39 @@
         "sender='xyz.openbmc_project.State.Chassis', "
         "arg0namespace='xyz.openbmc_project.State.OperatingSystem.Status'",
         [&server, &conn](sdbusplus::message_t& message) {
-            std::string intfName;
-            std::map<std::string, std::variant<std::string>> properties;
-            message.read(intfName, properties);
+        std::string intfName;
+        std::map<std::string, std::variant<std::string>> properties;
+        message.read(intfName, properties);
 
-            const auto it = properties.find("OperatingSystemState");
-            if (it != properties.end())
+        const auto it = properties.find("OperatingSystemState");
+        if (it != properties.end())
+        {
+            const std::string* state = std::get_if<std::string>(&it->second);
+            if (state != nullptr)
             {
-                const std::string* state =
-                    std::get_if<std::string>(&it->second);
-                if (state != nullptr)
+                // The short strings "BootComplete" and "Standby" are
+                // deprecated in favor of the full enum strings
+                // Support for the short strings will be removed in the
+                // future.
+                if (((*state == "BootComplete") ||
+                     (*state == "xyz.openbmc_project.State.OperatingSystem."
+                                "Status.OSStatus.BootComplete") ||
+                     (*state == "Inactive") ||
+                     (*state == "xyz.openbmc_project.State.OperatingSystem."
+                                "Status.OSStatus.Inactive")) &&
+                    (stateTimerRunning))
                 {
-                    // The short strings "BootComplete" and "Standby" are
-                    // deprecated in favor of the full enum strings
-                    // Support for the short strings will be removed in the
-                    // future.
-                    if (((*state == "BootComplete") ||
-                         (*state == "xyz.openbmc_project.State.OperatingSystem."
-                                    "Status.OSStatus.BootComplete") ||
-                         (*state == "Inactive") ||
-                         (*state == "xyz.openbmc_project.State.OperatingSystem."
-                                    "Status.OSStatus.Inactive")) &&
-                        (stateTimerRunning))
-                    {
-                        stateTimer->cancel();
-                        checkAndLogEvents(conn);
-                        stateTimerRunning = false;
-                    }
-                    else if (!stateTimerRunning)
-                    {
-                        stateTimerRunning = true;
-                        monitorPlatformStateChange(server, conn);
-                    }
+                    stateTimer->cancel();
+                    checkAndLogEvents(conn);
+                    stateTimerRunning = false;
+                }
+                else if (!stateTimerRunning)
+                {
+                    stateTimerRunning = true;
+                    monitorPlatformStateChange(server, conn);
                 }
             }
+        }
         });
 
     // First time, check and log events if any.
@@ -560,13 +556,13 @@
     lg2::info("VERSION INFO - cpld_active - {VER}", "VER", cpldVersion);
     conn->async_method_call(
         [](const boost::system::error_code ec) {
-            if (ec)
-            {
-                phosphor::logging::log<phosphor::logging::level::ERR>(
-                    "Unable to update cpld_active version",
-                    phosphor::logging::entry("MSG=%s", ec.message().c_str()));
-                return;
-            }
+        if (ec)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "Unable to update cpld_active version",
+                phosphor::logging::entry("MSG=%s", ec.message().c_str()));
+            return;
+        }
         },
         "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/software/cpld_active",
@@ -627,8 +623,8 @@
 
     constexpr size_t timeout = 10; // seconds
     pfrObjTimer->expires_after(std::chrono::seconds(timeout));
-    pfrObjTimer->async_wait([&conn,
-                             &server](const boost::system::error_code& ec) {
+    pfrObjTimer->async_wait(
+        [&conn, &server](const boost::system::error_code& ec) {
         if (ec)
         {
             if (ec == boost::asio::error::operation_aborted)
@@ -695,8 +691,8 @@
         pfr::pfrConfigObject->updateProvisioningStatus();
         if (pfr::pfrConfigObject->getPfrProvisioned())
         {
-            pfr::pfrPostcodeObject =
-                std::make_unique<pfr::PfrPostcode>(server, conn);
+            pfr::pfrPostcodeObject = std::make_unique<pfr::PfrPostcode>(server,
+                                                                        conn);
         }
     }