diff --git a/dbus-sdr/sdrutils.cpp b/dbus-sdr/sdrutils.cpp
index 14eebb4..0c77ef7 100644
--- a/dbus-sdr/sdrutils.cpp
+++ b/dbus-sdr/sdrutils.cpp
@@ -85,8 +85,8 @@
     {
         return;
     }
-    nlohmann::json sensorFilterJSON = nlohmann::json::parse(filterFile, nullptr,
-                                                            false);
+    nlohmann::json sensorFilterJSON =
+        nlohmann::json::parse(filterFile, nullptr, false);
     nlohmann::json::iterator svcFilterit =
         sensorFilterJSON.find("ServiceFilter");
     if (svcFilterit == sensorFilterJSON.end())
@@ -96,15 +96,16 @@
 
     subtree.erase(std::remove_if(subtree.begin(), subtree.end(),
                                  [svcFilterit](SensorSubTree::value_type& kv) {
-        auto& [_, serviceToIfaces] = kv;
+                                     auto& [_, serviceToIfaces] = kv;
 
-        for (auto service = svcFilterit->begin(); service != svcFilterit->end();
-             ++service)
-        {
-            serviceToIfaces.erase(*service);
-        }
-        return serviceToIfaces.empty();
-    }),
+                                     for (auto service = svcFilterit->begin();
+                                          service != svcFilterit->end();
+                                          ++service)
+                                     {
+                                         serviceToIfaces.erase(*service);
+                                     }
+                                     return serviceToIfaces.empty();
+                                 }),
                   subtree.end());
 }
 
@@ -174,8 +175,8 @@
     static constexpr const std::array vrInterfaces = {
         "xyz.openbmc_project.Control.VoltageRegulatorMode"};
 
-    bool sensorRez = lbdUpdateSensorTree("/xyz/openbmc_project/sensors",
-                                         sensorInterfaces);
+    bool sensorRez =
+        lbdUpdateSensorTree("/xyz/openbmc_project/sensors", sensorInterfaces);
 
 #ifdef FEATURE_HYBRID_SENSORS
 
@@ -291,8 +292,8 @@
     return std::find_if(
         ipmi::sensor::sensors.begin(), ipmi::sensor::sensors.end(),
         [&path](const ipmi::sensor::IdInfoMap::value_type& findSensor) {
-        return findSensor.second.sensorPath == path;
-    });
+            return findSensor.second.sensorPath == path;
+        });
 }
 #endif
 
@@ -410,8 +411,8 @@
     return interfacesResponse;
 }
 
-std::map<std::string, Value> getEntityManagerProperties(const char* path,
-                                                        const char* interface)
+std::map<std::string, Value>
+    getEntityManagerProperties(const char* path, const char* interface)
 {
     std::map<std::string, Value> properties;
     std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
@@ -462,8 +463,8 @@
         return ipmiDecoratorPaths;
     }
 
-    ipmiDecoratorPaths = std::unordered_set<std::string>(paths.begin(),
-                                                         paths.end());
+    ipmiDecoratorPaths =
+        std::unordered_set<std::string>(paths.begin(), paths.end());
     return ipmiDecoratorPaths;
 }
 
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index 6517fdd..b3786c9 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -135,24 +135,24 @@
     "type='signal',member='InterfacesAdded',arg0path='/xyz/openbmc_project/"
     "sensors/'",
     [](sdbusplus::message_t&) {
-    getSensorTree().clear();
-    getIpmiDecoratorPaths(/*ctx=*/std::nullopt).reset();
-    sdrLastAdd = std::chrono::duration_cast<std::chrono::seconds>(
-                     std::chrono::system_clock::now().time_since_epoch())
-                     .count();
-});
+        getSensorTree().clear();
+        getIpmiDecoratorPaths(/*ctx=*/std::nullopt).reset();
+        sdrLastAdd = std::chrono::duration_cast<std::chrono::seconds>(
+                         std::chrono::system_clock::now().time_since_epoch())
+                         .count();
+    });
 
 static sdbusplus::bus::match_t sensorRemoved(
     *getSdBus(),
     "type='signal',member='InterfacesRemoved',arg0path='/xyz/openbmc_project/"
     "sensors/'",
     [](sdbusplus::message_t&) {
-    getSensorTree().clear();
-    getIpmiDecoratorPaths(/*ctx=*/std::nullopt).reset();
-    sdrLastRemove = std::chrono::duration_cast<std::chrono::seconds>(
-                        std::chrono::system_clock::now().time_since_epoch())
-                        .count();
-});
+        getSensorTree().clear();
+        getIpmiDecoratorPaths(/*ctx=*/std::nullopt).reset();
+        sdrLastRemove = std::chrono::duration_cast<std::chrono::seconds>(
+                            std::chrono::system_clock::now().time_since_epoch())
+                            .count();
+    });
 
 ipmi_ret_t getSensorConnection(ipmi::Context::ptr ctx, uint8_t sensnum,
                                std::string& connection, std::string& path,
@@ -206,40 +206,43 @@
     "type='signal',member='PropertiesChanged',interface='org.freedesktop.DBus."
     "Properties',arg0namespace='xyz.openbmc_project.Sensor.Threshold'",
     [](sdbusplus::message_t& m) {
-    boost::container::flat_map<std::string, std::variant<bool, double>> values;
-    m.read(std::string(), values);
+        boost::container::flat_map<std::string, std::variant<bool, double>>
+            values;
+        m.read(std::string(), values);
 
-    auto findAssert = std::find_if(values.begin(), values.end(),
-                                   [](const auto& pair) {
-        return pair.first.find("Alarm") != std::string::npos;
-    });
-    if (findAssert != values.end())
-    {
-        auto ptr = std::get_if<bool>(&(findAssert->second));
-        if (ptr == nullptr)
+        auto findAssert =
+            std::find_if(values.begin(), values.end(), [](const auto& pair) {
+                return pair.first.find("Alarm") != std::string::npos;
+            });
+        if (findAssert != values.end())
         {
-            lg2::error("thresholdChanged: Assert non bool");
-            return;
-        }
-        if (*ptr)
-        {
-            lg2::info("thresholdChanged: Assert, sensor path: {SENSOR_PATH}",
-                      "SENSOR_PATH", m.get_path());
-            thresholdDeassertMap[m.get_path()][findAssert->first] = *ptr;
-        }
-        else
-        {
-            auto& value = thresholdDeassertMap[m.get_path()][findAssert->first];
-            if (value)
+            auto ptr = std::get_if<bool>(&(findAssert->second));
+            if (ptr == nullptr)
+            {
+                lg2::error("thresholdChanged: Assert non bool");
+                return;
+            }
+            if (*ptr)
             {
                 lg2::info(
-                    "thresholdChanged: deassert, sensor path: {SENSOR_PATH}",
+                    "thresholdChanged: Assert, sensor path: {SENSOR_PATH}",
                     "SENSOR_PATH", m.get_path());
-                value = *ptr;
+                thresholdDeassertMap[m.get_path()][findAssert->first] = *ptr;
+            }
+            else
+            {
+                auto& value =
+                    thresholdDeassertMap[m.get_path()][findAssert->first];
+                if (value)
+                {
+                    lg2::info(
+                        "thresholdChanged: deassert, sensor path: {SENSOR_PATH}",
+                        "SENSOR_PATH", m.get_path());
+                    value = *ptr;
+                }
             }
         }
-    }
-});
+    });
 
 namespace sensor
 {
@@ -432,9 +435,8 @@
 }
 
 // Calculate VR Mode from input IPMI discrete event bytes
-static std::optional<std::string>
-    calculateVRMode(uint15_t assertOffset,
-                    const ipmi::DbusInterfaceMap::mapped_type& VRObject)
+static std::optional<std::string> calculateVRMode(
+    uint15_t assertOffset, const ipmi::DbusInterfaceMap::mapped_type& VRObject)
 {
     // get VR mode profiles from Supported Interface
     auto profiles = getSupportedVrProfiles(VRObject);
@@ -774,18 +776,16 @@
     return ipmi::responseSuccess();
 }
 
-ipmi::RspType<> ipmiSetSensorReading(ipmi::Context::ptr ctx,
-                                     uint8_t sensorNumber, uint8_t,
-                                     uint8_t reading, uint15_t assertOffset,
-                                     bool, uint15_t, bool, uint8_t, uint8_t,
-                                     uint8_t)
+ipmi::RspType<> ipmiSetSensorReading(
+    ipmi::Context::ptr ctx, uint8_t sensorNumber, uint8_t, uint8_t reading,
+    uint15_t assertOffset, bool, uint15_t, bool, uint8_t, uint8_t, uint8_t)
 {
     std::string connection;
     std::string path;
     std::vector<std::string> interfaces;
 
-    ipmi::Cc status = getSensorConnection(ctx, sensorNumber, connection, path,
-                                          &interfaces);
+    ipmi::Cc status =
+        getSensorConnection(ctx, sensorNumber, connection, path, &interfaces);
     if (status)
     {
         return ipmi::response(status);
@@ -807,14 +807,14 @@
         }
 
         // Only allow external SetSensor if write permission granted
-        if (!details::sdrWriteTable.getWritePermission((ctx->lun << 8) |
-                                                       sensorNumber))
+        if (!details::sdrWriteTable.getWritePermission(
+                (ctx->lun << 8) | sensorNumber))
         {
             return ipmi::responseResponseError();
         }
 
-        auto value = sensor::calculateValue(reading, sensorMap,
-                                            sensorObject->second);
+        auto value =
+            sensor::calculateValue(reading, sensorMap, sensorObject->second);
         if (!value)
         {
             return ipmi::responseResponseError();
@@ -863,8 +863,8 @@
         // VR sensors are treated as a special case and we will not check the
         // write permission for VR sensors, since they always deemed writable
         // and permission table are not applied to VR sensors.
-        auto vrMode = sensor::calculateVRMode(assertOffset,
-                                              sensorObject->second);
+        auto vrMode =
+            sensor::calculateVRMode(assertOffset, sensorObject->second);
         if (!vrMode)
         {
             return ipmi::responseResponseError();
@@ -982,8 +982,8 @@
         return ipmi::responseResponseError();
     }
 
-    uint8_t value = scaleIPMIValueFromDouble(reading, mValue, rExp, bValue,
-                                             bExp, bSigned);
+    uint8_t value =
+        scaleIPMIValueFromDouble(reading, mValue, rExp, bValue, bExp, bSigned);
     uint8_t operation =
         static_cast<uint8_t>(IPMISensorReadingByte2::sensorScanningEnable);
     operation |=
@@ -1032,16 +1032,15 @@
         {
             // This is the first reading, show the coefficients
             double step = (max - min) / 255.0;
-            std::cerr << "IPMI sensor "
-                      << details::sdrStatsTable.getName((ctx->lun << 8) |
-                                                        sensnum)
-                      << ": Range min=" << min << " max=" << max
-                      << ", step=" << step
-                      << ", Coefficients mValue=" << static_cast<int>(mValue)
-                      << " rExp=" << static_cast<int>(rExp)
-                      << " bValue=" << static_cast<int>(bValue)
-                      << " bExp=" << static_cast<int>(bExp)
-                      << " bSigned=" << static_cast<int>(bSigned) << "\n";
+            std::cerr
+                << "IPMI sensor "
+                << details::sdrStatsTable.getName((ctx->lun << 8) | sensnum)
+                << ": Range min=" << min << " max=" << max << ", step=" << step
+                << ", Coefficients mValue=" << static_cast<int>(mValue)
+                << " rExp=" << static_cast<int>(rExp)
+                << " bValue=" << static_cast<int>(bValue)
+                << " bExp=" << static_cast<int>(bExp)
+                << " bSigned=" << static_cast<int>(bSigned) << "\n";
         }
     }
 
@@ -1296,8 +1295,8 @@
 
             if (warningHigh != warningMap.end())
             {
-                double value = std::visit(VariantToDoubleVisitor(),
-                                          warningHigh->second);
+                double value =
+                    std::visit(VariantToDoubleVisitor(), warningHigh->second);
                 if (std::isfinite(value))
                 {
                     resp.warningHigh = scaleIPMIValueFromDouble(
@@ -1306,8 +1305,8 @@
             }
             if (warningLow != warningMap.end())
             {
-                double value = std::visit(VariantToDoubleVisitor(),
-                                          warningLow->second);
+                double value =
+                    std::visit(VariantToDoubleVisitor(), warningLow->second);
                 if (std::isfinite(value))
                 {
                     resp.warningLow = scaleIPMIValueFromDouble(
@@ -1324,8 +1323,8 @@
 
             if (criticalHigh != criticalMap.end())
             {
-                double value = std::visit(VariantToDoubleVisitor(),
-                                          criticalHigh->second);
+                double value =
+                    std::visit(VariantToDoubleVisitor(), criticalHigh->second);
                 if (std::isfinite(value))
                 {
                     resp.criticalHigh = scaleIPMIValueFromDouble(
@@ -1334,8 +1333,8 @@
             }
             if (criticalLow != criticalMap.end())
             {
-                double value = std::visit(VariantToDoubleVisitor(),
-                                          criticalLow->second);
+                double value =
+                    std::visit(VariantToDoubleVisitor(), criticalLow->second);
                 if (std::isfinite(value))
                 {
                     resp.criticalLow = scaleIPMIValueFromDouble(
@@ -1511,8 +1510,8 @@
             auto warningLow = warningMap.find("WarningLow");
             if (warningHigh != warningMap.end())
             {
-                double value = std::visit(VariantToDoubleVisitor(),
-                                          warningHigh->second);
+                double value =
+                    std::visit(VariantToDoubleVisitor(), warningHigh->second);
                 if (std::isfinite(value))
                 {
                     assertionEnabledLsb |= static_cast<uint8_t>(
@@ -1525,8 +1524,8 @@
             }
             if (warningLow != warningMap.end())
             {
-                double value = std::visit(VariantToDoubleVisitor(),
-                                          warningLow->second);
+                double value =
+                    std::visit(VariantToDoubleVisitor(), warningLow->second);
                 if (std::isfinite(value))
                 {
                     assertionEnabledLsb |= static_cast<uint8_t>(
@@ -1547,8 +1546,8 @@
 
             if (criticalHigh != criticalMap.end())
             {
-                double value = std::visit(VariantToDoubleVisitor(),
-                                          criticalHigh->second);
+                double value =
+                    std::visit(VariantToDoubleVisitor(), criticalHigh->second);
                 if (std::isfinite(value))
                 {
                     assertionEnabledMsb |= static_cast<uint8_t>(
@@ -1560,8 +1559,8 @@
             }
             if (criticalLow != criticalMap.end())
             {
-                double value = std::visit(VariantToDoubleVisitor(),
-                                          criticalLow->second);
+                double value =
+                    std::visit(VariantToDoubleVisitor(), criticalLow->second);
                 if (std::isfinite(value))
                 {
                     assertionEnabledLsb |= static_cast<uint8_t>(
@@ -1731,15 +1730,15 @@
             }
             if (warningHighAlarm)
             {
-                assertions.set(
-                    static_cast<size_t>(IPMIGetSensorEventEnableThresholds::
-                                            upperNonCriticalGoingHigh));
+                assertions.set(static_cast<size_t>(
+                    IPMIGetSensorEventEnableThresholds::
+                        upperNonCriticalGoingHigh));
             }
             if (warningLowAlarm)
             {
-                assertions.set(
-                    static_cast<size_t>(IPMIGetSensorEventEnableThresholds::
-                                            lowerNonCriticalGoingLow));
+                assertions.set(static_cast<size_t>(
+                    IPMIGetSensorEventEnableThresholds::
+                        lowerNonCriticalGoingLow));
             }
         }
         if (criticalInterface != sensorMap.end())
@@ -1761,9 +1760,9 @@
             }
             if (criticalHighAlarm)
             {
-                assertions.set(
-                    static_cast<size_t>(IPMIGetSensorEventEnableThresholds::
-                                            upperCriticalGoingHigh));
+                assertions.set(static_cast<size_t>(
+                    IPMIGetSensorEventEnableThresholds::
+                        upperCriticalGoingHigh));
             }
             if (criticalLowAlarm)
             {
@@ -1898,8 +1897,8 @@
     uint8_t bExpBits = bExp & 0x07;
 
     // move rExp and bExp into place
-    record.body.r_b_exponents = (rExpSign << 7) | (rExpBits << 4) |
-                                (bExpSign << 3) | bExpBits;
+    record.body.r_b_exponents =
+        (rExpSign << 7) | (rExpBits << 4) | (bExpSign << 3) | bExpBits;
 
     // Set the analog reading byte interpretation accordingly
     record.body.sensor_units_1 = (bSigned ? 1 : 0) << 7;
@@ -1923,8 +1922,8 @@
         sensorMap.find("xyz.openbmc_project.Sensor.ValueMutability");
     if (mutability != sensorMap.end())
     {
-        sensorSettable = mappedVariant<bool>(mutability->second, "Mutable",
-                                             false);
+        sensorSettable =
+            mappedVariant<bool>(mutability->second, "Mutable", false);
     }
     get_sdr::body::init_settable_state(sensorSettable, &record.body);
 
@@ -2173,9 +2172,9 @@
         ctx->lun = lun3;
     }
 
-    auto status = getSensorConnection(ctx,
-                                      static_cast<uint8_t>(sensNumFromRecID),
-                                      connection, path, &interfaces);
+    auto status =
+        getSensorConnection(ctx, static_cast<uint8_t>(sensNumFromRecID),
+                            connection, path, &interfaces);
     if (status)
     {
         lg2::error("getSensorDataRecord: getSensorConnection error");
@@ -2369,8 +2368,8 @@
         // Return the number of sensors attached to the LUN
         if ((ctx->lun == lun0) && (numSensors > 0))
         {
-            sdrCount = (numSensors > maxSensorsPerLUN) ? maxSensorsPerLUN
-                                                       : numSensors;
+            sdrCount =
+                (numSensors > maxSensorsPerLUN) ? maxSensorsPerLUN : numSensors;
         }
         else if ((ctx->lun == lun1) && (numSensors > maxSensorsPerLUN))
         {
@@ -2435,8 +2434,8 @@
     ipmiStorageGetSDRRepositoryInfo(ipmi::Context::ptr ctx)
 {
     constexpr const uint16_t unspecifiedFreeSpace = 0xFFFF;
-    uint16_t recordCount = ipmi::getNumberOfSensors() +
-                           ipmi::sensor::getOtherSensorsCount(ctx);
+    uint16_t recordCount =
+        ipmi::getNumberOfSensors() + ipmi::sensor::getOtherSensorsCount(ctx);
 
     uint8_t operationSupport = static_cast<uint8_t>(
         SdrRepositoryInfoOps::overflow); // write not supported
@@ -2535,8 +2534,8 @@
         return ipmi::responseSuccess(nextRecordId, record);
     }
 
-    size_t sdrLength = sizeof(get_sdr::SensorDataRecordHeader) +
-                       hdr->record_length;
+    size_t sdrLength =
+        sizeof(get_sdr::SensorDataRecordHeader) + hdr->record_length;
     if (offset >= sdrLength)
     {
         lg2::error("ipmiStorageGetSDR: offset is outside the record");
@@ -2831,8 +2830,8 @@
 
     for (const auto& sensor : sensorList)
     {
-        const auto& [readResult, tempVal,
-                     signBit] = readTemp(ctx, sensor.objectPath);
+        const auto& [readResult, tempVal, signBit] =
+            readTemp(ctx, sensor.objectPath);
 
         if (readResult)
         {
@@ -2931,14 +2930,14 @@
                           ipmi::storage::cmdGetSdr, ipmi::Privilege::User,
                           ipmiStorageGetSDR);
     // <Get DCMI Sensor Info>
-    ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, ipmi::groupDCMI,
-                               ipmi::dcmi::cmdGetDcmiSensorInfo,
-                               ipmi::Privilege::Operator,
-                               ipmi::dcmi::getSensorInfo);
+    ipmi::registerGroupHandler(
+        ipmi::prioOpenBmcBase, ipmi::groupDCMI,
+        ipmi::dcmi::cmdGetDcmiSensorInfo, ipmi::Privilege::Operator,
+        ipmi::dcmi::getSensorInfo);
     // <Get Temperature Readings>
-    ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, ipmi::groupDCMI,
-                               ipmi::dcmi::cmdGetTemperatureReadings,
-                               ipmi::Privilege::User,
-                               ipmi::dcmi::getTempReadings);
+    ipmi::registerGroupHandler(
+        ipmi::prioOpenBmcBase, ipmi::groupDCMI,
+        ipmi::dcmi::cmdGetTemperatureReadings, ipmi::Privilege::User,
+        ipmi::dcmi::getTempReadings);
 }
 } // namespace ipmi
diff --git a/dbus-sdr/sensorutils.cpp b/dbus-sdr/sensorutils.cpp
index e76a5f1..8c6952b 100644
--- a/dbus-sdr/sensorutils.cpp
+++ b/dbus-sdr/sensorutils.cpp
@@ -240,9 +240,8 @@
     // Step 4: Constrain B, and set bExp accordingly
     if (!(scaleFloatExp(dB, bExp)))
     {
-        std::cerr << "getSensorAttributes: Offset (B=" << dB
-                  << ", bExp=" << (int)bExp
-                  << ") exceeds multiplier scale (M=" << dM
+        std::cerr << "getSensorAttributes: Offset (B=" << dB << ", bExp="
+                  << (int)bExp << ") exceeds multiplier scale (M=" << dM
                   << ", rExp=" << (int)rExp << ")\n";
         return false;
     }
@@ -312,8 +311,8 @@
     int8_t bExp = 0;
     bool bSigned = false;
 
-    bool result = getSensorAttributes(max, min, mValue, rExp, bValue, bExp,
-                                      bSigned);
+    bool result =
+        getSensorAttributes(max, min, mValue, rExp, bValue, bExp, bSigned);
     if (!result)
     {
         throw std::runtime_error("Illegal sensor attributes");
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index afe3535..a93a045 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -236,8 +236,8 @@
     recalculateHashes();
 }
 
-std::pair<ipmi::Cc, std::vector<uint8_t>> getFru(ipmi::Context::ptr ctx,
-                                                 uint8_t devId)
+std::pair<ipmi::Cc, std::vector<uint8_t>>
+    getFru(ipmi::Context::ptr ctx, uint8_t devId)
 {
     if (lastDevId == devId && devId != 0xFF)
     {
@@ -297,55 +297,57 @@
     fruMatches.reserve(2);
 
     auto bus = getSdBus();
-    fruMatches.emplace_back(*bus,
-                            "type='signal',arg0path='/xyz/openbmc_project/"
-                            "FruDevice/',member='InterfacesAdded'",
-                            [](sdbusplus::message_t& message) {
-        sdbusplus::message::object_path path;
-        ObjectType object;
-        try
-        {
-            message.read(path, object);
-        }
-        catch (const sdbusplus::exception_t&)
-        {
-            return;
-        }
-        auto findType = object.find("xyz.openbmc_project.FruDevice");
-        if (findType == object.end())
-        {
-            return;
-        }
-        writeFruIfRunning();
-        frus[path] = object;
-        recalculateHashes();
-        lastDevId = 0xFF;
-    });
+    fruMatches.emplace_back(
+        *bus,
+        "type='signal',arg0path='/xyz/openbmc_project/"
+        "FruDevice/',member='InterfacesAdded'",
+        [](sdbusplus::message_t& message) {
+            sdbusplus::message::object_path path;
+            ObjectType object;
+            try
+            {
+                message.read(path, object);
+            }
+            catch (const sdbusplus::exception_t&)
+            {
+                return;
+            }
+            auto findType = object.find("xyz.openbmc_project.FruDevice");
+            if (findType == object.end())
+            {
+                return;
+            }
+            writeFruIfRunning();
+            frus[path] = object;
+            recalculateHashes();
+            lastDevId = 0xFF;
+        });
 
-    fruMatches.emplace_back(*bus,
-                            "type='signal',arg0path='/xyz/openbmc_project/"
-                            "FruDevice/',member='InterfacesRemoved'",
-                            [](sdbusplus::message_t& message) {
-        sdbusplus::message::object_path path;
-        std::set<std::string> interfaces;
-        try
-        {
-            message.read(path, interfaces);
-        }
-        catch (const sdbusplus::exception_t&)
-        {
-            return;
-        }
-        auto findType = interfaces.find("xyz.openbmc_project.FruDevice");
-        if (findType == interfaces.end())
-        {
-            return;
-        }
-        writeFruIfRunning();
-        frus.erase(path);
-        recalculateHashes();
-        lastDevId = 0xFF;
-    });
+    fruMatches.emplace_back(
+        *bus,
+        "type='signal',arg0path='/xyz/openbmc_project/"
+        "FruDevice/',member='InterfacesRemoved'",
+        [](sdbusplus::message_t& message) {
+            sdbusplus::message::object_path path;
+            std::set<std::string> interfaces;
+            try
+            {
+                message.read(path, interfaces);
+            }
+            catch (const sdbusplus::exception_t&)
+            {
+                return;
+            }
+            auto findType = interfaces.find("xyz.openbmc_project.FruDevice");
+            if (findType == interfaces.end())
+            {
+                return;
+            }
+            writeFruIfRunning();
+            frus.erase(path);
+            recalculateHashes();
+            lastDevId = 0xFF;
+        });
 
     // call once to populate
     boost::asio::spawn(*getIoContext(), [](boost::asio::yield_context yield) {
@@ -410,10 +412,9 @@
  *  @returns ipmi completion code plus response data
  *   - countWritten  - Count written
  */
-ipmi::RspType<uint8_t>
-    ipmiStorageWriteFruData(ipmi::Context::ptr ctx, uint8_t fruDeviceId,
-                            uint16_t fruInventoryOffset,
-                            std::vector<uint8_t>& dataToWrite)
+ipmi::RspType<uint8_t> ipmiStorageWriteFruData(
+    ipmi::Context::ptr ctx, uint8_t fruDeviceId, uint16_t fruInventoryOffset,
+    std::vector<uint8_t>& dataToWrite)
 {
     if (fruDeviceId == 0xFF)
     {
@@ -558,31 +559,33 @@
     uint8_t& address = device->second.second;
 
     boost::container::flat_map<std::string, Value>* fruData = nullptr;
-    auto fru = std::find_if(frus.begin(), frus.end(),
-                            [bus, address, &fruData](ManagedEntry& entry) {
-        auto findFruDevice = entry.second.find("xyz.openbmc_project.FruDevice");
-        if (findFruDevice == entry.second.end())
-        {
-            return false;
-        }
-        fruData = &(findFruDevice->second);
-        auto findBus = findFruDevice->second.find("BUS");
-        auto findAddress = findFruDevice->second.find("ADDRESS");
-        if (findBus == findFruDevice->second.end() ||
-            findAddress == findFruDevice->second.end())
-        {
-            return false;
-        }
-        if (std::get<uint32_t>(findBus->second) != bus)
-        {
-            return false;
-        }
-        if (std::get<uint32_t>(findAddress->second) != address)
-        {
-            return false;
-        }
-        return true;
-    });
+    auto fru = std::find_if(
+        frus.begin(), frus.end(),
+        [bus, address, &fruData](ManagedEntry& entry) {
+            auto findFruDevice =
+                entry.second.find("xyz.openbmc_project.FruDevice");
+            if (findFruDevice == entry.second.end())
+            {
+                return false;
+            }
+            fruData = &(findFruDevice->second);
+            auto findBus = findFruDevice->second.find("BUS");
+            auto findAddress = findFruDevice->second.find("ADDRESS");
+            if (findBus == findFruDevice->second.end() ||
+                findAddress == findFruDevice->second.end())
+            {
+                return false;
+            }
+            if (std::get<uint32_t>(findBus->second) != bus)
+            {
+                return false;
+            }
+            if (std::get<uint32_t>(findAddress->second) != address)
+            {
+                return false;
+            }
+            return true;
+        });
     if (fru == frus.end())
     {
         return IPMI_CC_RESPONSE_ERROR;
@@ -610,49 +613,49 @@
         return ipmi::ccResponseError;
     }
 
-    auto entity =
-        std::find_if(entities.begin(), entities.end(),
-                     [bus, address, &entityData, &name](ManagedEntry& entry) {
-        auto findFruDevice = entry.second.find(
-            "xyz.openbmc_project.Inventory.Decorator.I2CDevice");
-        if (findFruDevice == entry.second.end())
-        {
-            return false;
-        }
+    auto entity = std::find_if(
+        entities.begin(), entities.end(),
+        [bus, address, &entityData, &name](ManagedEntry& entry) {
+            auto findFruDevice = entry.second.find(
+                "xyz.openbmc_project.Inventory.Decorator.I2CDevice");
+            if (findFruDevice == entry.second.end())
+            {
+                return false;
+            }
 
-        // Integer fields added via Entity-Manager json are uint64_ts by
-        // default.
-        auto findBus = findFruDevice->second.find("Bus");
-        auto findAddress = findFruDevice->second.find("Address");
+            // Integer fields added via Entity-Manager json are uint64_ts by
+            // default.
+            auto findBus = findFruDevice->second.find("Bus");
+            auto findAddress = findFruDevice->second.find("Address");
 
-        if (findBus == findFruDevice->second.end() ||
-            findAddress == findFruDevice->second.end())
-        {
-            return false;
-        }
-        if ((std::get<uint64_t>(findBus->second) != bus) ||
-            (std::get<uint64_t>(findAddress->second) != address))
-        {
-            return false;
-        }
+            if (findBus == findFruDevice->second.end() ||
+                findAddress == findFruDevice->second.end())
+            {
+                return false;
+            }
+            if ((std::get<uint64_t>(findBus->second) != bus) ||
+                (std::get<uint64_t>(findAddress->second) != address))
+            {
+                return false;
+            }
 
-        auto fruName = findFruDevice->second.find("Name");
-        if (fruName != findFruDevice->second.end())
-        {
-            name = std::get<std::string>(fruName->second);
-        }
+            auto fruName = findFruDevice->second.find("Name");
+            if (fruName != findFruDevice->second.end())
+            {
+                name = std::get<std::string>(fruName->second);
+            }
 
-        // At this point we found the device entry and should return
-        // true.
-        auto findIpmiDevice =
-            entry.second.find("xyz.openbmc_project.Inventory.Decorator.Ipmi");
-        if (findIpmiDevice != entry.second.end())
-        {
-            entityData = &(findIpmiDevice->second);
-        }
+            // At this point we found the device entry and should return
+            // true.
+            auto findIpmiDevice = entry.second.find(
+                "xyz.openbmc_project.Inventory.Decorator.Ipmi");
+            if (findIpmiDevice != entry.second.end())
+            {
+                entityData = &(findIpmiDevice->second);
+            }
 
-        return true;
-    });
+            return true;
+        });
 
     if (entity == entities.end())
     {
@@ -747,8 +750,8 @@
                                dynamic_sensors::ipmi::sel::selLogFilename))
         {
             // If we find an ipmi_sel log file, save the path
-            selLogFiles.emplace_back(dynamic_sensors::ipmi::sel::selLogDir /
-                                     filename);
+            selLogFiles.emplace_back(
+                dynamic_sensors::ipmi::sel::selLogDir / filename);
         }
     }
     // As the log files rotate, they are appended with a ".#" that is higher for
@@ -1139,10 +1142,9 @@
   uint8_t eventType, uint8_t eventData1, uint8_t eventData2,
   uint8_t eventData3
 */
-ipmi::RspType<uint16_t> ipmiStorageAddSELEntry(uint16_t, uint8_t, uint32_t,
-                                               uint16_t, uint8_t, uint8_t,
-                                               uint8_t, uint8_t, uint8_t,
-                                               uint8_t, uint8_t)
+ipmi::RspType<uint16_t>
+    ipmiStorageAddSELEntry(uint16_t, uint8_t, uint32_t, uint16_t, uint8_t,
+                           uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
 {
     // Per the IPMI spec, need to cancel any reservation when a SEL entry is
     // added
@@ -1152,10 +1154,9 @@
     return ipmi::responseSuccess(responseID);
 }
 
-ipmi::RspType<uint8_t> ipmiStorageClearSEL(ipmi::Context::ptr ctx,
-                                           uint16_t reservationID,
-                                           const std::array<uint8_t, 3>& clr,
-                                           uint8_t eraseOperation)
+ipmi::RspType<uint8_t> ipmiStorageClearSEL(
+    ipmi::Context::ptr ctx, uint16_t reservationID,
+    const std::array<uint8_t, 3>& clr, uint8_t eraseOperation)
 {
     if (!checkSELReservation(reservationID))
     {
@@ -1198,9 +1199,8 @@
     return ipmi::responseSuccess(ipmi::sel::eraseComplete);
 }
 
-std::vector<uint8_t>
-    getType8SDRs(ipmi::sensor::EntityInfoMap::const_iterator& entity,
-                 uint16_t recordId)
+std::vector<uint8_t> getType8SDRs(
+    ipmi::sensor::EntityInfoMap::const_iterator& entity, uint16_t recordId)
 {
     std::vector<uint8_t> resp;
     get_sdr::SensorDataEntityRecord data{};
@@ -1252,8 +1252,8 @@
     }
     else
     {
-        throw std::runtime_error("getType12SDRs:: Illegal index " +
-                                 std::to_string(index));
+        throw std::runtime_error(
+            "getType12SDRs:: Illegal index " + std::to_string(index));
     }
 
     return resp;
