diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index e43058e..47c9ecf 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -28,9 +28,9 @@
 {
 namespace platform
 {
-using generatePDR = std::function<void(const pldm::utils::DBusHandler& dBusIntf,
-                                       const pldm::utils::Json& json,
-                                       pdr_utils::RepoInterface& repo)>;
+using generatePDR = std::function<void(
+    const pldm::utils::DBusHandler& dBusIntf, const pldm::utils::Json& json,
+    pdr_utils::RepoInterface& repo)>;
 
 using EffecterId = uint16_t;
 using DbusObjMaps =
@@ -58,8 +58,7 @@
             pldm::requester::Handler<pldm::requester::Request>* handler,
             sdeventplus::Event& event, bool buildPDRLazily = false,
             const std::optional<EventMap>& addOnHandlersMap = std::nullopt) :
-        eid(eid),
-        instanceIdDb(instanceIdDb), pdrRepo(repo),
+        eid(eid), instanceIdDb(instanceIdDb), pdrRepo(repo),
         hostPDRHandler(hostPDRHandler),
         dbusToPLDMEventHandler(dbusToPLDMEventHandler), fruHandler(fruHandler),
         dBusIntf(dBusIntf), platformConfigHandler(platformConfigHandler),
@@ -76,47 +75,48 @@
         handlers.emplace(
             PLDM_GET_PDR,
             [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
-            return this->getPDR(request, payloadLength);
-        });
+                return this->getPDR(request, payloadLength);
+            });
         handlers.emplace(
             PLDM_SET_NUMERIC_EFFECTER_VALUE,
             [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
-            return this->setNumericEffecterValue(request, payloadLength);
-        });
+                return this->setNumericEffecterValue(request, payloadLength);
+            });
         handlers.emplace(
             PLDM_GET_NUMERIC_EFFECTER_VALUE,
             [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
-            return this->getNumericEffecterValue(request, payloadLength);
-        });
+                return this->getNumericEffecterValue(request, payloadLength);
+            });
         handlers.emplace(
             PLDM_SET_STATE_EFFECTER_STATES,
             [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
-            return this->setStateEffecterStates(request, payloadLength);
-        });
+                return this->setStateEffecterStates(request, payloadLength);
+            });
         handlers.emplace(
             PLDM_PLATFORM_EVENT_MESSAGE,
             [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
-            return this->platformEventMessage(request, payloadLength);
-        });
+                return this->platformEventMessage(request, payloadLength);
+            });
         handlers.emplace(
             PLDM_GET_STATE_SENSOR_READINGS,
             [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
-            return this->getStateSensorReadings(request, payloadLength);
-        });
+                return this->getStateSensorReadings(request, payloadLength);
+            });
 
         // Default handler for PLDM Events
         eventHandlers[PLDM_SENSOR_EVENT].emplace_back(
             [this](const pldm_msg* request, size_t payloadLength,
                    uint8_t formatVersion, uint8_t tid, size_t eventDataOffset) {
-            return this->sensorEvent(request, payloadLength, formatVersion, tid,
-                                     eventDataOffset);
-        });
+                return this->sensorEvent(request, payloadLength, formatVersion,
+                                         tid, eventDataOffset);
+            });
         eventHandlers[PLDM_PDR_REPOSITORY_CHG_EVENT].emplace_back(
             [this](const pldm_msg* request, size_t payloadLength,
                    uint8_t formatVersion, uint8_t tid, size_t eventDataOffset) {
-            return this->pldmPDRRepositoryChgEvent(
-                request, payloadLength, formatVersion, tid, eventDataOffset);
-        });
+                return this->pldmPDRRepositoryChgEvent(
+                    request, payloadLength, formatVersion, tid,
+                    eventDataOffset);
+            });
 
         // Additional OEM event handlers for PLDM events, append it to the
         // standard handlers
@@ -359,8 +359,8 @@
             if (pdr->effecter_id != effecterId)
             {
                 pdr = nullptr;
-                pdrRecord = stateEffecterPDRs.getNextRecord(pdrRecord,
-                                                            pdrEntry);
+                pdrRecord =
+                    stateEffecterPDRs.getNextRecord(pdrRecord, pdrEntry);
                 continue;
             }
 
@@ -385,15 +385,15 @@
         int rc = PLDM_SUCCESS;
         try
         {
-            const auto& [dbusMappings,
-                         dbusValMaps] = effecterDbusObjMaps.at(effecterId);
+            const auto& [dbusMappings, dbusValMaps] =
+                effecterDbusObjMaps.at(effecterId);
             for (uint8_t currState = 0; currState < compEffecterCnt;
                  ++currState)
             {
                 std::vector<StateSetNum> allowed{};
                 // computation is based on table 79 from DSP0248 v1.1.1
-                uint8_t bitfieldIndex = stateField[currState].effecter_state /
-                                        8;
+                uint8_t bitfieldIndex =
+                    stateField[currState].effecter_state / 8;
                 uint8_t bit = stateField[currState].effecter_state -
                               (8 * bitfieldIndex);
                 if (states->possible_states_size < bitfieldIndex ||
