clang-tidy: Enable modernize-avoid-bind check
The check finds uses of std::bind and boost::bind and replaces them
with lambdas.
Lambdas will use value-capture unless reference capture is explicitly
requested with std::ref or boost::ref.
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I4491650a46eaab1588474b26efc622e89232ef02
diff --git a/manager/json-config.hpp b/manager/json-config.hpp
index 64441b3..d02af56 100644
--- a/manager/json-config.hpp
+++ b/manager/json-config.hpp
@@ -41,8 +41,7 @@
sdbusplus::bus::match::rules::interfacesAdded() +
sdbusplus::bus::match::rules::sender(
"xyz.openbmc_project.EntityManager"),
- std::bind(&JsonConfig::ifacesAddedCallback, this,
- std::placeholders::_1));
+ [this](sdbusplus::message_t& m) { ifacesAddedCallback(m); });
getFilePath();
if (!confFile.empty())
diff --git a/manager/lamptest/lamptest.hpp b/manager/lamptest/lamptest.hpp
index 1d9dd86..c7804c8 100644
--- a/manager/lamptest/lamptest.hpp
+++ b/manager/lamptest/lamptest.hpp
@@ -38,8 +38,8 @@
* @param[in] manager - reference to manager instance
*/
LampTest(const sdeventplus::Event& event, Manager& manager) :
- timer(event, std::bind(std::mem_fn(&LampTest::timeOutHandler), this)),
- manager(manager), groupObj(NULL)
+ timer(event, [this](auto&) { timeOutHandler(); }), manager(manager),
+ groupObj(NULL)
{
// Get the force update and/or skipped physical LEDs names from the
// lamp-test-led-overrides.json file during lamp
diff --git a/manager/led-main.cpp b/manager/led-main.cpp
index 450f4d7..7791747 100644
--- a/manager/led-main.cpp
+++ b/manager/led-main.cpp
@@ -70,14 +70,17 @@
groups.emplace_back(std::make_unique<phosphor::led::Group>(
bus, LAMP_TEST_OBJECT, manager, serializePtr,
- std::bind(std::mem_fn(&phosphor::led::LampTest::requestHandler),
- &lampTest, std::placeholders::_1, std::placeholders::_2)));
+ [&lampTest](auto&& arg1, auto&& arg2) {
+ return lampTest.requestHandler(std::forward<decltype(arg1)>(arg1),
+ std::forward<decltype(arg2)>(arg2));
+ }));
// Register a lamp test method in the manager class, and call this method
// when the lamp test is started
- manager.setLampTestCallBack(
- std::bind(std::mem_fn(&phosphor::led::LampTest::processLEDUpdates),
- &lampTest, std::placeholders::_1, std::placeholders::_2));
+ manager.setLampTestCallBack([&lampTest](auto&& arg1, auto&& arg2) {
+ return lampTest.processLEDUpdates(std::forward<decltype(arg1)>(arg1),
+ std::forward<decltype(arg2)>(arg2));
+ });
#endif
/** Now create so many dbus objects as there are groups */