Remove redundant is_method_error() checks
The handlers registered through sdbusplus::bus::match_t only receive
D-Bus signals. Signal messages are never sent as method-error
replies, and therefore message.is_method_error() can never be true in
these callbacks.
This change removes all unnecessary is_method_error() checks from
signal handlers to simplify the code and avoid confusion.
Change-Id: I43e4a564c1bf401a5da9819dd201464e4a59c871
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/src/adc/ADCSensorMain.cpp b/src/adc/ADCSensorMain.cpp
index ae1efb9..8ce4bb0 100644
--- a/src/adc/ADCSensorMain.cpp
+++ b/src/adc/ADCSensorMain.cpp
@@ -333,11 +333,6 @@
boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
- if (message.is_method_error())
- {
- lg2::error("callback method error");
- return;
- }
sensorsChanged->insert(message.get_path());
// this implicitly cancels the timer
filterTimer.expires_after(std::chrono::seconds(1));
diff --git a/src/external/ExternalSensorMain.cpp b/src/external/ExternalSensorMain.cpp
index 04edb4f..e155b5b 100644
--- a/src/external/ExternalSensorMain.cpp
+++ b/src/external/ExternalSensorMain.cpp
@@ -348,12 +348,6 @@
std::function<void(sdbusplus::message_t&)> eventHandler =
[&objectServer, &sensors, &systemBus, &sensorsChanged, &filterTimer,
&reaperTimer](sdbusplus::message_t& message) mutable {
- if (message.is_method_error())
- {
- lg2::error("callback method error");
- return;
- }
-
const auto* messagePath = message.get_path();
sensorsChanged->insert(messagePath);
lg2::debug("ExternalSensor change event received: '{PATH}'", "PATH",
diff --git a/src/fan/FanMain.cpp b/src/fan/FanMain.cpp
index 98e41a0..b946f56 100644
--- a/src/fan/FanMain.cpp
+++ b/src/fan/FanMain.cpp
@@ -677,11 +677,6 @@
boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
- if (message.is_method_error())
- {
- lg2::error("callback method error");
- return;
- }
sensorsChanged->insert(message.get_path());
// this implicitly cancels the timer
filterTimer.expires_after(std::chrono::seconds(1));
diff --git a/src/hwmon-temp/HwmonTempMain.cpp b/src/hwmon-temp/HwmonTempMain.cpp
index 874fbf0..e9ddb5c 100644
--- a/src/hwmon-temp/HwmonTempMain.cpp
+++ b/src/hwmon-temp/HwmonTempMain.cpp
@@ -557,12 +557,6 @@
boost::container::flat_map<std::string, std::shared_ptr<HwmonTempSensor>>&
sensors)
{
- if (message.is_method_error())
- {
- lg2::error("interfacesRemoved callback method error");
- return;
- }
-
sdbusplus::message::object_path path;
std::vector<std::string> interfaces;
@@ -635,11 +629,6 @@
boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
- if (message.is_method_error())
- {
- lg2::error("callback method error");
- return;
- }
sensorsChanged->insert(message.get_path());
// this implicitly cancels the timer
filterTimer.expires_after(std::chrono::seconds(1));
diff --git a/src/intel-cpu/IntelCPUSensorMain.cpp b/src/intel-cpu/IntelCPUSensorMain.cpp
index 19b81e8..7aa7bcf 100644
--- a/src/intel-cpu/IntelCPUSensorMain.cpp
+++ b/src/intel-cpu/IntelCPUSensorMain.cpp
@@ -819,12 +819,6 @@
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
- if (message.is_method_error())
- {
- lg2::error("callback method error");
- return;
- }
-
lg2::debug("'{PATH}' is changed", "PATH", message.get_path());
// this implicitly cancels the timer
diff --git a/src/intrusion/IntrusionSensorMain.cpp b/src/intrusion/IntrusionSensorMain.cpp
index bc25fe3..2d44a56 100644
--- a/src/intrusion/IntrusionSensorMain.cpp
+++ b/src/intrusion/IntrusionSensorMain.cpp
@@ -476,12 +476,7 @@
// callback to handle configuration change
boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
- [&](sdbusplus::message_t& message) {
- if (message.is_method_error())
- {
- lg2::error("callback method error");
- return;
- }
+ [&](sdbusplus::message_t&) {
// this implicitly cancels the timer
filterTimer.expires_after(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
@@ -516,14 +511,7 @@
"type='signal', member='PropertiesChanged',path_namespace='" +
std::string(inventoryPath) + "',arg0namespace='" +
configInterfaceName(nicType) + "'",
- [&systemBus](sdbusplus::message_t& msg) {
- if (msg.is_method_error())
- {
- lg2::error("callback method error");
- return;
- }
- getNicNameInfo(systemBus);
- });
+ [&systemBus](sdbusplus::message_t&) { getNicNameInfo(systemBus); });
}
io.run();
diff --git a/src/ipmb/IpmbSensor.cpp b/src/ipmb/IpmbSensor.cpp
index a6c4ac1..978f5f4 100644
--- a/src/ipmb/IpmbSensor.cpp
+++ b/src/ipmb/IpmbSensor.cpp
@@ -682,12 +682,6 @@
boost::container::flat_map<std::string, std::shared_ptr<IpmbSensor>>&
sensors)
{
- if (message.is_method_error())
- {
- lg2::error("interfacesRemoved callback method error");
- return;
- }
-
sdbusplus::message::object_path removedPath;
std::vector<std::string> interfaces;
diff --git a/src/nvidia-gpu/NvidiaDeviceDiscovery.cpp b/src/nvidia-gpu/NvidiaDeviceDiscovery.cpp
index b682345..9c06d4b 100644
--- a/src/nvidia-gpu/NvidiaDeviceDiscovery.cpp
+++ b/src/nvidia-gpu/NvidiaDeviceDiscovery.cpp
@@ -427,12 +427,6 @@
boost::container::flat_map<std::string, std::shared_ptr<PcieDevice>>&
pcieDevices)
{
- if (message.is_method_error())
- {
- lg2::error("interfacesRemoved callback method error");
- return;
- }
-
sdbusplus::message::object_path removedPath;
std::vector<std::string> interfaces;
diff --git a/src/nvme/NVMeSensorMain.cpp b/src/nvme/NVMeSensorMain.cpp
index 0f1d9d5..76944cb 100644
--- a/src/nvme/NVMeSensorMain.cpp
+++ b/src/nvme/NVMeSensorMain.cpp
@@ -236,12 +236,6 @@
static void interfaceRemoved(sdbusplus::message_t& message, NVMEMap& contexts)
{
- if (message.is_method_error())
- {
- lg2::error("interfacesRemoved callback method error");
- return;
- }
-
sdbusplus::message::object_path path;
std::vector<std::string> interfaces;
diff --git a/src/psu/PSUSensorMain.cpp b/src/psu/PSUSensorMain.cpp
index d31c57b..9623b94 100644
--- a/src/psu/PSUSensorMain.cpp
+++ b/src/psu/PSUSensorMain.cpp
@@ -1174,11 +1174,6 @@
boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
- if (message.is_method_error())
- {
- lg2::error("callback method error");
- return;
- }
sensorsChanged->insert(message.get_path());
filterTimer.expires_after(std::chrono::seconds(3));
filterTimer.async_wait([&](const boost::system::error_code& ec) {