Fix the return value of pack_pldm_header and unpack_pldm_header
- The intent behind this commit is to fix the return value of the
pack_pldm_header and the unpack_pldm_header methods.
- According to PLDM spec, their return value should be `uint8_t`, not
`int`, so 0 is PLDM_SUCCESS and non-0 is failure.
- Also, when we call the pack_pldm_header and unpack_pldm_header
methods, we need to verify the return value of the method.
Tested: Built pldm successfully and Unit Test passes.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I0bd6838c4fb3b90f821c10324e4536ed352ffcfa
diff --git a/oem/ibm/libpldm/platform_oem_ibm.c b/oem/ibm/libpldm/platform_oem_ibm.c
index 1cf7e86..7090f95 100644
--- a/oem/ibm/libpldm/platform_oem_ibm.c
+++ b/oem/ibm/libpldm/platform_oem_ibm.c
@@ -9,14 +9,6 @@
size_t payload_length,
struct pldm_msg *msg)
{
- struct pldm_header_info header = {0};
- int rc = PLDM_SUCCESS;
-
- header.msg_type = PLDM_REQUEST;
- header.instance = instance_id;
- header.pldm_type = PLDM_PLATFORM;
- header.command = PLDM_PLATFORM_EVENT_MESSAGE;
-
if (format_version != 1) {
return PLDM_ERROR_INVALID_DATA;
}
@@ -35,7 +27,13 @@
return PLDM_ERROR_INVALID_LENGTH;
}
- if ((rc = pack_pldm_header(&header, &(msg->hdr))) > PLDM_SUCCESS) {
+ struct pldm_header_info header = {0};
+ header.msg_type = PLDM_REQUEST;
+ header.instance = instance_id;
+ header.pldm_type = PLDM_PLATFORM;
+ header.command = PLDM_PLATFORM_EVENT_MESSAGE;
+ uint8_t rc = pack_pldm_header(&header, &(msg->hdr));
+ if (rc != PLDM_SUCCESS) {
return rc;
}