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: Ief05bd757cffb1453e058a719ee4b060861752e7
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 8321a8a..6823622 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -30,7 +30,7 @@
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Device::Error;
-PowerSupply::PowerSupply(sdbusplus::bus::bus& bus, const std::string& invpath,
+PowerSupply::PowerSupply(sdbusplus::bus_t& bus, const std::string& invpath,
std::uint8_t i2cbus, std::uint16_t i2caddr,
const std::string& driver,
const std::string& gpioLineName) :
@@ -143,7 +143,7 @@
{
present = getPresence(bus, inventoryPath);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
// Relying on property change or interface added to retry.
// Log an informational trace to the journal.
@@ -739,7 +739,7 @@
}
}
-void PowerSupply::inventoryChanged(sdbusplus::message::message& msg)
+void PowerSupply::inventoryChanged(sdbusplus::message_t& msg)
{
std::string msgSensor;
std::map<std::string, std::variant<uint32_t, bool>> msgData;
@@ -772,7 +772,7 @@
}
}
-void PowerSupply::inventoryAdded(sdbusplus::message::message& msg)
+void PowerSupply::inventoryAdded(sdbusplus::message_t& msg)
{
sdbusplus::message::object_path path;
msg.read(path);
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 218e2d5..a4888ec 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -63,7 +63,7 @@
* @param[in] gpioLineName - The gpio-line-name to read for presence. See
* https://github.com/openbmc/docs/blob/master/designs/device-tree-gpio-naming.md
*/
- PowerSupply(sdbusplus::bus::bus& bus, const std::string& invpath,
+ PowerSupply(sdbusplus::bus_t& bus, const std::string& invpath,
std::uint8_t i2cbus, const std::uint16_t i2caddr,
const std::string& driver, const std::string& gpioLineName);
@@ -513,7 +513,7 @@
private:
/** @brief systemd bus member */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief Will be updated to the latest/lastvalue read from STATUS_WORD.*/
uint64_t statusWord = 0;
@@ -844,7 +844,7 @@
*
* @param[in] msg - Data associated with Present change signal
**/
- void inventoryChanged(sdbusplus::message::message& msg);
+ void inventoryChanged(sdbusplus::message_t& msg);
/**
* @brief Callback for inventory property added.
@@ -856,7 +856,7 @@
*
* @param[in] msg - Data associated with Present add signal
**/
- void inventoryAdded(sdbusplus::message::message& msg);
+ void inventoryAdded(sdbusplus::message_t& msg);
/**
* @brief Reads the pmbus MFR_POUT_MAX value.
diff --git a/phosphor-power-supply/psu_manager.cpp b/phosphor-power-supply/psu_manager.cpp
index cb83a2a..ebc953f 100644
--- a/phosphor-power-supply/psu_manager.cpp
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -34,7 +34,7 @@
constexpr auto INPUT_HISTORY_SYNC_DELAY = 5;
-PSUManager::PSUManager(sdbusplus::bus::bus& bus, const sdeventplus::Event& e) :
+PSUManager::PSUManager(sdbusplus::bus_t& bus, const sdeventplus::Event& e) :
bus(bus), powerSystemInputs(bus, powerSystemsInputsObjPath),
objectManager(bus, objectManagerObjPath),
historyManager(bus, "/org/open_power/sensors")
@@ -365,7 +365,7 @@
}
}
-void PSUManager::entityManagerIfaceAdded(sdbusplus::message::message& msg)
+void PSUManager::entityManagerIfaceAdded(sdbusplus::message_t& msg)
{
try
{
@@ -405,7 +405,7 @@
}
}
-void PSUManager::powerStateChanged(sdbusplus::message::message& msg)
+void PSUManager::powerStateChanged(sdbusplus::message_t& msg)
{
std::string msgSensor;
std::map<std::string, std::variant<int>> msgData;
@@ -457,7 +457,7 @@
.c_str());
}
-void PSUManager::presenceChanged(sdbusplus::message::message& msg)
+void PSUManager::presenceChanged(sdbusplus::message_t& msg)
{
std::string msgSensor;
std::map<std::string, std::variant<uint32_t, bool>> msgData;
@@ -836,7 +836,7 @@
presProperty = getPresence(bus, psuInventoryPath);
propReadFail = false;
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
propReadFail = true;
// Relying on property change or interface added to retry.
diff --git a/phosphor-power-supply/psu_manager.hpp b/phosphor-power-supply/psu_manager.hpp
index 6f58eec..4b4171a 100644
--- a/phosphor-power-supply/psu_manager.hpp
+++ b/phosphor-power-supply/psu_manager.hpp
@@ -41,7 +41,7 @@
class PowerSystemInputs : public PowerSystemInputsObject
{
public:
- PowerSystemInputs(sdbusplus::bus::bus& bus, const std::string& path) :
+ PowerSystemInputs(sdbusplus::bus_t& bus, const std::string& path) :
PowerSystemInputsObject(bus, path.c_str())
{}
};
@@ -68,7 +68,7 @@
* @param[in] bus - D-Bus bus object
* @param[in] e - event object
*/
- PSUManager(sdbusplus::bus::bus& bus, const sdeventplus::Event& e);
+ PSUManager(sdbusplus::bus_t& bus, const sdeventplus::Event& e);
/**
* Get PSU properties from D-Bus, use that to build a power supply
@@ -138,7 +138,7 @@
/**
* The D-Bus object
*/
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/**
* The timer that runs to periodically check the power supplies.
@@ -207,7 +207,7 @@
*
* @param[in] msg - Data associated with the power state signal
*/
- void powerStateChanged(sdbusplus::message::message& msg);
+ void powerStateChanged(sdbusplus::message_t& msg);
/**
* @brief Callback for inventory property changes
@@ -216,7 +216,7 @@
*
* @param[in] msg - Data associated with the Present change signal
**/
- void presenceChanged(sdbusplus::message::message& msg);
+ void presenceChanged(sdbusplus::message_t& msg);
/**
* @brief Callback for entity-manager interface added
@@ -226,7 +226,7 @@
*
* @param[in] msg - Data associated with the interfaces added signal
*/
- void entityManagerIfaceAdded(sdbusplus::message::message& msg);
+ void entityManagerIfaceAdded(sdbusplus::message_t& msg);
/**
* @brief Adds properties to the inventory.
diff --git a/phosphor-power-supply/test/mock.hpp b/phosphor-power-supply/test/mock.hpp
index 13d22e6..d964964 100644
--- a/phosphor-power-supply/test/mock.hpp
+++ b/phosphor-power-supply/test/mock.hpp
@@ -48,18 +48,18 @@
virtual ~MockedUtil() = default;
MOCK_METHOD(bool, getPresence,
- (sdbusplus::bus::bus & bus, const std::string& invpath),
+ (sdbusplus::bus_t & bus, const std::string& invpath),
(const, override));
MOCK_METHOD(void, setPresence,
- (sdbusplus::bus::bus & bus, const std::string& invpath,
+ (sdbusplus::bus_t & bus, const std::string& invpath,
bool present, const std::string& name),
(const, override));
MOCK_METHOD(void, setAvailable,
- (sdbusplus::bus::bus & bus, const std::string& invpath,
+ (sdbusplus::bus_t & bus, const std::string& invpath,
bool available),
(const, override));
MOCK_METHOD(void, handleChassisHealthRollup,
- (sdbusplus::bus::bus & bus, const std::string& invpath,
+ (sdbusplus::bus_t & bus, const std::string& invpath,
bool addRollup),
(const, override));
};
diff --git a/phosphor-power-supply/util.hpp b/phosphor-power-supply/util.hpp
index caa5bac..01f5b0b 100644
--- a/phosphor-power-supply/util.hpp
+++ b/phosphor-power-supply/util.hpp
@@ -27,7 +27,7 @@
class Util : public UtilBase
{
public:
- bool getPresence(sdbusplus::bus::bus& bus,
+ bool getPresence(sdbusplus::bus_t& bus,
const std::string& invpath) const override
{
bool present = false;
@@ -39,7 +39,7 @@
return present;
}
- void setPresence(sdbusplus::bus::bus& bus, const std::string& invpath,
+ void setPresence(sdbusplus::bus_t& bus, const std::string& invpath,
bool present, const std::string& name) const override
{
using InternalFailure =
@@ -89,7 +89,7 @@
}
}
- void setAvailable(sdbusplus::bus::bus& bus, const std::string& invpath,
+ void setAvailable(sdbusplus::bus_t& bus, const std::string& invpath,
bool available) const override
{
PropertyMap invProp;
@@ -113,7 +113,7 @@
invMsg.append(std::move(invObj));
auto invMgrResponseMsg = bus.call(invMsg);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
using namespace phosphor::logging;
log<level::ERR>(
@@ -125,7 +125,7 @@
}
}
- void handleChassisHealthRollup(sdbusplus::bus::bus& bus,
+ void handleChassisHealthRollup(sdbusplus::bus_t& bus,
const std::string& invpath,
bool addRollup) const override
{
@@ -186,7 +186,7 @@
invpath, service, bus,
associations);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
using namespace phosphor::logging;
log<level::INFO>(fmt::format("Error trying to handle health rollup "
@@ -196,7 +196,7 @@
}
}
- std::string getChassis(sdbusplus::bus::bus& bus,
+ std::string getChassis(sdbusplus::bus_t& bus,
const std::string& invpath) const
{
// Use the 'chassis' association to find the parent chassis.
diff --git a/phosphor-power-supply/util_base.hpp b/phosphor-power-supply/util_base.hpp
index 684abdf..5d38a51 100644
--- a/phosphor-power-supply/util_base.hpp
+++ b/phosphor-power-supply/util_base.hpp
@@ -19,42 +19,40 @@
public:
virtual ~UtilBase() = default;
- virtual bool getPresence(sdbusplus::bus::bus& bus,
+ virtual bool getPresence(sdbusplus::bus_t& bus,
const std::string& invpath) const = 0;
- virtual void setPresence(sdbusplus::bus::bus& bus,
- const std::string& invpath, bool present,
- const std::string& name) const = 0;
+ virtual void setPresence(sdbusplus::bus_t& bus, const std::string& invpath,
+ bool present, const std::string& name) const = 0;
- virtual void setAvailable(sdbusplus::bus::bus& bus,
- const std::string& invpath,
+ virtual void setAvailable(sdbusplus::bus_t& bus, const std::string& invpath,
bool available) const = 0;
- virtual void handleChassisHealthRollup(sdbusplus::bus::bus& bus,
+ virtual void handleChassisHealthRollup(sdbusplus::bus_t& bus,
const std::string& invpath,
bool addRollup) const = 0;
};
const UtilBase& getUtils();
-inline bool getPresence(sdbusplus::bus::bus& bus, const std::string& invpath)
+inline bool getPresence(sdbusplus::bus_t& bus, const std::string& invpath)
{
return getUtils().getPresence(bus, invpath);
}
-inline void setPresence(sdbusplus::bus::bus& bus, const std::string& invpath,
+inline void setPresence(sdbusplus::bus_t& bus, const std::string& invpath,
bool present, const std::string& name)
{
return getUtils().setPresence(bus, invpath, present, name);
}
-inline void setAvailable(sdbusplus::bus::bus& bus, const std::string& invpath,
+inline void setAvailable(sdbusplus::bus_t& bus, const std::string& invpath,
bool available)
{
getUtils().setAvailable(bus, invpath, available);
}
-inline void handleChassisHealthRollup(sdbusplus::bus::bus& bus,
+inline void handleChassisHealthRollup(sdbusplus::bus_t& bus,
const std::string& invpath,
bool addRollup)
{