Fix usage of std::variant
The .get() member interface is mapbox specific and will not work when we
transition to std::variant.
Change-Id: Ia2b580339af0ef08f4e43503b774988a30062645
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/snmp_notification.cpp b/snmp_notification.cpp
index 5f2aea9..5b548f6 100644
--- a/snmp_notification.cpp
+++ b/snmp_notification.cpp
@@ -13,6 +13,7 @@
namespace snmp
{
+namespace variant_ns = sdbusplus::message::variant_ns;
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
@@ -27,28 +28,28 @@
{
case ASN_INTEGER:
{
- auto ltmp = val.get<int32_t>();
+ auto ltmp = variant_ns::get<int32_t>(val);
varList = snmp_pdu_add_variable(&pdu, objID.data(), objIDLen, type,
<mp, sizeof(ltmp));
}
break;
case ASN_UNSIGNED:
{
- auto ltmp = val.get<uint32_t>();
+ auto ltmp = variant_ns::get<uint32_t>(val);
varList = snmp_pdu_add_variable(&pdu, objID.data(), objIDLen, type,
<mp, sizeof(ltmp));
}
break;
case ASN_OPAQUE_U64:
{
- auto ltmp = val.get<uint64_t>();
+ auto ltmp = variant_ns::get<uint64_t>(val);
varList = snmp_pdu_add_variable(&pdu, objID.data(), objIDLen, type,
<mp, sizeof(ltmp));
}
break;
case ASN_OCTET_STR:
{
- auto value = val.get<std::string>();
+ const auto& value = variant_ns::get<std::string>(val);
varList = snmp_pdu_add_variable(&pdu, objID.data(), objIDLen, type,
value.c_str(), value.length());
}
diff --git a/snmp_util.cpp b/snmp_util.cpp
index 25342ea..b5cea81 100644
--- a/snmp_util.cpp
+++ b/snmp_util.cpp
@@ -13,6 +13,7 @@
namespace phosphor
{
+namespace variant_ns = sdbusplus::message::variant_ns;
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
@@ -102,8 +103,9 @@
{
auto& intfMap = objIter.second;
auto& snmpClientProps = intfMap.at(clientIntf);
- auto& address = snmpClientProps.at("Address").get<std::string>();
- auto& port = snmpClientProps.at("Port").get<uint16_t>();
+ auto& address =
+ variant_ns::get<std::string>(snmpClientProps.at("Address"));
+ auto& port = variant_ns::get<uint16_t>(snmpClientProps.at("Port"));
auto ipaddress = phosphor::network::resolveAddress(address);
auto mgr = std::move(ipaddress);
if (port > 0)