sdbusplus: use shorter type aliases
The sdbusplus headers provide shortened aliases for many types.
Switch to using them to provide better code clarity and shorter
lines. Possible replacements are for:
* bus_t
* exception_t
* manager_t
* match_t
* message_t
* object_t
* slot_t
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I3fafbe552dcf47d16fc4002fe2dd8992ba59c465
diff --git a/include/pulse_event_monitor.hpp b/include/pulse_event_monitor.hpp
index bdd1ee4..54fdd56 100644
--- a/include/pulse_event_monitor.hpp
+++ b/include/pulse_event_monitor.hpp
@@ -19,10 +19,10 @@
#include <sel_logger.hpp>
#include <sensorutils.hpp>
-inline static sdbusplus::bus::match::match
+inline static sdbusplus::bus::match_t
startPulseEventMonitor(std::shared_ptr<sdbusplus::asio::connection> conn)
{
- auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+ auto pulseEventMatcherCallback = [](sdbusplus::message_t& msg) {
std::string thresholdInterface;
boost::container::flat_map<std::string, std::variant<std::string>>
propertiesChanged;
@@ -67,8 +67,8 @@
}
};
- sdbusplus::bus::match::match pulseEventMatcher(
- static_cast<sdbusplus::bus::bus&>(*conn),
+ sdbusplus::bus::match_t pulseEventMatcher(
+ static_cast<sdbusplus::bus_t&>(*conn),
"type='signal',interface='org.freedesktop.DBus.Properties',member='"
"PropertiesChanged',arg0namespace='xyz.openbmc_project.State.Host'",
std::move(pulseEventMatcherCallback));
diff --git a/include/threshold_alarm_event_monitor.hpp b/include/threshold_alarm_event_monitor.hpp
index 21cd29d..0de281d 100644
--- a/include/threshold_alarm_event_monitor.hpp
+++ b/include/threshold_alarm_event_monitor.hpp
@@ -23,7 +23,7 @@
#include <string_view>
#include <variant>
-using sdbusMatch = std::shared_ptr<sdbusplus::bus::match::match>;
+using sdbusMatch = std::shared_ptr<sdbusplus::bus::match_t>;
static sdbusMatch warningLowAssertedMatcher;
static sdbusMatch warningLowDeassertedMatcher;
static sdbusMatch warningHighAssertedMatcher;
@@ -45,7 +45,7 @@
void generateEvent(std::string signalName,
std::shared_ptr<sdbusplus::asio::connection> conn,
- sdbusplus::message::message& msg)
+ sdbusplus::message_t& msg)
{
double assertValue;
try
@@ -152,7 +152,7 @@
thresholdEventDataTriggerReadingByte3;
// Get the sensor reading to put in the event data
- sdbusplus::message::message getSensorValue =
+ sdbusplus::message_t getSensorValue =
conn->new_method_call(msg.get_sender(), msg.get_path(),
"org.freedesktop.DBus.Properties", "GetAll");
getSensorValue.append("xyz.openbmc_project.Sensor.Value");
@@ -160,8 +160,7 @@
sensorValue;
try
{
- sdbusplus::message::message getSensorValueResp =
- conn->call(getSensorValue);
+ sdbusplus::message_t getSensorValueResp = conn->call(getSensorValue);
getSensorValueResp.read(sensorValue);
}
catch (const sdbusplus::exception_t&)
@@ -194,14 +193,14 @@
}
// Get the threshold value to put in the event data
- sdbusplus::message::message getThreshold =
+ sdbusplus::message_t getThreshold =
conn->new_method_call(msg.get_sender(), msg.get_path(),
"org.freedesktop.DBus.Properties", "Get");
getThreshold.append(thresholdInterface, event);
std::variant<double, int64_t> thresholdValue;
try
{
- sdbusplus::message::message getThresholdResp = conn->call(getThreshold);
+ sdbusplus::message_t getThresholdResp = conn->call(getThreshold);
getThresholdResp.read(thresholdValue);
}
catch (const sdbusplus::exception_t&)
@@ -251,10 +250,10 @@
{
for (auto iter = matchers.begin(); iter != matchers.end(); iter++)
{
- iter->second = std::make_shared<sdbusplus::bus::match::match>(
- static_cast<sdbusplus::bus::bus&>(*conn),
+ iter->second = std::make_shared<sdbusplus::bus::match_t>(
+ static_cast<sdbusplus::bus_t&>(*conn),
"type='signal',member=" + iter->first,
- [conn, iter](sdbusplus::message::message& msg) {
+ [conn, iter](sdbusplus::message_t& msg) {
generateEvent(iter->first, conn, msg);
});
}
diff --git a/include/threshold_event_monitor.hpp b/include/threshold_event_monitor.hpp
index cd5397a..a8cf83c 100644
--- a/include/threshold_event_monitor.hpp
+++ b/include/threshold_event_monitor.hpp
@@ -34,11 +34,10 @@
static const std::string openBMCMessageRegistryVersion("0.1");
-inline static sdbusplus::bus::match::match startThresholdAssertMonitor(
+inline static sdbusplus::bus::match_t startThresholdAssertMonitor(
std::shared_ptr<sdbusplus::asio::connection> conn)
{
- auto thresholdAssertMatcherCallback = [conn](sdbusplus::message::message&
- msg) {
+ auto thresholdAssertMatcherCallback = [conn](sdbusplus::message_t& msg) {
// This static set of std::pair<path, event> tracks asserted events to
// avoid duplicate logs or deasserts logged without an assert
static boost::container::flat_set<std::pair<std::string, std::string>>
@@ -114,7 +113,7 @@
thresholdEventDataTriggerReadingByte3;
// Get the sensor reading to put in the event data
- sdbusplus::message::message getSensorValue =
+ sdbusplus::message_t getSensorValue =
conn->new_method_call(msg.get_sender(), msg.get_path(),
"org.freedesktop.DBus.Properties", "GetAll");
getSensorValue.append("xyz.openbmc_project.Sensor.Value");
@@ -122,7 +121,7 @@
sensorValue;
try
{
- sdbusplus::message::message getSensorValueResp =
+ sdbusplus::message_t getSensorValueResp =
conn->call(getSensorValue);
getSensorValueResp.read(sensorValue);
}
@@ -164,15 +163,14 @@
{
event.erase(pos, alarm.length());
}
- sdbusplus::message::message getThreshold =
+ sdbusplus::message_t getThreshold =
conn->new_method_call(msg.get_sender(), msg.get_path(),
"org.freedesktop.DBus.Properties", "Get");
getThreshold.append(thresholdInterface, event);
std::variant<double, int64_t> thresholdValue;
try
{
- sdbusplus::message::message getThresholdResp =
- conn->call(getThreshold);
+ sdbusplus::message_t getThresholdResp = conn->call(getThreshold);
getThresholdResp.read(thresholdValue);
}
catch (const sdbusplus::exception_t&)
@@ -275,8 +273,8 @@
"REDFISH_MESSAGE_ARGS=%.*s,%f,%f", sensorName.length(),
sensorName.data(), assertValue, thresholdVal);
};
- sdbusplus::bus::match::match thresholdAssertMatcher(
- static_cast<sdbusplus::bus::bus&>(*conn),
+ sdbusplus::bus::match_t thresholdAssertMatcher(
+ static_cast<sdbusplus::bus_t&>(*conn),
"type='signal', member='ThresholdAsserted'",
std::move(thresholdAssertMatcherCallback));
return thresholdAssertMatcher;
diff --git a/include/watchdog_event_monitor.hpp b/include/watchdog_event_monitor.hpp
index 84b8cb7..facb282 100644
--- a/include/watchdog_event_monitor.hpp
+++ b/include/watchdog_event_monitor.hpp
@@ -55,13 +55,13 @@
inline static void sendWatchdogEventLog(
std::shared_ptr<sdbusplus::asio::connection> conn,
- sdbusplus::message::message& msg, bool assert,
+ sdbusplus::message_t& msg, bool assert,
std::optional<std::string_view> expireAction = std::nullopt)
{
// SEL event data is three bytes where 0xFF means unspecified
std::vector<uint8_t> eventData(selEvtDataMaxSize, 0xFF);
- sdbusplus::message::message getWatchdogStatus =
+ sdbusplus::message_t getWatchdogStatus =
conn->new_method_call(msg.get_sender(), msg.get_path(),
"org.freedesktop.DBus.Properties", "GetAll");
getWatchdogStatus.append("xyz.openbmc_project.State.Watchdog");
@@ -71,7 +71,7 @@
try
{
- sdbusplus::message::message getWatchdogStatusResp =
+ sdbusplus::message_t getWatchdogStatusResp =
conn->call(getWatchdogStatus);
getWatchdogStatusResp.read(watchdogStatus);
}
@@ -186,7 +186,7 @@
// get watchdog status properties
static bool wdt_nolog;
- sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+ sdbusplus::bus_t bus = sdbusplus::bus::new_default();
uint8_t netFn = 0x06;
uint8_t lun = 0x00;
uint8_t cmd = 0x25;
@@ -234,23 +234,22 @@
}
}
-inline static sdbusplus::bus::match::match
+inline static sdbusplus::bus::match_t
startWatchdogEventMonitor(std::shared_ptr<sdbusplus::asio::connection> conn)
{
- auto watchdogEventMatcherCallback =
- [conn](sdbusplus::message::message& msg) {
- std::string expiredAction;
- msg.read(expiredAction);
+ auto watchdogEventMatcherCallback = [conn](sdbusplus::message_t& msg) {
+ std::string expiredAction;
+ msg.read(expiredAction);
- std::string_view action = expiredAction;
- action.remove_prefix(
- std::min(action.find_last_of(".") + 1, action.size()));
+ std::string_view action = expiredAction;
+ action.remove_prefix(
+ std::min(action.find_last_of(".") + 1, action.size()));
- sendWatchdogEventLog(conn, msg, true, action);
- };
+ sendWatchdogEventLog(conn, msg, true, action);
+ };
- sdbusplus::bus::match::match watchdogEventMatcher(
- static_cast<sdbusplus::bus::bus&>(*conn),
+ sdbusplus::bus::match_t watchdogEventMatcher(
+ static_cast<sdbusplus::bus_t&>(*conn),
"type='signal',interface='xyz.openbmc_project.Watchdog',"
"member='Timeout'",
std::move(watchdogEventMatcherCallback));
diff --git a/src/sel_logger.cpp b/src/sel_logger.cpp
index b7f6a77..29cbd46 100644
--- a/src/sel_logger.cpp
+++ b/src/sel_logger.cpp
@@ -140,13 +140,13 @@
// Reload rsyslog so it knows to start new log files
boost::asio::io_service io;
auto dbus = std::make_shared<sdbusplus::asio::connection>(io);
- sdbusplus::message::message rsyslogReload = dbus->new_method_call(
+ sdbusplus::message_t rsyslogReload = dbus->new_method_call(
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager", "ReloadUnit");
rsyslogReload.append("rsyslog.service", "replace");
try
{
- sdbusplus::message::message reloadResponse = dbus->call(rsyslogReload);
+ sdbusplus::message_t reloadResponse = dbus->call(rsyslogReload);
}
catch (const sdbusplus::exception_t& e)
{
@@ -289,17 +289,16 @@
ifaceAddSel->initialize();
#ifdef SEL_LOGGER_MONITOR_THRESHOLD_EVENTS
- sdbusplus::bus::match::match thresholdAssertMonitor =
+ sdbusplus::bus::match_t thresholdAssertMonitor =
startThresholdAssertMonitor(conn);
#endif
#ifdef REDFISH_LOG_MONITOR_PULSE_EVENTS
- sdbusplus::bus::match::match pulseEventMonitor =
- startPulseEventMonitor(conn);
+ sdbusplus::bus::match_t pulseEventMonitor = startPulseEventMonitor(conn);
#endif
#ifdef SEL_LOGGER_MONITOR_WATCHDOG_EVENTS
- sdbusplus::bus::match::match watchdogEventMonitor =
+ sdbusplus::bus::match_t watchdogEventMonitor =
startWatchdogEventMonitor(conn);
#endif