Skip to content

Commit b3ef4e1

Browse files
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 <[email protected]> Change-Id: I19e094a2a99893627dbb82b615f630b87ad90fdd
1 parent 2f64e42 commit b3ef4e1

15 files changed

+37
-38
lines changed

mainapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ constexpr auto USER_MANAGER_ROOT = "/xyz/openbmc_project/user";
2525
int main(int /*argc*/, char** /*argv*/)
2626
{
2727
auto bus = sdbusplus::bus::new_default();
28-
sdbusplus::server::manager::manager objManager(bus, USER_MANAGER_ROOT);
28+
sdbusplus::server::manager_t objManager(bus, USER_MANAGER_ROOT);
2929

3030
phosphor::user::UserMgr userMgr(bus, USER_MANAGER_ROOT);
3131

phosphor-ldap-config/ldap_config.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ using Key = std::string;
4949
using Val = std::string;
5050
using ConfigInfo = std::map<Key, Val>;
5151

52-
Config::Config(sdbusplus::bus::bus& bus, const char* path, const char* filePath,
52+
Config::Config(sdbusplus::bus_t& bus, const char* path, const char* filePath,
5353
const char* caCertFile, const char* certFile, bool secureLDAP,
5454
std::string ldapServerURI, std::string ldapBindDN,
5555
std::string ldapBaseDN, std::string&& ldapBindDNPassword,
@@ -106,7 +106,7 @@ Config::Config(sdbusplus::bus::bus& bus, const char* path, const char* filePath,
106106
parent.startOrStopService(nslcdService, enabled());
107107
}
108108

109-
Config::Config(sdbusplus::bus::bus& bus, const char* path, const char* filePath,
109+
Config::Config(sdbusplus::bus_t& bus, const char* path, const char* filePath,
110110
const char* caCertFile, const char* certFile,
111111
ConfigIface::Type ldapType, ConfigMgr& parent) :
112112
Ifaces(bus, path, Ifaces::action::defer_emit),
@@ -137,7 +137,7 @@ Config::Config(sdbusplus::bus::bus& bus, const char* path, const char* filePath,
137137
configPersistPath += "/config";
138138
}
139139

140-
void Config::certificateInstalled(sdbusplus::message::message& /*msg*/)
140+
void Config::certificateInstalled(sdbusplus::message_t& /*msg*/)
141141
{
142142
try
143143
{
@@ -158,7 +158,7 @@ void Config::certificateInstalled(sdbusplus::message::message& /*msg*/)
158158
}
159159
}
160160

161-
void Config::certificateChanged(sdbusplus::message::message& msg)
161+
void Config::certificateChanged(sdbusplus::message_t& msg)
162162
{
163163
std::string objectName;
164164
std::map<std::string, std::variant<std::string>> msgData;

phosphor-ldap-config/ldap_config.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ using namespace phosphor::logging;
2828
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
2929
using ConfigIface = sdbusplus::xyz::openbmc_project::User::Ldap::server::Config;
3030
using EnableIface = sdbusplus::xyz::openbmc_project::Object::server::Enable;
31-
using CreateIface = sdbusplus::server::object::object<
31+
using CreateIface = sdbusplus::server::object_t<
3232
sdbusplus::xyz::openbmc_project::User::Ldap::server::Create>;
3333
namespace fs = std::filesystem;
3434
using MapperIface =
3535
sdbusplus::xyz::openbmc_project::User::server::PrivilegeMapper;
3636

3737
using Ifaces =
38-
sdbusplus::server::object::object<ConfigIface, EnableIface, MapperIface>;
38+
sdbusplus::server::object_t<ConfigIface, EnableIface, MapperIface>;
3939
using ObjectPath = sdbusplus::message::object_path;
4040

4141
namespace sdbusRule = sdbusplus::bus::match::rules;
@@ -82,7 +82,7 @@ class Config : public Ifaces
8282
* @param[in] parent - parent of config object.
8383
*/
8484

85-
Config(sdbusplus::bus::bus& bus, const char* path, const char* filePath,
85+
Config(sdbusplus::bus_t& bus, const char* path, const char* filePath,
8686
const char* caCertFile, const char* certFile, bool secureLDAP,
8787
std::string ldapServerURI, std::string ldapBindDN,
8888
std::string ldapBaseDN, std::string&& ldapBindDNPassword,
@@ -98,7 +98,7 @@ class Config : public Ifaces
9898
* or openLDAP.
9999
* @param[in] parent - parent of config object.
100100
*/
101-
Config(sdbusplus::bus::bus& bus, const char* path, const char* filePath,
101+
Config(sdbusplus::bus_t& bus, const char* path, const char* filePath,
102102
const char* caCertFile, const char* certFile,
103103
ConfigIface::Type ldapType, ConfigMgr& parent);
104104

@@ -257,7 +257,7 @@ class Config : public Ifaces
257257
std::filesystem::path configPersistPath{};
258258

259259
/** @brief Persistent sdbusplus D-Bus bus connection. */
260-
sdbusplus::bus::bus& bus;
260+
sdbusplus::bus_t& bus;
261261

262262
/** @brief Create a new LDAP config file.
263263
*/
@@ -283,15 +283,15 @@ class Config : public Ifaces
283283
/** @brief React to InterfaceAdded signal
284284
* @param[in] msg - sdbusplus message
285285
*/
286-
void certificateInstalled(sdbusplus::message::message& msg);
286+
void certificateInstalled(sdbusplus::message_t& msg);
287287
sdbusplus::bus::match_t certificateInstalledSignal;
288288

289289
sdbusplus::bus::match_t cacertificateInstalledSignal;
290290

291291
/** @brief React to certificate changed signal
292292
* @param[in] msg - sdbusplus message
293293
*/
294-
void certificateChanged(sdbusplus::message::message& msg);
294+
void certificateChanged(sdbusplus::message_t& msg);
295295
sdbusplus::bus::match_t certificateChangedSignal;
296296

297297
friend class MockConfigMgr;

phosphor-ldap-config/ldap_config_mgr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void ConfigMgr::restartService(const std::string& service)
5050
method.append(service.c_str(), "replace");
5151
bus.call_noreply(method);
5252
}
53-
catch (const sdbusplus::exception::exception& ex)
53+
catch (const sdbusplus::exception_t& ex)
5454
{
5555
log<level::ERR>("Failed to restart service",
5656
entry("SERVICE=%s", service.c_str()),
@@ -67,7 +67,7 @@ void ConfigMgr::stopService(const std::string& service)
6767
method.append(service.c_str(), "replace");
6868
bus.call_noreply(method);
6969
}
70-
catch (const sdbusplus::exception::exception& ex)
70+
catch (const sdbusplus::exception_t& ex)
7171
{
7272
log<level::ERR>("Failed to stop service",
7373
entry("SERVICE=%s", service.c_str()),

phosphor-ldap-config/ldap_config_mgr.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static auto ADDbusObjectPath =
2727

2828
using namespace phosphor::logging;
2929
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
30-
using CreateIface = sdbusplus::server::object::object<
30+
using CreateIface = sdbusplus::server::object_t<
3131
sdbusplus::xyz::openbmc_project::User::Ldap::server::Create>;
3232

3333
// class Config;
@@ -53,7 +53,7 @@ class ConfigMgr : public CreateIface
5353
* @param[in] dbusPersistentPath - Persistent path for LDAP D-Bus property.
5454
* @param[in] caCertFile - LDAP's CA certificate file.
5555
*/
56-
ConfigMgr(sdbusplus::bus::bus& bus, const char* path, const char* filePath,
56+
ConfigMgr(sdbusplus::bus_t& bus, const char* path, const char* filePath,
5757
const char* dbusPersistentPath, const char* caCertFile,
5858
const char* certFile) :
5959
CreateIface(bus, path, CreateIface::action::defer_emit),
@@ -121,7 +121,7 @@ class ConfigMgr : public CreateIface
121121
std::string tlsCertFile{};
122122

123123
/** @brief Persistent sdbusplus D-Bus bus connection. */
124-
sdbusplus::bus::bus& bus;
124+
sdbusplus::bus_t& bus;
125125

126126
/* Below two config objects are default, which will always be there */
127127

phosphor-ldap-config/ldap_mapper_entry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using InvalidArgument =
2323
sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
2424
using Argument = xyz::openbmc_project::Common::InvalidArgument;
2525

26-
LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus::bus& bus, const char* path,
26+
LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus_t& bus, const char* path,
2727
const char* filePath,
2828
const std::string& groupName,
2929
const std::string& privilege, Config& parent) :
@@ -36,7 +36,7 @@ LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus::bus& bus, const char* path,
3636
Interfaces::emit_object_added();
3737
}
3838

39-
LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus::bus& bus, const char* path,
39+
LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus_t& bus, const char* path,
4040
const char* filePath, Config& parent) :
4141
Interfaces(bus, path, Interfaces::action::defer_emit),
4242
id(std::stol(std::filesystem::path(path).filename())), manager(parent),

phosphor-ldap-config/ldap_mapper_entry.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Base = sdbusplus::xyz::openbmc_project;
1414
using Entry =
1515
sdbusplus::xyz::openbmc_project::User::server::PrivilegeMapperEntry;
1616
using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete;
17-
using Interfaces = sdbusplus::server::object::object<Entry, Delete>;
17+
using Interfaces = sdbusplus::server::object_t<Entry, Delete>;
1818

1919
// Forward declaration for Config
2020
class Config;
@@ -44,7 +44,7 @@ class LDAPMapperEntry : public Interfaces
4444
* @param[in] privilege - the privilege for the group
4545
* @param[in] parent - LDAP privilege mapper manager
4646
*/
47-
LDAPMapperEntry(sdbusplus::bus::bus& bus, const char* path,
47+
LDAPMapperEntry(sdbusplus::bus_t& bus, const char* path,
4848
const char* filePath, const std::string& groupName,
4949
const std::string& privilege, Config& parent);
5050

@@ -55,7 +55,7 @@ class LDAPMapperEntry : public Interfaces
5555
* @param[in] filePath - serialization directory path
5656
* @param[in] parent - LDAP privilege mapper manager
5757
*/
58-
LDAPMapperEntry(sdbusplus::bus::bus& bus, const char* path,
58+
LDAPMapperEntry(sdbusplus::bus_t& bus, const char* path,
5959
const char* filePath, Config& parent);
6060

6161
/** @brief Delete privilege mapper entry object

phosphor-ldap-config/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int main(int /*argc*/, char** /*argv*/)
2828
auto bus = sdbusplus::bus::new_default();
2929

3030
// Add sdbusplus ObjectManager for the 'root' path of the LDAP config.
31-
sdbusplus::server::manager::manager objManager(bus, LDAP_CONFIG_ROOT);
31+
sdbusplus::server::manager_t objManager(bus, LDAP_CONFIG_ROOT);
3232

3333
phosphor::ldap::ConfigMgr mgr(bus, LDAP_CONFIG_ROOT, LDAP_CONFIG_FILE,
3434
LDAP_CONF_PERSIST_PATH, TLS_CACERT_PATH,

test/ldap_config_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ class TestLDAPConfig : public testing::Test
7070
std::string tlsCacertFile;
7171
std::string tlsCertFile;
7272
std::string ldapconfFile;
73-
sdbusplus::bus::bus bus;
73+
sdbusplus::bus_t bus;
7474
};
7575

7676
class MockConfigMgr : public phosphor::ldap::ConfigMgr
7777
{
7878
public:
79-
MockConfigMgr(sdbusplus::bus::bus& bus, const char* path,
80-
const char* filePath, const char* dbusPersistentFile,
81-
const char* caCertFile, const char* certFile) :
79+
MockConfigMgr(sdbusplus::bus_t& bus, const char* path, const char* filePath,
80+
const char* dbusPersistentFile, const char* caCertFile,
81+
const char* certFile) :
8282
phosphor::ldap::ConfigMgr(bus, path, filePath, dbusPersistentFile,
8383
caCertFile, certFile)
8484
{}

test/mock_user_mgr.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ constexpr auto objpath = "/dummy/user";
1212
class MockManager : public UserMgr
1313
{
1414
public:
15-
MockManager(sdbusplus::bus::bus& bus, const char* path) : UserMgr(bus, path)
15+
MockManager(sdbusplus::bus_t& bus, const char* path) : UserMgr(bus, path)
1616
{}
1717

1818
MOCK_METHOD1(getLdapGroupName, std::string(const std::string& userName));

test/user_mgr_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TestUserMgr : public testing::Test
2222
{
2323
public:
2424
sdbusplus::SdBusMock sdbusMock;
25-
sdbusplus::bus::bus bus;
25+
sdbusplus::bus_t bus;
2626
MockManager mockManager;
2727

2828
TestUserMgr() :

user_mgr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ DbusUserObj UserMgr::getPrivilegeMapperObject(void)
919919
entry("WHAT=%s", e.what()));
920920
throw;
921921
}
922-
catch (const sdbusplus::exception::exception& e)
922+
catch (const sdbusplus::exception_t& e)
923923
{
924924
log<level::ERR>(
925925
"Failed to excute method", entry("METHOD=%s", "GetManagedObjects"),
@@ -1181,7 +1181,7 @@ void UserMgr::initUserObjects(void)
11811181
}
11821182
}
11831183

1184-
UserMgr::UserMgr(sdbusplus::bus::bus& bus, const char* path) :
1184+
UserMgr::UserMgr(sdbusplus::bus_t& bus, const char* path) :
11851185
Ifaces(bus, path, Ifaces::action::defer_emit), bus(bus), path(path)
11861186
{
11871187
UserMgrIface::allPrivileges(privMgr);

user_mgr.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ using UserSSHLists =
3535
using AccountPolicyIface =
3636
sdbusplus::xyz::openbmc_project::User::server::AccountPolicy;
3737

38-
using Ifaces =
39-
sdbusplus::server::object::object<UserMgrIface, AccountPolicyIface>;
38+
using Ifaces = sdbusplus::server::object_t<UserMgrIface, AccountPolicyIface>;
4039

4140
using Privilege = std::string;
4241
using GroupList = std::vector<std::string>;
@@ -78,7 +77,7 @@ class UserMgr : public Ifaces
7877
* @param[in] bus - sdbusplus handler
7978
* @param[in] path - D-Bus path
8079
*/
81-
UserMgr(sdbusplus::bus::bus& bus, const char* path);
80+
UserMgr(sdbusplus::bus_t& bus, const char* path);
8281

8382
/** @brief create user method.
8483
* This method creates a new user as requested
@@ -189,7 +188,7 @@ class UserMgr : public Ifaces
189188

190189
private:
191190
/** @brief sdbusplus handler */
192-
sdbusplus::bus::bus& bus;
191+
sdbusplus::bus_t& bus;
193192

194193
/** @brief object path */
195194
const std::string path;

users.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ using Argument = xyz::openbmc_project::Common::InvalidArgument;
5858
* @param[in] enabled - user enabled state
5959
* @param[in] parent - user manager - parent object
6060
*/
61-
Users::Users(sdbusplus::bus::bus& bus, const char* path,
61+
Users::Users(sdbusplus::bus_t& bus, const char* path,
6262
std::vector<std::string> groups, std::string priv, bool enabled,
6363
UserMgr& parent) :
6464
Interfaces(bus, path, Interfaces::action::defer_emit),

users.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace user
2727
namespace Base = sdbusplus::xyz::openbmc_project;
2828
using UsersIface = Base::User::server::Attributes;
2929
using DeleteIface = Base::Object::server::Delete;
30-
using Interfaces = sdbusplus::server::object::object<UsersIface, DeleteIface>;
30+
using Interfaces = sdbusplus::server::object_t<UsersIface, DeleteIface>;
3131
// Place where all user objects has to be created
3232
constexpr auto usersObjPath = "/xyz/openbmc_project/user";
3333

@@ -55,7 +55,7 @@ class Users : public Interfaces
5555
* @param[in] enabled - user enabled state
5656
* @param[in] parent - user manager - parent object
5757
*/
58-
Users(sdbusplus::bus::bus& bus, const char* path,
58+
Users(sdbusplus::bus_t& bus, const char* path,
5959
std::vector<std::string> groups, std::string priv, bool enabled,
6060
UserMgr& parent);
6161

0 commit comments

Comments
 (0)