summaryrefslogtreecommitdiffstats
path: root/ipmi
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-09-06 17:56:41 -0700
committerPatrick Venture <venture@google.com>2018-09-06 18:02:37 -0700
commitacecf6b82c5dfbcab9215936eb1ee5fd3893a32d (patch)
treec562b43d2474dbf896d2187683a6b0ab44f27ae7 /ipmi
parente2ec0f618a9b3b6809a98516abe63d5d833e7fe7 (diff)
downloadphosphor-pid-control-acecf6b82c5dfbcab9215936eb1ee5fd3893a32d.tar.gz
phosphor-pid-control-acecf6b82c5dfbcab9215936eb1ee5fd3893a32d.zip
ipmi: catch SdBusErrors on bus call failures
Now sdbusplus call and call_noreply can throw an SdBusError exception. This code changes from checking .is_method_error() to catching the exception. Issue: 4 Change-Id: I07bbe5dbbd91d72ca75eeb14861d56aae5f3afed Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'ipmi')
-rw-r--r--ipmi/manualcmds.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/ipmi/manualcmds.cpp b/ipmi/manualcmds.cpp
index eabcd0a..798deab 100644
--- a/ipmi/manualcmds.cpp
+++ b/ipmi/manualcmds.cpp
@@ -84,22 +84,20 @@ static ipmi_ret_t GetFanCtrlProperty(uint8_t zoneId, bool* value,
propertiesintf, "GetAll");
pimMsg.append(intf);
- auto valueResponseMsg = propertyReadBus.call(pimMsg);
- if (valueResponseMsg.is_method_error())
+ try
{
- return IPMI_CC_INVALID;
- }
+ auto valueResponseMsg = propertyReadBus.call(pimMsg);
- PropertyMap propMap;
- valueResponseMsg.read(propMap);
+ PropertyMap propMap;
+ valueResponseMsg.read(propMap);
- if (propMap.size() != 2)
+ *value = sdbusplus::message::variant_ns::get<bool>(propMap[property]);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
{
return IPMI_CC_INVALID;
}
- *value = sdbusplus::message::variant_ns::get<bool>(propMap[property]);
-
return IPMI_CC_OK;
}
@@ -193,8 +191,12 @@ static ipmi_ret_t SetManualModeState(const uint8_t* reqBuf, uint8_t* replyBuf,
pimMsg.append(intf);
pimMsg.append(manualProperty);
pimMsg.append(v);
- auto responseMsg = PropertyWriteBus.call(pimMsg);
- if (responseMsg.is_method_error())
+
+ try
+ {
+ PropertyWriteBus.call_noreply(pimMsg);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
{
rc = IPMI_CC_INVALID;
}
OpenPOWER on IntegriCloud