diff options
author | Lei YU <mine260309@gmail.com> | 2017-05-15 11:24:04 +0800 |
---|---|---|
committer | Lei YU <mine260309@gmail.com> | 2017-05-16 10:07:20 +0800 |
commit | 12c2db7947bf20f683950347e06a36bea1991d37 (patch) | |
tree | 447cdc2238a72b2bda8feb95a7e2427400da590c /systemintfcmds.cpp | |
parent | 8315970370d63b101bd0bd579bc1f697a3c8d07c (diff) | |
download | phosphor-host-ipmid-12c2db7947bf20f683950347e06a36bea1991d37.tar.gz phosphor-host-ipmid-12c2db7947bf20f683950347e06a36bea1991d37.zip |
Set init_priority attribute for global/static variables
The initialization order of global/static variables and functions
with constructor attribute is unspecified.
Set init_priority attribute to specify the initialization order.
Resolves openbmc/openbmc#1581
Change-Id: Ia85804b3b9e537e0f32b712a3ce92e7d0be554b2
Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'systemintfcmds.cpp')
-rw-r--r-- | systemintfcmds.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/systemintfcmds.cpp b/systemintfcmds.cpp index 23e81ba..b101016 100644 --- a/systemintfcmds.cpp +++ b/systemintfcmds.cpp @@ -144,11 +144,11 @@ ipmi_ret_t ipmi_app_set_bmc_global_enables(ipmi_netfn_t netfn, ipmi_cmd_t cmd, return rc; } -// Globals to keep the object alive during process life -std::unique_ptr<sdbusplus::bus::bus> sdbus = nullptr; -// TODO openbmc/openbmc#1581 - unique_ptr causes seg fault -phosphor::host::Host* host = nullptr; - +namespace { +// Static storage to keep the object alive during process life +std::unique_ptr<sdbusplus::bus::bus> sdbus __attribute__((init_priority(101))); +std::unique_ptr<phosphor::host::Host> host __attribute__((init_priority(101))); +} #include <unistd.h> void register_netfn_app_functions() @@ -185,9 +185,9 @@ void register_netfn_app_functions() // Get the sd_events pointer auto events = ipmid_get_sd_event_connection(); - host = new phosphor::host::Host(*sdbus, - objPathInst.c_str(), - events); + host = std::make_unique<phosphor::host::Host>(*sdbus, + objPathInst.c_str(), + events); sdbus->request_name(CONTROL_HOST_BUSNAME); |