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/host.c b/oem/ibm/libpldm/host.c
index 454f6c3..caaaf9e 100644
--- a/oem/ibm/libpldm/host.c
+++ b/oem/ibm/libpldm/host.c
@@ -6,22 +6,24 @@
 int encode_get_alert_status_req(uint8_t instance_id, uint8_t version_id,
 				struct pldm_msg *msg, size_t payload_length)
 {
-	struct pldm_header_info header = {0};
-	int rc = PLDM_SUCCESS;
-
-	header.msg_type = PLDM_REQUEST;
-	header.instance = instance_id;
-	header.pldm_type = PLDM_OEM;
-	header.command = PLDM_HOST_GET_ALERT_STATUS;
-
-	if ((rc = pack_pldm_header(&header, &(msg->hdr))) > PLDM_SUCCESS) {
-		return rc;
+	if (msg == NULL) {
+		return PLDM_ERROR_INVALID_LENGTH;
 	}
 
 	if (payload_length != PLDM_GET_ALERT_STATUS_REQ_BYTES) {
 		return PLDM_ERROR_INVALID_LENGTH;
 	}
 
+	struct pldm_header_info header = {0};
+	header.msg_type = PLDM_REQUEST;
+	header.instance = instance_id;
+	header.pldm_type = PLDM_OEM;
+	header.command = PLDM_HOST_GET_ALERT_STATUS;
+	uint8_t rc = pack_pldm_header(&header, &(msg->hdr));
+	if (rc != PLDM_SUCCESS) {
+		return rc;
+	}
+
 	msg->payload[0] = version_id;
 
 	return PLDM_SUCCESS;
@@ -75,22 +77,24 @@
 				 uint32_t rack_entry, uint32_t pri_cec_node,
 				 struct pldm_msg *msg, size_t payload_length)
 {
-	struct pldm_header_info header = {0};
-	int rc = PLDM_SUCCESS;
-
-	header.msg_type = PLDM_RESPONSE;
-	header.instance = instance_id;
-	header.pldm_type = PLDM_OEM;
-	header.command = PLDM_HOST_GET_ALERT_STATUS;
-
-	if ((rc = pack_pldm_header(&header, &(msg->hdr))) > PLDM_SUCCESS) {
-		return rc;
+	if (msg == NULL) {
+		return PLDM_ERROR_INVALID_LENGTH;
 	}
 
 	if (payload_length != PLDM_GET_ALERT_STATUS_RESP_BYTES) {
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
+	struct pldm_header_info header = {0};
+	header.msg_type = PLDM_RESPONSE;
+	header.instance = instance_id;
+	header.pldm_type = PLDM_OEM;
+	header.command = PLDM_HOST_GET_ALERT_STATUS;
+	uint8_t rc = pack_pldm_header(&header, &(msg->hdr));
+	if (rc != PLDM_SUCCESS) {
+		return rc;
+	}
+
 	struct pldm_get_alert_status_resp *response =
 	    (struct pldm_get_alert_status_resp *)msg->payload;