app: Optimize ipmi complete code
Encapsulate the custom status return code into an ipmi method and
then use it in cpp.
Change-Id: If1ce2bbb1a234c574bc89832dbb87004937d1d38
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/app/channel.cpp b/app/channel.cpp
index efed5c1..ea737d5 100644
--- a/app/channel.cpp
+++ b/app/channel.cpp
@@ -17,6 +17,16 @@
using namespace phosphor::logging;
using namespace sdbusplus::error::xyz::openbmc_project::common;
+namespace ipmi
+{
+constexpr Cc ccPayloadTypeNotSupported = 0x80;
+
+static inline auto responsePayloadTypeNotSupported()
+{
+ return response(ccPayloadTypeNotSupported);
+}
+} // namespace ipmi
+
namespace cipher
{
@@ -131,8 +141,7 @@
if (!ipmi::isValidPayloadType(static_cast<ipmi::PayloadType>(payloadType)))
{
lg2::debug("Get channel cipher suites - Invalid payload type");
- constexpr uint8_t ccPayloadTypeNotSupported = 0x80;
- return ipmi::response(ccPayloadTypeNotSupported);
+ return ipmi::responsePayloadTypeNotSupported();
}
if (!recordInit)
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index e0c1e03..eae7344 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -21,6 +21,16 @@
static bool lastCallSuccessful = false;
+namespace ipmi
+{
+constexpr Cc ccWatchdogNotInit = 0x80;
+
+static inline auto responseWatchdogNotInit()
+{
+ return response(ccWatchdogNotInit);
+}
+} // namespace ipmi
+
void reportError()
{
// We don't want to fill the SEL with errors if the daemon dies and doesn't
@@ -52,8 +62,7 @@
{
lastCallSuccessful = true;
- constexpr uint8_t ccWatchdogNotInit = 0x80;
- return ipmi::response(ccWatchdogNotInit);
+ return ipmi::responseWatchdogNotInit();
}
// The ipmi standard dictates we enable the watchdog during reset