diff options
author | William A. Kennington III <wak@google.com> | 2018-11-12 17:19:33 -0800 |
---|---|---|
committer | William A. Kennington III <wak@google.com> | 2018-11-12 17:27:25 -0800 |
commit | 7a0689a91af664c8485df760bedabba0aef84725 (patch) | |
tree | 58ede714045ea4e55f2b5f160c5f7b750bb0b1ea | |
parent | 436f3b88152393c33b579c20d5ba0de28ff0f855 (diff) | |
download | phosphor-state-manager-7a0689a91af664c8485df760bedabba0aef84725.tar.gz phosphor-state-manager-7a0689a91af664c8485df760bedabba0aef84725.zip |
std::variant: Fix use of incompatible api
Refactors any uses of the mapbox variant specific api and converts them
to an api compatible with std::variant and mapbox variant.
Tested:
Built and run through the unit test suite.
Change-Id: Ie9b83fd638c495859fe98b5de86d9d3c7c1a27af
Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r-- | chassis_state_manager.cpp | 14 | ||||
-rw-r--r-- | discover_system_state.cpp | 2 | ||||
-rw-r--r-- | host_state_manager.cpp | 14 |
3 files changed, 11 insertions, 19 deletions
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp index d721460..16cecec 100644 --- a/chassis_state_manager.cpp +++ b/chassis_state_manager.cpp @@ -89,7 +89,7 @@ void Chassis::determineInitialState() goto fail; } - if (pgood == 1) + if (sdbusplus::message::variant_ns::get<int>(pgood) == 1) { log<level::INFO>("Initial Chassis State will be On", entry("CHASSIS_CURRENT_POWER_STATE=%s", @@ -204,14 +204,10 @@ bool Chassis::stateActive(const std::string& target) } result.read(currentState); - - if (currentState != ACTIVE_STATE && currentState != ACTIVATING_STATE) - { - // False - not active - return false; - } - // True - active - return true; + const auto& currentStateStr = + sdbusplus::message::variant_ns::get<std::string>(currentState); + return currentStateStr == ACTIVE_STATE || + currentStateStr == ACTIVATING_STATE; } int Chassis::sysStateChange(sdbusplus::message::message& msg) diff --git a/discover_system_state.cpp b/discover_system_state.cpp index 5ce94b4..92d3416 100644 --- a/discover_system_state.cpp +++ b/discover_system_state.cpp @@ -157,7 +157,7 @@ int main(int argc, char** argv) sdbusplus::message::variant<std::string> result; reply.read(result); - auto powerPolicy = result.get<std::string>(); + auto powerPolicy = sdbusplus::message::variant_ns::get<std::string>(result); log<level::INFO>("Host power is off, checking power policy", entry("POWER_POLICY=%s", powerPolicy.c_str())); diff --git a/host_state_manager.cpp b/host_state_manager.cpp index 38c9469..aaac46c 100644 --- a/host_state_manager.cpp +++ b/host_state_manager.cpp @@ -162,14 +162,10 @@ bool Host::stateActive(const std::string& target) } result.read(currentState); - - if (currentState != ACTIVE_STATE && currentState != ACTIVATING_STATE) - { - // False - not active - return false; - } - // True - active - return true; + const auto& currentStateStr = + sdbusplus::message::variant_ns::get<std::string>(currentState); + return currentStateStr == ACTIVE_STATE || + currentStateStr == ACTIVATING_STATE; } bool Host::isAutoReboot() @@ -189,7 +185,7 @@ bool Host::isAutoReboot() sdbusplus::message::variant<bool> result; reply.read(result); - auto autoReboot = result.get<bool>(); + auto autoReboot = sdbusplus::message::variant_ns::get<bool>(result); auto rebootCounterParam = reboot::RebootAttempts::attemptsLeft(); if (autoReboot) |