diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 1e0955a..522899c 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -87,22 +87,23 @@
         {PLDM_STATE_EFFECTER_PDR,
          [this](const DBusHandler& dBusIntf, const auto& json,
                 RepoInterface& repo) {
-        pdr_state_effecter::generateStateEffecterPDR<pldm::utils::DBusHandler,
-                                                     Handler>(dBusIntf, json,
-                                                              *this, repo);
-    }},
+             pdr_state_effecter::generateStateEffecterPDR<
+                 pldm::utils::DBusHandler, Handler>(dBusIntf, json, *this,
+                                                    repo);
+         }},
         {PLDM_NUMERIC_EFFECTER_PDR,
          [this](const DBusHandler& dBusIntf, const auto& json,
                 RepoInterface& repo) {
-        pdr_numeric_effecter::generateNumericEffecterPDR<
-            pldm::utils::DBusHandler, Handler>(dBusIntf, json, *this, repo);
-    }},
+             pdr_numeric_effecter::generateNumericEffecterPDR<
+                 pldm::utils::DBusHandler, Handler>(dBusIntf, json, *this,
+                                                    repo);
+         }},
         {PLDM_STATE_SENSOR_PDR, [this](const DBusHandler& dBusIntf,
                                        const auto& json, RepoInterface& repo) {
-        pdr_state_sensor::generateStateSensorPDR<pldm::utils::DBusHandler,
-                                                 Handler>(dBusIntf, json, *this,
-                                                          repo);
-    }}};
+             pdr_state_sensor::generateStateSensorPDR<pldm::utils::DBusHandler,
+                                                      Handler>(dBusIntf, json,
+                                                               *this, repo);
+         }}};
 
     Type pdrType{};
     for (const auto& directory : dir)
@@ -120,16 +121,16 @@
                         for (const auto& effecter : effecterPDRs)
                         {
                             pdrType = effecter.value("pdrType", 0);
-                            generateHandlers.at(pdrType)(dBusIntf, effecter,
-                                                         repo);
+                            generateHandlers.at(
+                                pdrType)(dBusIntf, effecter, repo);
                         }
 
                         auto sensorPDRs = json.value("sensorPDRs", empty);
                         for (const auto& sensor : sensorPDRs)
                         {
                             pdrType = sensor.value("pdrType", 0);
-                            generateHandlers.at(pdrType)(dBusIntf, sensor,
-                                                         repo);
+                            generateHandlers.at(
+                                pdrType)(dBusIntf, sensor, repo);
                         }
                     }
                 }
@@ -296,9 +297,9 @@
         return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
     }
 
-    int rc = decode_set_state_effecter_states_req(request, payloadLength,
-                                                  &effecterId, &compEffecterCnt,
-                                                  stateField.data());
+    int rc = decode_set_state_effecter_states_req(
+        request, payloadLength, &effecterId, &compEffecterCnt,
+        stateField.data());
 
     if (rc != PLDM_SUCCESS)
     {
@@ -378,8 +379,8 @@
             const auto& handlers = eventHandlers.at(eventClass);
             for (const auto& handler : handlers)
             {
-                auto rc = handler(request, payloadLength, formatVersion, tid,
-                                  offset);
+                auto rc =
+                    handler(request, payloadLength, formatVersion, tid, offset);
                 if (rc != PLDM_SUCCESS)
                 {
                     return CmdHandler::ccOnlyResponse(request, rc);
@@ -414,8 +415,8 @@
     uint16_t sensorId{};
     uint8_t eventClass{};
     size_t eventClassDataOffset{};
-    auto eventData = reinterpret_cast<const uint8_t*>(request->payload) +
-                     eventDataOffset;
+    auto eventData =
+        reinterpret_cast<const uint8_t*>(request->payload) + eventDataOffset;
     auto eventDataSize = payloadLength - eventDataOffset;
 
     auto rc = decode_sensor_event_data(eventData, eventDataSize, &sensorId,
@@ -427,8 +428,8 @@
 
     auto eventClassData = reinterpret_cast<const uint8_t*>(request->payload) +
                           eventDataOffset + eventClassDataOffset;
-    auto eventClassDataSize = payloadLength - eventDataOffset -
-                              eventClassDataOffset;
+    auto eventClassDataSize =
+        payloadLength - eventDataOffset - eventClassDataOffset;
 
     if (eventClass == PLDM_STATE_SENSOR_STATE)
     {
@@ -496,12 +497,13 @@
         }
 
         const auto& [containerId, entityType, entityInstance] = entityInfo;
-        events::StateSensorEntry stateSensorEntry{containerId,
-                                                  entityType,
-                                                  entityInstance,
-                                                  sensorOffset,
-                                                  stateSetIds[sensorOffset],
-                                                  false};
+        events::StateSensorEntry stateSensorEntry{
+            containerId,
+            entityType,
+            entityInstance,
+            sensorOffset,
+            stateSetIds[sensorOffset],
+            false};
         return hostPDRHandler->handleStateSensorEvent(stateSensorEntry,
                                                       eventState);
     }
@@ -513,17 +515,16 @@
     return PLDM_SUCCESS;
 }
 
-int Handler::pldmPDRRepositoryChgEvent(const pldm_msg* request,
-                                       size_t payloadLength,
-                                       uint8_t /*formatVersion*/, uint8_t tid,
-                                       size_t eventDataOffset)
+int Handler::pldmPDRRepositoryChgEvent(
+    const pldm_msg* request, size_t payloadLength, uint8_t /*formatVersion*/,
+    uint8_t tid, size_t eventDataOffset)
 {
     uint8_t eventDataFormat{};
     uint8_t numberOfChangeRecords{};
     size_t dataOffset{};
 
-    auto eventData = reinterpret_cast<const uint8_t*>(request->payload) +
-                     eventDataOffset;
+    auto eventData =
+        reinterpret_cast<const uint8_t*>(request->payload) + eventDataOffset;
     auto eventDataSize = payloadLength - eventDataOffset;
 
     auto rc = decode_pldm_pdr_repository_chg_event_data(
@@ -569,8 +570,8 @@
                 }
 
                 rc = getPDRRecordHandles(
-                    reinterpret_cast<const ChangeEntry*>(changeRecordData +
-                                                         dataOffset),
+                    reinterpret_cast<const ChangeEntry*>(
+                        changeRecordData + dataOffset),
                     changeRecordDataSize - dataOffset,
                     static_cast<size_t>(numberOfChangeEntries),
                     pdrRecordHandles);
@@ -581,8 +582,8 @@
                 }
             }
 
-            changeRecordData += dataOffset +
-                                (numberOfChangeEntries * sizeof(ChangeEntry));
+            changeRecordData +=
+                dataOffset + (numberOfChangeEntries * sizeof(ChangeEntry));
             changeRecordDataSize -=
                 dataOffset + (numberOfChangeEntries * sizeof(ChangeEntry));
         }
@@ -618,10 +619,9 @@
     return PLDM_SUCCESS;
 }
 
-int Handler::getPDRRecordHandles(const ChangeEntry* changeEntryData,
-                                 size_t changeEntryDataSize,
-                                 size_t numberOfChangeEntries,
-                                 PDRRecordHandles& pdrRecordHandles)
+int Handler::getPDRRecordHandles(
+    const ChangeEntry* changeEntryData, size_t changeEntryDataSize,
+    size_t numberOfChangeEntries, PDRRecordHandles& pdrRecordHandles)
 {
     if (numberOfChangeEntries > (changeEntryDataSize / sizeof(ChangeEntry)))
     {
@@ -672,11 +672,11 @@
     // PresentValue (uint8|sint8|uint16|sint16|uint32|sint32 )
     // Size of PendingValue and PresentValue calculated based on size is
     // provided in effecter data size
-    size_t responsePayloadLength = sizeof(completionCode) +
-                                   sizeof(effecterDataSize) +
-                                   sizeof(effecterOperationalState) +
-                                   getEffecterDataSize(effecterDataSize) +
-                                   getEffecterDataSize(effecterDataSize);
+    size_t responsePayloadLength =
+        sizeof(completionCode) + sizeof(effecterDataSize) +
+        sizeof(effecterOperationalState) +
+        getEffecterDataSize(effecterDataSize) +
+        getEffecterDataSize(effecterDataSize);
 
     Response response(responsePayloadLength + sizeof(pldm_msg_hdr));
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
@@ -698,8 +698,8 @@
 Response Handler::setNumericEffecterValue(const pldm_msg* request,
                                           size_t payloadLength)
 {
-    Response response(sizeof(pldm_msg_hdr) +
-                      PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES);
+    Response response(
+        sizeof(pldm_msg_hdr) + PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES);
     uint16_t effecterId{};
     uint8_t effecterDataSize{};
     uint8_t effecterValue[4] = {};
@@ -718,9 +718,9 @@
     {
         const pldm::utils::DBusHandler dBusIntf;
         rc = platform_numeric_effecter::setNumericEffecterValueHandler<
-            pldm::utils::DBusHandler, Handler>(dBusIntf, *this, effecterId,
-                                               effecterDataSize, effecterValue,
-                                               sizeof(effecterValue));
+            pldm::utils::DBusHandler, Handler>(
+            dBusIntf, *this, effecterId, effecterDataSize, effecterValue,
+            sizeof(effecterValue));
     }
 
     return ccOnlyResponse(request, rc);
@@ -810,13 +810,13 @@
         return ccOnlyResponse(request, rc);
     }
 
-    Response response(sizeof(pldm_msg_hdr) +
-                      PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES +
-                      sizeof(get_sensor_state_field) * comSensorCnt);
+    Response response(
+        sizeof(pldm_msg_hdr) + PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES +
+        sizeof(get_sensor_state_field) * comSensorCnt);
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
-    rc = encode_get_state_sensor_readings_resp(request->hdr.instance_id, rc,
-                                               comSensorCnt, stateField.data(),
-                                               responsePtr);
+    rc = encode_get_state_sensor_readings_resp(
+        request->hdr.instance_id, rc, comSensorCnt, stateField.data(),
+        responsePtr);
     if (rc != PLDM_SUCCESS)
     {
         return ccOnlyResponse(request, rc);
@@ -973,8 +973,8 @@
 
 void Handler::setEventReceiver()
 {
-    std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
-                                    PLDM_SET_EVENT_RECEIVER_REQ_BYTES);
+    std::vector<uint8_t> requestMsg(
+        sizeof(pldm_msg_hdr) + PLDM_SET_EVENT_RECEIVER_REQ_BYTES);
     auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
     auto instanceId = instanceIdDb->next(eid);
     uint8_t eventMessageGlobalEnable =
@@ -995,8 +995,9 @@
         return;
     }
 
-    auto processSetEventReceiverResponse =
-        [](mctp_eid_t /*eid*/, const pldm_msg* response, size_t respMsgLen) {
+    auto processSetEventReceiverResponse = [](mctp_eid_t /*eid*/,
+                                              const pldm_msg* response,
+                                              size_t respMsgLen) {
         if (response == nullptr || !respMsgLen)
         {
             error("Failed to receive response for setEventReceiver command");
