use new sdbusplus match constructors
Change-Id: Id833073b9e45fae24d6bd0e7f9310ef0ba8658de
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/fault-monitor/fru-fault-monitor.cpp b/fault-monitor/fru-fault-monitor.cpp
index e21727b..8bf27f2 100644
--- a/fault-monitor/fru-fault-monitor.cpp
+++ b/fault-monitor/fru-fault-monitor.cpp
@@ -117,22 +117,19 @@
return;
}
-int Add::created(sd_bus_message* msg,
- void* data,
- sd_bus_error* retError)
+void Add::created(sdbusplus::message::message& msg)
{
- auto m = sdbusplus::message::message(msg);
- auto bus = m.get_bus();
+ auto bus = msg.get_bus();
sdbusplus::message::object_path obPath;
- m.read(obPath);
+ msg.read(obPath);
std::string objectPath(std::move(obPath));
std::size_t found = objectPath.find(ELOG_ENTRY);
if (found == std::string::npos)
{
//Not a new error entry skip
- return 0;
+ return;
}
std::string service;
@@ -143,12 +140,12 @@
catch (MethodErr& e)
{
commit<MethodErr>();
- return 0;
+ return;
}
catch (ObjectNotFoundErr& e)
{
commit<ObjectNotFoundErr>();
- return 0;
+ return;
}
auto method = bus.new_method_call(service.c_str(), objectPath.c_str(),
@@ -164,7 +161,7 @@
report<AssociationRetrieveErr>(
AssociationRetrieveError::ELOG_ENTRY_PATH(
objectPath.c_str()));
- return 0;
+ return;
}
sdbusplus::message::variant<AssociationList> assoc;
@@ -175,7 +172,7 @@
if (assocs.empty())
{
//No associations skip
- return 0;
+ return;
}
for (const auto& item : assocs)
@@ -183,46 +180,43 @@
if (std::get<1>(item).compare(CALLOUT_REV_ASSOCIATION) == 0)
{
action(bus, std::get<2>(item), true);
- static_cast<Add*>(data)->removeWatches.emplace_back(
- std::make_unique<Remove>(bus, std::get<2>(item)));
+ removeWatches.emplace_back(
+ std::make_unique<Remove>(bus, std::get<2>(item)));
}
}
- return 0;
+ return;
}
-int Remove::removed(sd_bus_message* msg,
- void* data,
- sd_bus_error* retError)
+void Remove::removed(sdbusplus::message::message& msg)
{
- auto m = sdbusplus::message::message(msg);
- auto bus = m.get_bus();
+ auto bus = msg.get_bus();
std::string assoc;
- m.read(assoc);
+ msg.read(assoc);
if (assoc.compare("org.openbmc.Association"))
{
//Skip if not about association
- return 0;
+ return;
}
std::map<std::string, std::vector<std::string>> endPoints;
- m.read(endPoints);
+ msg.read(endPoints);
auto it = endPoints.find("endpoints");
if (it == endPoints.end())
{
//No end points,skip
- return 0;
+ return;
}
if (!((*it).second.empty()))
{
//Skip, end points are not empty
- return 0;
+ return;
}
- action(bus, static_cast<Remove*>(data)->inventoryPath, false);
- return 0;
+ action(bus, inventoryPath, false);
+ return;
}
}//namespace monitor
diff --git a/fault-monitor/fru-fault-monitor.hpp b/fault-monitor/fru-fault-monitor.hpp
index 8d5195d..b686560 100644
--- a/fault-monitor/fru-fault-monitor.hpp
+++ b/fault-monitor/fru-fault-monitor.hpp
@@ -47,31 +47,25 @@
Add(sdbusplus::bus::bus& bus):
matchCreated(
bus,
- "type='signal',"
- "interface='org.freedesktop.DBus.ObjectManager',"
- "member='InterfacesAdded',"
- "path_namespace='/xyz/openbmc_project/logging'",
- created,
- this)
+ sdbusplus::bus::match::rules::interfacesAdded() +
+ sdbusplus::bus::match::rules::path_namespace(
+ "/xyz/openbmc_project/logging"),
+ std::bind(std::mem_fn(&Add::created),
+ this, std::placeholders::_1))
{
//Do nothing
}
private:
/** @brief sdbusplus signal match for fault created */
- sdbusplus::server::match::match matchCreated;
+ sdbusplus::bus::match_t matchCreated;
std::vector<std::unique_ptr<Remove>> removeWatches;
/** @brief Callback function for fru fault created
* @param[in] msg - Data associated with subscribed signal
- * @param[in] data - Pointer to this object instance
- * @param[out] retError - Error returned
- * @return zero on success and error code upon failure
*/
- static int created(sd_bus_message* msg,
- void* data,
- sd_bus_error* retError);
+ void created(sdbusplus::message::message& msg);
};
/** @class Remove
@@ -97,9 +91,9 @@
inventoryPath(path),
matchRemoved(
bus,
- match(path).c_str(),
- removed,
- this)
+ match(path),
+ std::bind(std::mem_fn(&Remove::removed),
+ this, std::placeholders::_1))
{
//Do nothing
}
@@ -110,29 +104,26 @@
std::string inventoryPath;
/** @brief sdbusplus signal matches for fault removed */
- sdbusplus::server::match::match matchRemoved;
+ sdbusplus::bus::match_t matchRemoved;
/** @brief Callback function for fru fault created
* @param[in] msg - Data associated with subscribed signal
- * @param[in] data - Pointer to this object instance
- * @param[out] retError - Error returned
- * @return zero on success and error code upon failure
*/
- static int removed(sd_bus_message* msg,
- void* data,
- sd_bus_error* retError);
+ void removed(sdbusplus::message::message& msg);
/** @brief function to create fault remove match for a fru
* @param[in] path - Inventory path of the faulty unit.
*/
std::string match(const std::string& path)
{
+ namespace MatchRules = sdbusplus::bus::match::rules;
+
std::string matchStmt =
- "type='signal',"
- "interface='org.freedesktop.DBus.Properties',"
- "member='PropertiesChanged',"
- "path='" + path +
- "/" + CALLOUT_REV_ASSOCIATION + "'";
+ MatchRules::type::signal() +
+ MatchRules::interface("org.freedesktop.DBus.Properties") +
+ MatchRules::member("PropertiesChanged") +
+ MatchRules::path(path + "/" + CALLOUT_REV_ASSOCIATION);
+
return matchStmt;
}
};