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: I844971bd190187ba9ef2e8cf16809e2d16317ec4
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index abedc25..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
@@ -49,6 +52,7 @@
 ConstructorInitializerIndentWidth: 4
 ContinuationIndentWidth: 4
 Cpp11BracedListStyle: true
+DeriveLineEnding: false
 DerivePointerAlignment: false
 PointerAlignment: Left
 DisableFormat:   false
@@ -74,9 +78,13 @@
   - Regex:           '.*'
     Priority:        6
 IndentCaseLabels: true
+IndentRequiresClause: true
 IndentWidth:     4
 IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
 MaxEmptyLinesToKeep: 1
@@ -84,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
@@ -112,3 +126,4 @@
 TabWidth:        4
 UseTab:          Never
 ...
+
diff --git a/src/power_control.cpp b/src/power_control.cpp
index 1a89323..0dafd60 100644
--- a/src/power_control.cpp
+++ b/src/power_control.cpp
@@ -199,13 +199,13 @@
 
     conn->async_method_call(
         [](boost::system::error_code ec) {
-            if (ec)
-            {
-                lg2::error(
-                    "beep returned error with async_method_call (ec = {ERROR_MSG})",
-                    "ERROR_MSG", ec.message());
-                return;
-            }
+        if (ec)
+        {
+            lg2::error(
+                "beep returned error with async_method_call (ec = {ERROR_MSG})",
+                "ERROR_MSG", ec.message());
+            return;
+        }
         },
         "xyz.openbmc_project.BeepCode", "/xyz/openbmc_project/BeepCode",
         "xyz.openbmc_project.BeepCode", "Beep", uint8_t(beepPriority));
@@ -675,10 +675,10 @@
     {
         conn->async_method_call(
             [](boost::system::error_code ec) {
-                if (ec)
-                {
-                    lg2::error("failed to reset ACBoot property");
-                }
+            if (ec)
+            {
+                lg2::error("failed to reset ACBoot property");
+            }
             },
             "xyz.openbmc_project.Settings",
             "/xyz/openbmc_project/control/host0/ac_boot",
@@ -877,13 +877,13 @@
     appStateStream << stateData.dump(indentationSize);
 }
 
-static constexpr char const* setingsService = "xyz.openbmc_project.Settings";
-static constexpr char const* powerRestorePolicyIface =
+static constexpr const char* setingsService = "xyz.openbmc_project.Settings";
+static constexpr const char* powerRestorePolicyIface =
     "xyz.openbmc_project.Control.Power.RestorePolicy";
 #ifdef USE_ACBOOT
-static constexpr char const* powerACBootObject =
+static constexpr const char* powerACBootObject =
     "/xyz/openbmc_project/control/host0/ac_boot";
-static constexpr char const* powerACBootIface =
+static constexpr const char* powerACBootIface =
     "xyz.openbmc_project.Common.ACBoot";
 #endif // USE_ACBOOT
 
@@ -933,8 +933,8 @@
 
 void PowerRestoreController::run()
 {
-    std::string powerRestorePolicyObject =
-        "/xyz/openbmc_project/control/host" + node + "/power_restore_policy";
+    std::string powerRestorePolicyObject = "/xyz/openbmc_project/control/host" +
+                                           node + "/power_restore_policy";
     powerRestorePolicyLog();
     // this list only needs to be created once
     if (matches.empty())
@@ -963,11 +963,11 @@
     conn->async_method_call(
         [this](boost::system::error_code ec,
                const dbusPropertiesList properties) {
-            if (ec)
-            {
-                return;
-            }
-            setProperties(properties);
+        if (ec)
+        {
+            return;
+        }
+        setProperties(properties);
         },
         setingsService, powerRestorePolicyObject,
         "org.freedesktop.DBus.Properties", "GetAll", powerRestorePolicyIface);
@@ -977,11 +977,11 @@
     conn->async_method_call(
         [this](boost::system::error_code ec,
                const dbusPropertiesList properties) {
-            if (ec)
-            {
-                return;
-            }
-            setProperties(properties);
+        if (ec)
+        {
+            return;
+        }
+        setProperties(properties);
         },
         setingsService, powerACBootObject, "org.freedesktop.DBus.Properties",
         "GetAll", powerACBootIface);
@@ -1060,8 +1060,8 @@
             powerRestoreTimer.expires_after(std::chrono::seconds(delay));
             lg2::info("Power Restore delay of {DELAY} seconds started", "DELAY",
                       delay);
-            powerRestoreTimer.async_wait([this](const boost::system::error_code
-                                                    ec) {
+            powerRestoreTimer.async_wait(
+                [this](const boost::system::error_code ec) {
                 if (ec)
                 {
                     // operation_aborted is expected if timer is canceled before
@@ -1140,20 +1140,18 @@
     event.async_wait(boost::asio::posix::stream_descriptor::wait_read,
                      [&name, eventHandler, &line,
                       &event](const boost::system::error_code ec) {
-                         if (ec)
-                         {
-                             lg2::error(
-                                 "{GPIO_NAME} fd handler error: {ERROR_MSG}",
-                                 "GPIO_NAME", name, "ERROR_MSG", ec.message());
-                             // TODO: throw here to force power-control to
-                             // restart?
-                             return;
-                         }
-                         gpiod::line_event line_event = line.event_read();
-                         eventHandler(line_event.event_type ==
-                                      gpiod::line_event::RISING_EDGE);
-                         waitForGPIOEvent(name, eventHandler, line, event);
-                     });
+        if (ec)
+        {
+            lg2::error("{GPIO_NAME} fd handler error: {ERROR_MSG}", "GPIO_NAME",
+                       name, "ERROR_MSG", ec.message());
+            // TODO: throw here to force power-control to
+            // restart?
+            return;
+        }
+        gpiod::line_event line_event = line.event_read();
+        eventHandler(line_event.event_type == gpiod::line_event::RISING_EDGE);
+        waitForGPIOEvent(name, eventHandler, line, event);
+    });
 }
 
 static bool requestGPIOEvents(
@@ -1233,20 +1231,20 @@
     gpioAssertTimer.expires_after(std::chrono::milliseconds(durationMs));
     gpioAssertTimer.async_wait(
         [maskedGPIOLine, value, name](const boost::system::error_code ec) {
-            // Set the masked GPIO line back to the opposite value
-            maskedGPIOLine.set_value(!value);
-            lg2::info("{GPIO_NAME} released", "GPIO_NAME", name);
-            if (ec)
+        // Set the masked GPIO line back to the opposite value
+        maskedGPIOLine.set_value(!value);
+        lg2::info("{GPIO_NAME} released", "GPIO_NAME", name);
+        if (ec)
+        {
+            // operation_aborted is expected if timer is canceled before
+            // completion.
+            if (ec != boost::asio::error::operation_aborted)
             {
-                // operation_aborted is expected if timer is canceled before
-                // completion.
-                if (ec != boost::asio::error::operation_aborted)
-                {
-                    lg2::error("{GPIO_NAME} async_wait failed: {ERROR_MSG}",
-                               "GPIO_NAME", name, "ERROR_MSG", ec.message());
-                }
+                lg2::error("{GPIO_NAME} async_wait failed: {ERROR_MSG}",
+                           "GPIO_NAME", name, "ERROR_MSG", ec.message());
             }
-        });
+        }
+    });
     return 0;
 }
 
@@ -1276,20 +1274,20 @@
     gpioAssertTimer.expires_after(std::chrono::milliseconds(durationMs));
     gpioAssertTimer.async_wait(
         [gpioLine, value, name](const boost::system::error_code ec) {
-            // Set the GPIO line back to the opposite value
-            gpioLine.set_value(!value);
-            lg2::info("{GPIO_NAME} released", "GPIO_NAME", name);
-            if (ec)
+        // Set the GPIO line back to the opposite value
+        gpioLine.set_value(!value);
+        lg2::info("{GPIO_NAME} released", "GPIO_NAME", name);
+        if (ec)
+        {
+            // operation_aborted is expected if timer is canceled before
+            // completion.
+            if (ec != boost::asio::error::operation_aborted)
             {
-                // operation_aborted is expected if timer is canceled before
-                // completion.
-                if (ec != boost::asio::error::operation_aborted)
-                {
-                    lg2::error("{GPIO_NAME} async_wait failed: {ERROR_MSG}",
-                               "GPIO_NAME", name, "ERROR_MSG", ec.message());
-                }
+                lg2::error("{GPIO_NAME} async_wait failed: {ERROR_MSG}",
+                           "GPIO_NAME", name, "ERROR_MSG", ec.message());
             }
-        });
+        }
+    });
     return 0;
 }
 
@@ -1307,7 +1305,6 @@
 {
     if (power_control::slotPowerState != power_control::SlotPowerState::on)
     {
-
         slotPowerLine.set_value(1);
 
         if (slotPowerLine.get_value() > 0)
@@ -1531,31 +1528,31 @@
         conn->async_method_call(
             [](boost::system::error_code ec,
                const std::variant<uint32_t>& pohCounterProperty) {
+            if (ec)
+            {
+                lg2::error("error getting poh counter");
+                return;
+            }
+            const uint32_t* pohCounter =
+                std::get_if<uint32_t>(&pohCounterProperty);
+            if (pohCounter == nullptr)
+            {
+                lg2::error("unable to read poh counter");
+                return;
+            }
+
+            conn->async_method_call(
+                [](boost::system::error_code ec) {
                 if (ec)
                 {
-                    lg2::error("error getting poh counter");
-                    return;
+                    lg2::error("failed to set poh counter");
                 }
-                const uint32_t* pohCounter =
-                    std::get_if<uint32_t>(&pohCounterProperty);
-                if (pohCounter == nullptr)
-                {
-                    lg2::error("unable to read poh counter");
-                    return;
-                }
-
-                conn->async_method_call(
-                    [](boost::system::error_code ec) {
-                        if (ec)
-                        {
-                            lg2::error("failed to set poh counter");
-                        }
-                    },
-                    "xyz.openbmc_project.Settings",
-                    "/xyz/openbmc_project/state/chassis0",
-                    "org.freedesktop.DBus.Properties", "Set",
-                    "xyz.openbmc_project.State.PowerOnHours", "POHCounter",
-                    std::variant<uint32_t>(*pohCounter + 1));
+                },
+                "xyz.openbmc_project.Settings",
+                "/xyz/openbmc_project/state/chassis0",
+                "org.freedesktop.DBus.Properties", "Set",
+                "xyz.openbmc_project.State.PowerOnHours", "POHCounter",
+                std::variant<uint32_t>(*pohCounter + 1));
             },
             "xyz.openbmc_project.Settings",
             "/xyz/openbmc_project/state/chassis0",
@@ -1582,75 +1579,73 @@
         setRestartCause();
     }
 
-    static auto match = sdbusplus::bus::match_t(
-        *conn,
-        "type='signal',member='PropertiesChanged', "
-        "interface='org.freedesktop.DBus.Properties', "
-        "arg0='xyz.openbmc_project.State.Host'",
-        [](sdbusplus::message_t& message) {
-            std::string intfName;
-            std::map<std::string, std::variant<std::string>> properties;
+    static auto match =
+        sdbusplus::bus::match_t(*conn,
+                                "type='signal',member='PropertiesChanged', "
+                                "interface='org.freedesktop.DBus.Properties', "
+                                "arg0='xyz.openbmc_project.State.Host'",
+                                [](sdbusplus::message_t& message) {
+        std::string intfName;
+        std::map<std::string, std::variant<std::string>> properties;
 
-            try
-            {
-                message.read(intfName, properties);
-            }
-            catch (const std::exception& e)
-            {
-                lg2::error("Unable to read host state: {ERROR}", "ERROR", e);
-                return;
-            }
-            if (properties.empty())
-            {
-                lg2::error("ERROR: Empty PropertiesChanged signal received");
-                return;
-            }
+        try
+        {
+            message.read(intfName, properties);
+        }
+        catch (const std::exception& e)
+        {
+            lg2::error("Unable to read host state: {ERROR}", "ERROR", e);
+            return;
+        }
+        if (properties.empty())
+        {
+            lg2::error("ERROR: Empty PropertiesChanged signal received");
+            return;
+        }
 
-            // We only want to check for CurrentHostState
-            if (properties.begin()->first != "CurrentHostState")
-            {
-                return;
-            }
-            std::string* currentHostState =
-                std::get_if<std::string>(&(properties.begin()->second));
-            if (currentHostState == nullptr)
-            {
-                lg2::error("{PROPERTY} property invalid", "PROPERTY",
-                           properties.begin()->first);
-                return;
-            }
+        // We only want to check for CurrentHostState
+        if (properties.begin()->first != "CurrentHostState")
+        {
+            return;
+        }
+        std::string* currentHostState =
+            std::get_if<std::string>(&(properties.begin()->second));
+        if (currentHostState == nullptr)
+        {
+            lg2::error("{PROPERTY} property invalid", "PROPERTY",
+                       properties.begin()->first);
+            return;
+        }
 
-            if (*currentHostState ==
-                "xyz.openbmc_project.State.Host.HostState.Running")
-            {
-                pohCounterTimerStart();
-                // Clear the restart cause set for the next restart
-                clearRestartCause();
-                sd_journal_send("MESSAGE=Host system DC power is on",
-                                "PRIORITY=%i", LOG_INFO,
-                                "REDFISH_MESSAGE_ID=%s",
-                                "OpenBMC.0.1.DCPowerOn", NULL);
-            }
-            else
-            {
-                pohCounterTimer.cancel();
-                // POST_COMPLETE GPIO event is not working in some platforms
-                // when power state is changed to OFF. This resulted in
-                // 'OperatingSystemState' to stay at 'Standby', even though
-                // system is OFF. Set 'OperatingSystemState' to 'Inactive'
-                // if HostState is trurned to OFF.
-                setOperatingSystemState(OperatingSystemStateStage::Inactive);
+        if (*currentHostState ==
+            "xyz.openbmc_project.State.Host.HostState.Running")
+        {
+            pohCounterTimerStart();
+            // Clear the restart cause set for the next restart
+            clearRestartCause();
+            sd_journal_send("MESSAGE=Host system DC power is on", "PRIORITY=%i",
+                            LOG_INFO, "REDFISH_MESSAGE_ID=%s",
+                            "OpenBMC.0.1.DCPowerOn", NULL);
+        }
+        else
+        {
+            pohCounterTimer.cancel();
+            // POST_COMPLETE GPIO event is not working in some platforms
+            // when power state is changed to OFF. This resulted in
+            // 'OperatingSystemState' to stay at 'Standby', even though
+            // system is OFF. Set 'OperatingSystemState' to 'Inactive'
+            // if HostState is trurned to OFF.
+            setOperatingSystemState(OperatingSystemStateStage::Inactive);
 
-                // Set the restart cause set for this restart
-                setRestartCause();
+            // Set the restart cause set for this restart
+            setRestartCause();
 #ifdef USE_ACBOOT
-                resetACBootProperty();
+            resetACBootProperty();
 #endif // USE_ACBOOT
-                sd_journal_send("MESSAGE=Host system DC power is off",
-                                "PRIORITY=%i", LOG_INFO,
-                                "REDFISH_MESSAGE_ID=%s",
-                                "OpenBMC.0.1.DCPowerOff", NULL);
-            }
+            sd_journal_send("MESSAGE=Host system DC power is off",
+                            "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s",
+                            "OpenBMC.0.1.DCPowerOff", NULL);
+        }
         });
 }
 
@@ -1659,8 +1654,8 @@
     lg2::info("SIO power good watchdog timer started");
     sioPowerGoodWatchdogTimer.expires_after(
         std::chrono::milliseconds(TimerMap["SioPowerGoodWatchdogMs"]));
-    sioPowerGoodWatchdogTimer.async_wait([](const boost::system::error_code
-                                                ec) {
+    sioPowerGoodWatchdogTimer.async_wait(
+        [](const boost::system::error_code ec) {
         if (ec)
         {
             // operation_aborted is expected if timer is canceled before
@@ -2007,15 +2002,15 @@
 
 static void psPowerOKHandler(bool state)
 {
-    Event powerControlEvent =
-        state ? Event::psPowerOKAssert : Event::psPowerOKDeAssert;
+    Event powerControlEvent = state ? Event::psPowerOKAssert
+                                    : Event::psPowerOKDeAssert;
     sendPowerControlEvent(powerControlEvent);
 }
 
 static void sioPowerGoodHandler(bool state)
 {
-    Event powerControlEvent =
-        state ? Event::sioPowerGoodAssert : Event::sioPowerGoodDeAssert;
+    Event powerControlEvent = state ? Event::sioPowerGoodAssert
+                                    : Event::sioPowerGoodDeAssert;
     sendPowerControlEvent(powerControlEvent);
 }
 
@@ -2077,11 +2072,11 @@
 {
     conn->async_method_call(
         [](boost::system::error_code ec) {
-            if (ec)
-            {
-                lg2::error("Failed to call chassis system reset: {ERR}", "ERR",
-                           ec.message());
-            }
+        if (ec)
+        {
+            lg2::error("Failed to call chassis system reset: {ERR}", "ERR",
+                       ec.message());
+        }
         },
         systemdBusname, systemdPath, systemdInterface, "StartUnit",
         systemTargetName, "replace");
@@ -2092,10 +2087,10 @@
 {
     conn->async_method_call(
         [](boost::system::error_code ec) {
-            if (ec)
-            {
-                lg2::error("failed to set NMI source");
-            }
+        if (ec)
+        {
+            lg2::error("failed to set NMI source");
+        }
         },
         "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/Chassis/Control/NMISource",
@@ -2147,35 +2142,31 @@
             "member='PropertiesChanged',"
             "arg0namespace='xyz.openbmc_project.Chassis.Control.NMISource'",
             [](sdbusplus::message_t& msg) {
-                std::string interfaceName;
-                boost::container::flat_map<std::string,
-                                           std::variant<bool, std::string>>
-                    propertiesChanged;
-                std::string state;
-                bool value = true;
-                try
+        std::string interfaceName;
+        boost::container::flat_map<std::string, std::variant<bool, std::string>>
+            propertiesChanged;
+        std::string state;
+        bool value = true;
+        try
+        {
+            msg.read(interfaceName, propertiesChanged);
+            if (propertiesChanged.begin()->first == "Enabled")
+            {
+                value = std::get<bool>(propertiesChanged.begin()->second);
+                lg2::info("NMI Enabled propertiesChanged value: {VALUE}",
+                          "VALUE", value);
+                nmiEnabled = value;
+                if (nmiEnabled)
                 {
-                    msg.read(interfaceName, propertiesChanged);
-                    if (propertiesChanged.begin()->first == "Enabled")
-                    {
-                        value =
-                            std::get<bool>(propertiesChanged.begin()->second);
-                        lg2::info(
-                            "NMI Enabled propertiesChanged value: {VALUE}",
-                            "VALUE", value);
-                        nmiEnabled = value;
-                        if (nmiEnabled)
-                        {
-                            nmiReset();
-                        }
-                    }
+                    nmiReset();
                 }
-                catch (const std::exception& e)
-                {
-                    lg2::error("Unable to read NMI source: {ERROR}", "ERROR",
-                               e);
-                    return;
-                }
+            }
+        }
+        catch (const std::exception& e)
+        {
+            lg2::error("Unable to read NMI source: {ERROR}", "ERROR", e);
+            return;
+        }
             });
 }
 
@@ -2183,10 +2174,10 @@
 {
     conn->async_method_call(
         [](boost::system::error_code ec) {
-            if (ec)
-            {
-                lg2::error("failed to set NMI source");
-            }
+        if (ec)
+        {
+            lg2::error("failed to set NMI source");
+        }
         },
         "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/Chassis/Control/NMISource",
@@ -2463,8 +2454,8 @@
 static sdbusplus::bus::match_t
     dbusGPIOMatcher(const ConfigData& cfg, std::function<void(bool)> onMatch)
 {
-    auto pulseEventMatcherCallback = [&cfg,
-                                      onMatch](sdbusplus::message_t& msg) {
+    auto pulseEventMatcherCallback =
+        [&cfg, onMatch](sdbusplus::message_t& msg) {
         bool value = false;
         if (!getDbusMsgGPIOState(msg, cfg.lineName, value))
         {
@@ -2578,7 +2569,6 @@
     }
     else if (powerOkConfig.type == ConfigType::DBUS)
     {
-
         static sdbusplus::bus::match_t powerOkEventMonitor =
             power_control::dbusGPIOMatcher(powerOkConfig, psPowerOKHandler);
     }
@@ -2834,95 +2824,92 @@
         "RequestedHostTransition",
         std::string("xyz.openbmc_project.State.Host.Transition.Off"),
         [](const std::string& requested, std::string& resp) {
-            if (requested == "xyz.openbmc_project.State.Host.Transition.Off")
+        if (requested == "xyz.openbmc_project.State.Host.Transition.Off")
+        {
+            // if power button is masked, ignore this
+            if (!powerButtonMask)
             {
-                // if power button is masked, ignore this
-                if (!powerButtonMask)
-                {
-                    sendPowerControlEvent(Event::gracefulPowerOffRequest);
-                    addRestartCause(RestartCause::command);
-                }
-                else
-                {
-                    lg2::info("Power Button Masked.");
-                    throw std::invalid_argument("Transition Request Masked");
-                    return 0;
-                }
-            }
-            else if (requested ==
-                     "xyz.openbmc_project.State.Host.Transition.On")
-            {
-                // if power button is masked, ignore this
-                if (!powerButtonMask)
-                {
-                    sendPowerControlEvent(Event::powerOnRequest);
-                    addRestartCause(RestartCause::command);
-                }
-                else
-                {
-                    lg2::info("Power Button Masked.");
-                    throw std::invalid_argument("Transition Request Masked");
-                    return 0;
-                }
-            }
-            else if (requested ==
-                     "xyz.openbmc_project.State.Host.Transition.Reboot")
-            {
-                // if power button is masked, ignore this
-                if (!powerButtonMask)
-                {
-                    sendPowerControlEvent(Event::powerCycleRequest);
-                    addRestartCause(RestartCause::command);
-                }
-                else
-                {
-                    lg2::info("Power Button Masked.");
-                    throw std::invalid_argument("Transition Request Masked");
-                    return 0;
-                }
-            }
-            else if (
-                requested ==
-                "xyz.openbmc_project.State.Host.Transition.GracefulWarmReboot")
-            {
-                // if reset button is masked, ignore this
-                if (!resetButtonMask)
-                {
-                    sendPowerControlEvent(Event::gracefulPowerCycleRequest);
-                    addRestartCause(RestartCause::command);
-                }
-                else
-                {
-                    lg2::info("Reset Button Masked.");
-                    throw std::invalid_argument("Transition Request Masked");
-                    return 0;
-                }
-            }
-            else if (
-                requested ==
-                "xyz.openbmc_project.State.Host.Transition.ForceWarmReboot")
-            {
-                // if reset button is masked, ignore this
-                if (!resetButtonMask)
-                {
-                    sendPowerControlEvent(Event::resetRequest);
-                    addRestartCause(RestartCause::command);
-                }
-                else
-                {
-                    lg2::info("Reset Button Masked.");
-                    throw std::invalid_argument("Transition Request Masked");
-                    return 0;
-                }
+                sendPowerControlEvent(Event::gracefulPowerOffRequest);
+                addRestartCause(RestartCause::command);
             }
             else
             {
-                lg2::error("Unrecognized host state transition request.");
-                throw std::invalid_argument("Unrecognized Transition Request");
+                lg2::info("Power Button Masked.");
+                throw std::invalid_argument("Transition Request Masked");
                 return 0;
             }
-            resp = requested;
-            return 1;
+        }
+        else if (requested == "xyz.openbmc_project.State.Host.Transition.On")
+        {
+            // if power button is masked, ignore this
+            if (!powerButtonMask)
+            {
+                sendPowerControlEvent(Event::powerOnRequest);
+                addRestartCause(RestartCause::command);
+            }
+            else
+            {
+                lg2::info("Power Button Masked.");
+                throw std::invalid_argument("Transition Request Masked");
+                return 0;
+            }
+        }
+        else if (requested ==
+                 "xyz.openbmc_project.State.Host.Transition.Reboot")
+        {
+            // if power button is masked, ignore this
+            if (!powerButtonMask)
+            {
+                sendPowerControlEvent(Event::powerCycleRequest);
+                addRestartCause(RestartCause::command);
+            }
+            else
+            {
+                lg2::info("Power Button Masked.");
+                throw std::invalid_argument("Transition Request Masked");
+                return 0;
+            }
+        }
+        else if (requested ==
+                 "xyz.openbmc_project.State.Host.Transition.GracefulWarmReboot")
+        {
+            // if reset button is masked, ignore this
+            if (!resetButtonMask)
+            {
+                sendPowerControlEvent(Event::gracefulPowerCycleRequest);
+                addRestartCause(RestartCause::command);
+            }
+            else
+            {
+                lg2::info("Reset Button Masked.");
+                throw std::invalid_argument("Transition Request Masked");
+                return 0;
+            }
+        }
+        else if (requested ==
+                 "xyz.openbmc_project.State.Host.Transition.ForceWarmReboot")
+        {
+            // if reset button is masked, ignore this
+            if (!resetButtonMask)
+            {
+                sendPowerControlEvent(Event::resetRequest);
+                addRestartCause(RestartCause::command);
+            }
+            else
+            {
+                lg2::info("Reset Button Masked.");
+                throw std::invalid_argument("Transition Request Masked");
+                return 0;
+            }
+        }
+        else
+        {
+            lg2::error("Unrecognized host state transition request.");
+            throw std::invalid_argument("Unrecognized Transition Request");
+            return 0;
+        }
+        resp = requested;
+        return 1;
         });
     hostIface->register_property("CurrentHostState",
                                  std::string(getHostState(powerState)));
@@ -2942,61 +2929,60 @@
         "RequestedPowerTransition",
         std::string("xyz.openbmc_project.State.Chassis.Transition.Off"),
         [](const std::string& requested, std::string& resp) {
-            if (requested == "xyz.openbmc_project.State.Chassis.Transition.Off")
+        if (requested == "xyz.openbmc_project.State.Chassis.Transition.Off")
+        {
+            // if power button is masked, ignore this
+            if (!powerButtonMask)
             {
-                // if power button is masked, ignore this
-                if (!powerButtonMask)
-                {
-                    sendPowerControlEvent(Event::powerOffRequest);
-                    addRestartCause(RestartCause::command);
-                }
-                else
-                {
-                    lg2::info("Power Button Masked.");
-                    throw std::invalid_argument("Transition Request Masked");
-                    return 0;
-                }
-            }
-            else if (requested ==
-                     "xyz.openbmc_project.State.Chassis.Transition.On")
-            {
-                // if power button is masked, ignore this
-                if (!powerButtonMask)
-                {
-                    sendPowerControlEvent(Event::powerOnRequest);
-                    addRestartCause(RestartCause::command);
-                }
-                else
-                {
-                    lg2::info("Power Button Masked.");
-                    throw std::invalid_argument("Transition Request Masked");
-                    return 0;
-                }
-            }
-            else if (requested ==
-                     "xyz.openbmc_project.State.Chassis.Transition.PowerCycle")
-            {
-                // if power button is masked, ignore this
-                if (!powerButtonMask)
-                {
-                    sendPowerControlEvent(Event::powerCycleRequest);
-                    addRestartCause(RestartCause::command);
-                }
-                else
-                {
-                    lg2::info("Power Button Masked.");
-                    throw std::invalid_argument("Transition Request Masked");
-                    return 0;
-                }
+                sendPowerControlEvent(Event::powerOffRequest);
+                addRestartCause(RestartCause::command);
             }
             else
             {
-                lg2::error("Unrecognized chassis state transition request.");
-                throw std::invalid_argument("Unrecognized Transition Request");
+                lg2::info("Power Button Masked.");
+                throw std::invalid_argument("Transition Request Masked");
                 return 0;
             }
-            resp = requested;
-            return 1;
+        }
+        else if (requested == "xyz.openbmc_project.State.Chassis.Transition.On")
+        {
+            // if power button is masked, ignore this
+            if (!powerButtonMask)
+            {
+                sendPowerControlEvent(Event::powerOnRequest);
+                addRestartCause(RestartCause::command);
+            }
+            else
+            {
+                lg2::info("Power Button Masked.");
+                throw std::invalid_argument("Transition Request Masked");
+                return 0;
+            }
+        }
+        else if (requested ==
+                 "xyz.openbmc_project.State.Chassis.Transition.PowerCycle")
+        {
+            // if power button is masked, ignore this
+            if (!powerButtonMask)
+            {
+                sendPowerControlEvent(Event::powerCycleRequest);
+                addRestartCause(RestartCause::command);
+            }
+            else
+            {
+                lg2::info("Power Button Masked.");
+                throw std::invalid_argument("Transition Request Masked");
+                return 0;
+            }
+        }
+        else
+        {
+            lg2::error("Unrecognized chassis state transition request.");
+            throw std::invalid_argument("Unrecognized Transition Request");
+            return 0;
+        }
+        resp = requested;
+        return 1;
         });
     chassisIface->register_property("CurrentPowerState",
                                     std::string(getChassisState(powerState)));
@@ -3018,21 +3004,20 @@
         "RequestedPowerTransition",
         std::string("xyz.openbmc_project.State.Chassis.Transition.On"),
         [](const std::string& requested, std::string& resp) {
-            if (requested ==
-                "xyz.openbmc_project.State.Chassis.Transition.PowerCycle")
-            {
-                systemReset();
-                addRestartCause(RestartCause::command);
-            }
-            else
-            {
-                lg2::error(
-                    "Unrecognized chassis system state transition request.");
-                throw std::invalid_argument("Unrecognized Transition Request");
-                return 0;
-            }
-            resp = requested;
-            return 1;
+        if (requested ==
+            "xyz.openbmc_project.State.Chassis.Transition.PowerCycle")
+        {
+            systemReset();
+            addRestartCause(RestartCause::command);
+        }
+        else
+        {
+            lg2::error("Unrecognized chassis system state transition request.");
+            throw std::invalid_argument("Unrecognized Transition Request");
+            return 0;
+        }
+        resp = requested;
+        return 1;
         });
     chassisSysIface->register_property(
         "CurrentPowerState", std::string(getChassisState(powerState)));
@@ -3061,32 +3046,29 @@
             "RequestedPowerTransition",
             std::string("xyz.openbmc_project.State.Chassis.Transition.On"),
             [](const std::string& requested, std::string& resp) {
-                if (requested ==
-                    "xyz.openbmc_project.State.Chassis.Transition.On")
-                {
-                    slotPowerOn();
-                }
-                else if (requested ==
-                         "xyz.openbmc_project.State.Chassis.Transition.Off")
-                {
-                    slotPowerOff();
-                }
-                else if (
-                    requested ==
-                    "xyz.openbmc_project.State.Chassis.Transition.PowerCycle")
-                {
-                    slotPowerCycle();
-                }
-                else
-                {
-                    lg2::error(
-                        "Unrecognized chassis system state transition request.\n");
-                    throw std::invalid_argument(
-                        "Unrecognized Transition Request");
-                    return 0;
-                }
-                resp = requested;
-                return 1;
+            if (requested == "xyz.openbmc_project.State.Chassis.Transition.On")
+            {
+                slotPowerOn();
+            }
+            else if (requested ==
+                     "xyz.openbmc_project.State.Chassis.Transition.Off")
+            {
+                slotPowerOff();
+            }
+            else if (requested ==
+                     "xyz.openbmc_project.State.Chassis.Transition.PowerCycle")
+            {
+                slotPowerCycle();
+            }
+            else
+            {
+                lg2::error(
+                    "Unrecognized chassis system state transition request.\n");
+                throw std::invalid_argument("Unrecognized Transition Request");
+                return 0;
+            }
+            resp = requested;
+            return 1;
             });
         chassisSlotIface->register_property(
             "CurrentPowerState", std::string(getSlotState(slotPowerState)));
@@ -3107,34 +3089,34 @@
             "xyz.openbmc_project.Chassis.Buttons");
 
         powerButtonIface->register_property(
-            "ButtonMasked", false, [](const bool requested, bool& current) {
-                if (requested)
+            "ButtonMasked", false,
+            [](const bool requested, bool& current) {
+            if (requested)
+            {
+                if (powerButtonMask)
                 {
-                    if (powerButtonMask)
-                    {
-                        return 1;
-                    }
-                    if (!setGPIOOutput(powerOutConfig.lineName,
-                                       !powerOutConfig.polarity,
-                                       powerButtonMask))
-                    {
-                        throw std::runtime_error("Failed to request GPIO");
-                        return 0;
-                    }
-                    lg2::info("Power Button Masked.");
+                    return 1;
                 }
-                else
+                if (!setGPIOOutput(powerOutConfig.lineName,
+                                   !powerOutConfig.polarity, powerButtonMask))
                 {
-                    if (!powerButtonMask)
-                    {
-                        return 1;
-                    }
-                    lg2::info("Power Button Un-masked");
-                    powerButtonMask.reset();
+                    throw std::runtime_error("Failed to request GPIO");
+                    return 0;
                 }
-                // Update the mask setting
-                current = requested;
-                return 1;
+                lg2::info("Power Button Masked.");
+            }
+            else
+            {
+                if (!powerButtonMask)
+                {
+                    return 1;
+                }
+                lg2::info("Power Button Un-masked");
+                powerButtonMask.reset();
+            }
+            // Update the mask setting
+            current = requested;
+            return 1;
             });
 
         // Check power button state
@@ -3163,34 +3145,34 @@
             "xyz.openbmc_project.Chassis.Buttons");
 
         resetButtonIface->register_property(
-            "ButtonMasked", false, [](const bool requested, bool& current) {
-                if (requested)
+            "ButtonMasked", false,
+            [](const bool requested, bool& current) {
+            if (requested)
+            {
+                if (resetButtonMask)
                 {
-                    if (resetButtonMask)
-                    {
-                        return 1;
-                    }
-                    if (!setGPIOOutput(resetOutConfig.lineName,
-                                       !resetOutConfig.polarity,
-                                       resetButtonMask))
-                    {
-                        throw std::runtime_error("Failed to request GPIO");
-                        return 0;
-                    }
-                    lg2::info("Reset Button Masked.");
+                    return 1;
                 }
-                else
+                if (!setGPIOOutput(resetOutConfig.lineName,
+                                   !resetOutConfig.polarity, resetButtonMask))
                 {
-                    if (!resetButtonMask)
-                    {
-                        return 1;
-                    }
-                    lg2::info("Reset Button Un-masked");
-                    resetButtonMask.reset();
+                    throw std::runtime_error("Failed to request GPIO");
+                    return 0;
                 }
-                // Update the mask setting
-                current = requested;
-                return 1;
+                lg2::info("Reset Button Masked.");
+            }
+            else
+            {
+                if (!resetButtonMask)
+                {
+                    return 1;
+                }
+                lg2::info("Reset Button Un-masked");
+                resetButtonMask.reset();
+            }
+            // Update the mask setting
+            current = requested;
+            return 1;
             });
 
         // Check reset button state
@@ -3341,22 +3323,21 @@
         "RequestedRestartCause",
         std::string("xyz.openbmc_project.State.Host.RestartCause.Unknown"),
         [](const std::string& requested, std::string& resp) {
-            if (requested ==
-                "xyz.openbmc_project.State.Host.RestartCause.WatchdogTimer")
-            {
-                addRestartCause(RestartCause::watchdog);
-            }
-            else
-            {
-                throw std::invalid_argument(
-                    "Unrecognized RestartCause Request");
-                return 0;
-            }
+        if (requested ==
+            "xyz.openbmc_project.State.Host.RestartCause.WatchdogTimer")
+        {
+            addRestartCause(RestartCause::watchdog);
+        }
+        else
+        {
+            throw std::invalid_argument("Unrecognized RestartCause Request");
+            return 0;
+        }
 
-            lg2::info("RestartCause requested: {RESTART_CAUSE}",
-                      "RESTART_CAUSE", requested);
-            resp = requested;
-            return 1;
+        lg2::info("RestartCause requested: {RESTART_CAUSE}", "RESTART_CAUSE",
+                  requested);
+        resp = requested;
+        return 1;
         });
 
     restartCauseIface->initialize();