clang-tidy: Enable readability-convert-member-functions-to-static
This check finds non-static member functions that can be made
static because the functions don’t use this.
This check also triggers readability-static-accessed-through
-instance check as we are trying to access a static member
function through an instance.
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I6efe76666f75fb4f65621796466d9347cea25d01
diff --git a/manager/lamptest/lamptest.cpp b/manager/lamptest/lamptest.cpp
index e7c9d5a..f91a085 100644
--- a/manager/lamptest/lamptest.cpp
+++ b/manager/lamptest/lamptest.cpp
@@ -31,8 +31,8 @@
if (iter != forceUpdateLEDs.end())
{
- manager.drivePhysicalLED(path, Layout::Action::Off, it.dutyOn,
- it.period);
+ phosphor::led::Manager::drivePhysicalLED(
+ path, Layout::Action::Off, it.dutyOn, it.period);
}
}
@@ -45,7 +45,8 @@
if (iter != forceUpdateLEDs.end())
{
- manager.drivePhysicalLED(path, it.action, it.dutyOn, it.period);
+ phosphor::led::Manager::drivePhysicalLED(path, it.action,
+ it.dutyOn, it.period);
}
}
@@ -80,7 +81,8 @@
continue;
}
- manager.drivePhysicalLED(path, Layout::Action::Off, 0, 0);
+ phosphor::led::Manager::drivePhysicalLED(path, Layout::Action::Off, 0,
+ 0);
}
if (std::filesystem::exists(lampTestIndicator))
@@ -146,7 +148,9 @@
uint8_t dutyOn{};
try
{
- auto properties = dBusHandler.getAllProperties(path, phyLedIntf);
+ auto properties =
+ phosphor::led::utils::DBusHandler::getAllProperties(path,
+ phyLedIntf);
state = std::get<std::string>(properties["State"]);
period = std::get<uint16_t>(properties["Period"]);
@@ -187,7 +191,8 @@
// Get paths of all the Physical LED objects
try
{
- physicalLEDPaths = dBusHandler.getSubTreePaths(phyLedPath, phyLedIntf);
+ physicalLEDPaths = phosphor::led::utils::DBusHandler::getSubTreePaths(
+ phyLedPath, phyLedIntf);
}
catch (const sdbusplus::exception_t& e)
{
@@ -233,7 +238,8 @@
continue;
}
- manager.drivePhysicalLED(path, Layout::Action::On, 0, 0);
+ phosphor::led::Manager::drivePhysicalLED(path, Layout::Action::On, 0,
+ 0);
}
}
@@ -307,9 +313,9 @@
try
{
PropertyValue assertedValue{value};
- dBusHandler.setProperty(HOST_LAMP_TEST_OBJECT,
- "xyz.openbmc_project.Led.Group", "Asserted",
- assertedValue);
+ phosphor::led::utils::DBusHandler::setProperty(
+ HOST_LAMP_TEST_OBJECT, "xyz.openbmc_project.Led.Group", "Asserted",
+ assertedValue);
}
catch (const sdbusplus::exception_t& e)
{
@@ -357,14 +363,14 @@
if (std::filesystem::exists(lampTestIndicator))
{
// we need to off all the LEDs.
- phosphor::led::utils::DBusHandler dBusHandler;
- std::vector<std::string> physicalLedPaths = dBusHandler.getSubTreePaths(
- phosphor::led::phyLedPath, phosphor::led::phyLedIntf);
+ std::vector<std::string> physicalLedPaths =
+ phosphor::led::utils::DBusHandler::getSubTreePaths(
+ phosphor::led::phyLedPath, phosphor::led::phyLedIntf);
for (const auto& path : physicalLedPaths)
{
- manager.drivePhysicalLED(path, phosphor::led::Layout::Action::Off,
- 0, 0);
+ phosphor::led::Manager::drivePhysicalLED(
+ path, phosphor::led::Layout::Action::Off, 0, 0);
}
// Also remove the lamp test on indicator file.
diff --git a/manager/lamptest/lamptest.hpp b/manager/lamptest/lamptest.hpp
index 5e312e2..ce7bae1 100644
--- a/manager/lamptest/lamptest.hpp
+++ b/manager/lamptest/lamptest.hpp
@@ -79,7 +79,7 @@
* with the persisted lamp test indicator file so that there is no sign of
* lamptest.
*/
- void clearLamps();
+ static void clearLamps();
private:
/** @brief Timer used for LEDs lamp test period */
@@ -88,9 +88,6 @@
/** @brief Reference to Manager object */
Manager& manager;
- /** DBusHandler class handles the D-Bus operations */
- DBusHandler dBusHandler;
-
/** @brief Pointer to Group object */
Group* groupObj;
@@ -137,13 +134,13 @@
*
* @return enumeration equivalent of the passed in string
*/
- Layout::Action getActionFromString(const std::string& str);
+ static Layout::Action getActionFromString(const std::string& str);
/** @brief Notify host to start / stop the lamp test
*
* @param[in] value - the Asserted property value
*/
- void doHostLampTest(bool value);
+ static void doHostLampTest(bool value);
/** @brief Get physical LED names from lamp test JSON config file
*
diff --git a/manager/manager.cpp b/manager/manager.cpp
index 6a31e93..7c7d730 100644
--- a/manager/manager.cpp
+++ b/manager/manager.cpp
@@ -218,12 +218,15 @@
PropertyValue dutyOnValue{dutyOn};
PropertyValue periodValue{period};
- dBusHandler.setProperty(objPath, phyLedIntf, "DutyOn", dutyOnValue);
- dBusHandler.setProperty(objPath, phyLedIntf, "Period", periodValue);
+ phosphor::led::utils::DBusHandler::setProperty(
+ objPath, phyLedIntf, "DutyOn", dutyOnValue);
+ phosphor::led::utils::DBusHandler::setProperty(
+ objPath, phyLedIntf, "Period", periodValue);
}
PropertyValue actionValue{getPhysicalAction(action)};
- dBusHandler.setProperty(objPath, phyLedIntf, "State", actionValue);
+ phosphor::led::utils::DBusHandler::setProperty(objPath, phyLedIntf,
+ "State", actionValue);
}
catch (const sdbusplus::exception_t& e)
{
diff --git a/manager/manager.hpp b/manager/manager.hpp
index ea37798..0177241 100644
--- a/manager/manager.hpp
+++ b/manager/manager.hpp
@@ -130,8 +130,9 @@
*
* @return: - 0: success, -1: LED set failed
*/
- int drivePhysicalLED(const std::string& objPath, Layout::Action action,
- uint8_t dutyOn, const uint16_t period);
+ static int drivePhysicalLED(const std::string& objPath,
+ Layout::Action action, uint8_t dutyOn,
+ const uint16_t period);
/** @brief Set lamp test callback when enabled lamp test.
*
@@ -148,9 +149,6 @@
/** Map of physical LED path to service name */
std::unordered_map<std::string, std::string> phyLeds{};
- /** DBusHandler class handles the D-Bus operations */
- DBusHandler dBusHandler;
-
/** @brief Pointers to groups that are in asserted state */
std::set<const Layout::GroupLayout*> assertedGroups;