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: I223d58649a21565678bd7ef78d955b30d3fd6d84
diff --git a/fault-monitor/fru-fault-monitor.cpp b/fault-monitor/fru-fault-monitor.cpp
index e1941cf..d0f5d00 100644
--- a/fault-monitor/fru-fault-monitor.cpp
+++ b/fault-monitor/fru-fault-monitor.cpp
@@ -47,7 +47,7 @@
using InvalidArgumentErr =
sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
-std::string getService(sdbusplus::bus::bus& bus, const std::string& path)
+std::string getService(sdbusplus::bus_t& bus, const std::string& path)
{
auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_OBJ_PATH,
MAPPER_IFACE, "GetObject");
@@ -59,7 +59,7 @@
auto mapperResponseMsg = bus.call(mapper);
mapperResponseMsg.read(mapperResponse);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error(
"Failed to parse getService mapper response, ERROR = {ERROR}",
@@ -77,7 +77,7 @@
return mapperResponse.cbegin()->first;
}
-void action(sdbusplus::bus::bus& bus, const std::string& path, bool assert)
+void action(sdbusplus::bus_t& bus, const std::string& path, bool assert)
{
std::string service;
try
@@ -116,7 +116,7 @@
{
bus.call_noreply(method);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
// Log an info message, system may not have all the LED Groups defined
lg2::info("Failed to Assert LED Group, ERROR = {ERROR}", "ERROR", e);
@@ -125,7 +125,7 @@
return;
}
-void Add::created(sdbusplus::message::message& msg)
+void Add::created(sdbusplus::message_t& msg)
{
auto bus = msg.get_bus();
@@ -135,7 +135,7 @@
{
msg.read(objectPath, interfaces);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error("Failed to parse created message, ERROR = {ERROR}", "ERROR",
e);
@@ -186,7 +186,7 @@
return;
}
-void getLoggingSubTree(sdbusplus::bus::bus& bus, MapperResponseType& subtree)
+void getLoggingSubTree(sdbusplus::bus_t& bus, MapperResponseType& subtree)
{
auto depth = 0;
auto mapperCall = bus.new_method_call(MAPPER_BUSNAME, MAPPER_OBJ_PATH,
@@ -200,7 +200,7 @@
auto mapperResponseMsg = bus.call(mapperCall);
mapperResponseMsg.read(subtree);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error(
"Failed to parse existing callouts subtree message, ERROR = {ERROR}",
@@ -208,7 +208,7 @@
}
}
-void Add::processExistingCallouts(sdbusplus::bus::bus& bus)
+void Add::processExistingCallouts(sdbusplus::bus_t& bus)
{
MapperResponseType mapperResponse;
@@ -239,7 +239,7 @@
{
reply.read(assoc);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error(
"Failed to parse existing callouts associations message, ERROR = {ERROR}",
@@ -265,7 +265,7 @@
}
}
-void Remove::removed(sdbusplus::message::message& msg)
+void Remove::removed(sdbusplus::message_t& msg)
{
auto bus = msg.get_bus();
diff --git a/fault-monitor/fru-fault-monitor.hpp b/fault-monitor/fru-fault-monitor.hpp
index 923a0f9..028e873 100644
--- a/fault-monitor/fru-fault-monitor.hpp
+++ b/fault-monitor/fru-fault-monitor.hpp
@@ -23,7 +23,7 @@
* @param[in] path - Inventory path of the FRU
* @param[in] assert - Assert if true deassert if false
*/
-void action(sdbusplus::bus::bus& bus, const std::string& path, bool assert);
+void action(sdbusplus::bus_t& bus, const std::string& path, bool assert);
class Remove;
@@ -45,7 +45,7 @@
/** @brief constructs Add a watch for FRU faults.
* @param[in] bus - The Dbus bus object
*/
- explicit Add(sdbusplus::bus::bus& bus) :
+ explicit Add(sdbusplus::bus_t& bus) :
matchCreated(
bus,
sdbusplus::bus::match::rules::interfacesAdded() +
@@ -65,12 +65,12 @@
/** @brief Callback function for fru fault created
* @param[in] msg - Data associated with subscribed signal
*/
- void created(sdbusplus::message::message& msg);
+ void created(sdbusplus::message_t& msg);
/** @brief This function process all callouts at application start
* @param[in] bus - The Dbus bus object
*/
- void processExistingCallouts(sdbusplus::bus::bus& bus);
+ void processExistingCallouts(sdbusplus::bus_t& bus);
};
/** @class Remove
@@ -92,7 +92,7 @@
* @param[in] bus - The Dbus bus object
* @param[in] path - Inventory path to fru
*/
- Remove(sdbusplus::bus::bus& bus, const std::string& path) :
+ Remove(sdbusplus::bus_t& bus, const std::string& path) :
inventoryPath(path),
matchRemoved(bus, match(path),
std::bind(std::mem_fn(&Remove::removed), this,
@@ -111,7 +111,7 @@
/** @brief Callback function for fru fault created
* @param[in] msg - Data associated with subscribed signal
*/
- void removed(sdbusplus::message::message& msg);
+ void removed(sdbusplus::message_t& msg);
/** @brief function to create fault remove match for a fru
* @param[in] path - Inventory path of the faulty unit.
diff --git a/fault-monitor/monitor-main.cpp b/fault-monitor/monitor-main.cpp
index f4e2182..92b332d 100644
--- a/fault-monitor/monitor-main.cpp
+++ b/fault-monitor/monitor-main.cpp
@@ -9,7 +9,7 @@
int main(void)
{
/** @brief Dbus constructs used by Fault Monitor */
- sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+ sdbusplus::bus_t bus = sdbusplus::bus::new_default();
#ifdef MONITOR_OPERATIONAL_STATUS
phosphor::led::Operational::status::monitor::Monitor monitor(bus);
diff --git a/fault-monitor/operational-status-monitor.cpp b/fault-monitor/operational-status-monitor.cpp
index 1114463..26ee918 100644
--- a/fault-monitor/operational-status-monitor.cpp
+++ b/fault-monitor/operational-status-monitor.cpp
@@ -14,7 +14,7 @@
namespace monitor
{
-void Monitor::matchHandler(sdbusplus::message::message& msg)
+void Monitor::matchHandler(sdbusplus::message_t& msg)
{
// Get the ObjectPath of the `xyz.openbmc_project.Inventory.Manager`
// service
@@ -72,7 +72,7 @@
"xyz.openbmc_project.Association",
"endpoints");
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error(
"Failed to get endpoints property, ERROR = {ERROR}, PATH = {PATH}",
@@ -98,7 +98,7 @@
dBusHandler.setProperty(path, "xyz.openbmc_project.Led.Group",
"Asserted", assertedValue);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error(
"Failed to set Asserted property, ERROR = {ERROR}, PATH = {PATH}",
diff --git a/fault-monitor/operational-status-monitor.hpp b/fault-monitor/operational-status-monitor.hpp
index 3fa995d..3b67edb 100644
--- a/fault-monitor/operational-status-monitor.hpp
+++ b/fault-monitor/operational-status-monitor.hpp
@@ -39,7 +39,7 @@
*
* @param[in] bus - D-Bus object
*/
- explicit Monitor(sdbusplus::bus::bus& bus) :
+ explicit Monitor(sdbusplus::bus_t& bus) :
bus(bus),
matchSignal(bus,
"type='signal',member='PropertiesChanged', "
@@ -54,7 +54,7 @@
private:
/** @brief sdbusplus D-Bus connection. */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief sdbusplus signal matches for Monitor */
sdbusplus::bus::match_t matchSignal;
@@ -70,7 +70,7 @@
*
* @param[in] msg - The D-Bus message contents
*/
- void matchHandler(sdbusplus::message::message& msg);
+ void matchHandler(sdbusplus::message_t& msg);
/**
* @brief From the Inventory D-Bus object, obtains the associated LED group
diff --git a/manager/group.hpp b/manager/group.hpp
index 520ba43..aec0e85 100644
--- a/manager/group.hpp
+++ b/manager/group.hpp
@@ -41,8 +41,8 @@
* @param[in] serialize - Serialize object
* @param[in] callBack - Custom callback when LED group is asserted
*/
- Group(sdbusplus::bus::bus& bus, const std::string& objPath,
- Manager& manager, Serialize& serialize,
+ Group(sdbusplus::bus_t& bus, const std::string& objPath, Manager& manager,
+ Serialize& serialize,
std::function<void(Group*, bool)> callBack = nullptr) :
GroupInherit(bus, objPath.c_str(), GroupInherit::action::defer_emit),
diff --git a/manager/json-config.hpp b/manager/json-config.hpp
index 3b836a1..2c4e16d 100644
--- a/manager/json-config.hpp
+++ b/manager/json-config.hpp
@@ -34,8 +34,7 @@
* @param[in] bus - The D-Bus object
* @param[in] event - sd event handler
*/
- JsonConfig(sdbusplus::bus::bus& bus, sdeventplus::Event& event) :
- event(event)
+ JsonConfig(sdbusplus::bus_t& bus, sdeventplus::Event& event) : event(event)
{
match = std::make_unique<sdbusplus::bus::match_t>(
bus,
@@ -93,7 +92,7 @@
*
* @param[in] msg - The D-Bus message contents
*/
- void ifacesAddedCallback(sdbusplus::message::message& msg)
+ void ifacesAddedCallback(sdbusplus::message_t& msg)
{
sdbusplus::message::object_path path;
std::unordered_map<
@@ -183,7 +182,7 @@
}
confFile.clear();
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
// Property unavailable on object.
lg2::error(
@@ -195,7 +194,7 @@
}
}
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error(
"Failed to call the SubTreePaths method, ERROR = {ERROR}, INTERFACE = {INTERFACE}",
diff --git a/manager/lamptest/lamptest.cpp b/manager/lamptest/lamptest.cpp
index 99d0318..57e5a33 100644
--- a/manager/lamptest/lamptest.cpp
+++ b/manager/lamptest/lamptest.cpp
@@ -142,7 +142,7 @@
period = std::get<uint16_t>(properties["Period"]);
dutyOn = std::get<uint8_t>(properties["DutyOn"]);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error(
"Failed to get All properties, ERROR = {ERROR}, PATH = {PATH}",
@@ -254,7 +254,7 @@
"xyz.openbmc_project.Led.Group", "Asserted",
assertedValue);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error(
"Failed to set Asserted property, ERROR = {ERROR}, PATH = {PATH}",
diff --git a/manager/led-main.cpp b/manager/led-main.cpp
index a6f8f82..86c13f5 100644
--- a/manager/led-main.cpp
+++ b/manager/led-main.cpp
@@ -45,7 +45,7 @@
phosphor::led::Manager manager(bus, systemLedMap);
/** @brief sd_bus object manager */
- sdbusplus::server::manager::manager objManager(bus, OBJPATH);
+ sdbusplus::server::manager_t objManager(bus, OBJPATH);
/** @brief vector of led groups */
std::vector<std::unique_ptr<phosphor::led::Group>> groups;
diff --git a/manager/manager.hpp b/manager/manager.hpp
index 2fbc7f2..ac00d76 100644
--- a/manager/manager.hpp
+++ b/manager/manager.hpp
@@ -76,7 +76,7 @@
* @param [in] bus - sdbusplus handler
* @param [in] GroupMap - LEDs group layout
*/
- Manager(sdbusplus::bus::bus& bus, const GroupMap& ledLayout) :
+ Manager(sdbusplus::bus_t& bus, const GroupMap& ledLayout) :
ledMap(ledLayout), bus(bus)
{
// Nothing here
@@ -126,7 +126,7 @@
private:
/** @brief sdbusplus handler */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** Map of physical LED path to service name */
std::unordered_map<std::string, std::string> phyLeds{};
diff --git a/test/utest.cpp b/test/utest.cpp
index 9375600..2bd222b 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -11,7 +11,7 @@
class LedTest : public ::testing::Test
{
public:
- sdbusplus::bus::bus bus;
+ sdbusplus::bus_t bus;
LedTest() : bus(sdbusplus::bus::new_default())
{
// Nothing here
diff --git a/utils.hpp b/utils.hpp
index edf4f8e..afc5120 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -62,7 +62,7 @@
*
* @return The Map to constructs all properties values
*
- * @throw sdbusplus::exception::exception when it fails
+ * @throw sdbusplus::exception_t when it fails
*/
const PropertyMap getAllProperties(const std::string& objectPath,
const std::string& interface) const;
@@ -75,7 +75,7 @@
*
* @return The value of the property(type: variant)
*
- * @throw sdbusplus::exception::exception when it fails
+ * @throw sdbusplus::exception_t when it fails
*/
const PropertyValue getProperty(const std::string& objectPath,
const std::string& interface,
@@ -88,7 +88,7 @@
* @param[in] propertyName - D-Bus property name
* @param[in] value - The value to be set
*
- * @throw sdbusplus::exception::exception when it fails
+ * @throw sdbusplus::exception_t when it fails
*/
void setProperty(const std::string& objectPath,
const std::string& interface,