summaryrefslogtreecommitdiffstats
path: root/include/ipmid
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2019-04-24 01:53:52 -0700
committerWilliam A. Kennington III <wak@google.com>2019-04-29 12:06:35 -0700
commitf2fd17a41bf7e3afd4d69adf5f8ea5642bdfffcf (patch)
tree3838a8099d55f05dc10cea8bfbb31e70b2cf14bf /include/ipmid
parent51694c22130d4f6160f63167a547d0a40763ef31 (diff)
downloadphosphor-host-ipmid-f2fd17a41bf7e3afd4d69adf5f8ea5642bdfffcf.tar.gz
phosphor-host-ipmid-f2fd17a41bf7e3afd4d69adf5f8ea5642bdfffcf.zip
message/payload: Ignore unchecked unpack warning during unwind
If we are caught in an exception unwind we don't care that the payload is not be fully checked. Otherwise, this encourages the pattern of wrapping all handler code in try catch blocks that set trailingOk as it is not required to read the entire payload when throwing an exception. Change-Id: I35149eedd33bd9fd41968e89d5a8614df7436872 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'include/ipmid')
-rw-r--r--include/ipmid/handler.hpp68
-rw-r--r--include/ipmid/message.hpp4
2 files changed, 38 insertions, 34 deletions
diff --git a/include/ipmid/handler.hpp b/include/ipmid/handler.hpp
index ebeb442..c84bffd 100644
--- a/include/ipmid/handler.hpp
+++ b/include/ipmid/handler.hpp
@@ -179,45 +179,47 @@ class IpmiHandler final : public HandlerBase
* parameter selector. All the remaining data can be extracted using
* the Payload class and the unpack API available to the Payload class.
*/
- std::optional<InputArgsType> inputArgs;
- if constexpr (std::tuple_size<InputArgsType>::value > 0)
+ ResultType result;
+ try
{
- if constexpr (std::is_same<std::tuple_element_t<0, InputArgsType>,
- boost::asio::yield_context>::value)
- {
- inputArgs.emplace(std::tuple_cat(
- std::forward_as_tuple(*(request->ctx->yield)),
- std::move(unpackArgs)));
- }
- else if constexpr (std::is_same<
- std::tuple_element_t<0, InputArgsType>,
- ipmi::Context::ptr>::value)
- {
- inputArgs.emplace(
- std::tuple_cat(std::forward_as_tuple(request->ctx),
- std::move(unpackArgs)));
- }
- else if constexpr (std::is_same<
- std::tuple_element_t<0, InputArgsType>,
- ipmi::message::Request::ptr>::value)
+ std::optional<InputArgsType> inputArgs;
+ if constexpr (std::tuple_size<InputArgsType>::value > 0)
{
- inputArgs.emplace(std::tuple_cat(std::forward_as_tuple(request),
- std::move(unpackArgs)));
+ if constexpr (std::is_same<
+ std::tuple_element_t<0, InputArgsType>,
+ boost::asio::yield_context>::value)
+ {
+ inputArgs.emplace(std::tuple_cat(
+ std::forward_as_tuple(*(request->ctx->yield)),
+ std::move(unpackArgs)));
+ }
+ else if constexpr (std::is_same<
+ std::tuple_element_t<0, InputArgsType>,
+ ipmi::Context::ptr>::value)
+ {
+ inputArgs.emplace(
+ std::tuple_cat(std::forward_as_tuple(request->ctx),
+ std::move(unpackArgs)));
+ }
+ else if constexpr (std::is_same<
+ std::tuple_element_t<0, InputArgsType>,
+ ipmi::message::Request::ptr>::value)
+ {
+ inputArgs.emplace(std::tuple_cat(
+ std::forward_as_tuple(request), std::move(unpackArgs)));
+ }
+ else
+ {
+ // no special parameters were requested (but others were)
+ inputArgs.emplace(std::move(unpackArgs));
+ }
}
else
{
- // no special parameters were requested (but others were)
- inputArgs.emplace(std::move(unpackArgs));
+ // no parameters were requested
+ inputArgs = std::move(unpackArgs);
}
- }
- else
- {
- // no parameters were requested
- inputArgs = std::move(unpackArgs);
- }
- ResultType result;
- try
- {
+
// execute the registered callback function and get the
// ipmi::RspType<>
result = std::apply(handler_, *inputArgs);
diff --git a/include/ipmid/message.hpp b/include/ipmid/message.hpp
index b10fc42..9bc1147 100644
--- a/include/ipmid/message.hpp
+++ b/include/ipmid/message.hpp
@@ -18,6 +18,7 @@
#include <algorithm>
#include <boost/asio/spawn.hpp>
#include <cstdint>
+#include <exception>
#include <ipmid/api-types.hpp>
#include <ipmid/message/types.hpp>
#include <memory>
@@ -110,7 +111,8 @@ struct Payload
~Payload()
{
using namespace phosphor::logging;
- if (raw.size() != 0 && !trailingOk && !unpackCheck && !unpackError)
+ if (raw.size() != 0 && std::uncaught_exceptions() == 0 && !trailingOk &&
+ !unpackCheck && !unpackError)
{
log<level::ERR>("Failed to check request for full unpack");
}
OpenPOWER on IntegriCloud