summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2019-04-03 09:37:43 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2019-04-08 10:31:56 -0700
commitbea5392552b3b6445adf093b97c97512d69db160 (patch)
tree388e607aa75431a9eb945c3dbcb1ccba36a5b61f
parente08fbffcd9bd1976f7d26d48bf7a4c3e5843d4a8 (diff)
downloadphosphor-host-ipmid-bea5392552b3b6445adf093b97c97512d69db160.zip
phosphor-host-ipmid-bea5392552b3b6445adf093b97c97512d69db160.tar.gz
Add helper functions to simplify error responses
Most IPMI commands have some error response. This makes it more intuitive what is happening, changing return ipmi::response(cc::CommandNotAvailable); to return ipmi::responseCommandNotAvailable(); which is parallel to the success respones of: return ipmi::responseSuccess(); Change-Id: Ibbd401c4007a02e91ab4983814b920d6d7f02404 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
-rw-r--r--include/ipmid/api-types.hpp103
1 files changed, 100 insertions, 3 deletions
diff --git a/include/ipmid/api-types.hpp b/include/ipmid/api-types.hpp
index c718ff4..b4b70e3 100644
--- a/include/ipmid/api-types.hpp
+++ b/include/ipmid/api-types.hpp
@@ -445,12 +445,109 @@ static inline auto response(ipmi::Cc cc)
template <typename... Args>
static inline auto responseSuccess(Args&&... args)
{
- return std::make_tuple(ipmi::ccSuccess,
- std::make_optional(std::make_tuple(args...)));
+ return response(ipmi::ccSuccess, args...);
}
static inline auto responseSuccess()
{
- return std::make_tuple(ipmi::ccSuccess, std::nullopt);
+ return response(ipmi::ccSuccess);
+}
+
+/* helper functions for the various standard error response types */
+static inline auto responseBusy()
+{
+ return response(ccBusy);
+}
+static inline auto responseInvalidCommand()
+{
+ return response(ccInvalidCommand);
+}
+static inline auto responseInvalidCommandOnLun()
+{
+ return response(ccInvalidCommandOnLun);
+}
+static inline auto responseTimeout()
+{
+ return response(ccTimeout);
+}
+static inline auto responseOutOfSpace()
+{
+ return response(ccOutOfSpace);
+}
+static inline auto responseInvalidReservationId()
+{
+ return response(ccInvalidReservationId);
+}
+static inline auto responseReqDataTruncated()
+{
+ return response(ccReqDataTruncated);
+}
+static inline auto responseReqDataLenInvalid()
+{
+ return response(ccReqDataLenInvalid);
+}
+static inline auto responseReqDataLenExceeded()
+{
+ return response(ccReqDataLenExceeded);
+}
+static inline auto responseParmOutOfRange()
+{
+ return response(ccParmOutOfRange);
+}
+static inline auto responseRetBytesUnavailable()
+{
+ return response(ccRetBytesUnavailable);
+}
+static inline auto responseSensorInvalid()
+{
+ return response(ccSensorInvalid);
+}
+static inline auto responseInvalidFieldRequest()
+{
+ return response(ccInvalidFieldRequest);
+}
+static inline auto responseIllegalCommand()
+{
+ return response(ccIllegalCommand);
+}
+static inline auto responseResponseError()
+{
+ return response(ccResponseError);
+}
+static inline auto responseDuplicateRequest()
+{
+ return response(ccDuplicateRequest);
+}
+static inline auto responseCmdFailSdrMode()
+{
+ return response(ccCmdFailSdrMode);
+}
+static inline auto responseCmdFailFwUpdMode()
+{
+ return response(ccCmdFailFwUpdMode);
+}
+static inline auto responseCmdFailInitAgent()
+{
+ return response(ccCmdFailInitAgent);
+}
+static inline auto responseDestinationUnavailable()
+{
+ return response(ccDestinationUnavailable);
+}
+static inline auto responseInsufficientPrivilege()
+{
+ return response(ccInsufficientPrivilege);
+}
+static inline auto responseCommandNotAvailable()
+{
+ return response(ccCommandNotAvailable);
+}
+static inline auto responseCommandDisabled()
+{
+ return response(ccCommandDisabled);
+}
+static inline auto responseUnspecifiedError()
+{
+ return response(ccUnspecifiedError);
}
} // namespace ipmi
OpenPOWER on IntegriCloud