platform: pldm_msgbuf for decode_event_message_buffer_size_resp()
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ib0730c3a2b670a478d3e7c9a71bc677902029098
diff --git a/src/platform.c b/src/platform.c
index 0cd79e9..eb14a10 100644
--- a/src/platform.c
+++ b/src/platform.c
@@ -1035,25 +1035,33 @@
uint8_t *completion_code,
uint16_t *terminus_max_buffer_size)
{
+ struct pldm_msgbuf _buf;
+ struct pldm_msgbuf *buf = &_buf;
+ int rc;
+
if (msg == NULL || completion_code == NULL ||
terminus_max_buffer_size == NULL) {
return PLDM_ERROR_INVALID_DATA;
}
- *completion_code = msg->payload[0];
+ rc = pldm_msgbuf_init(buf, PLDM_EVENT_MESSAGE_BUFFER_SIZE_RESP_BYTES,
+ msg->payload, payload_length);
+ if (rc) {
+ return rc;
+ }
+
+ rc = pldm_msgbuf_extract(buf, completion_code);
+ if (rc) {
+ return rc;
+ }
+
if (PLDM_SUCCESS != *completion_code) {
return PLDM_SUCCESS;
}
- if (payload_length != PLDM_EVENT_MESSAGE_BUFFER_SIZE_RESP_BYTES) {
- return PLDM_ERROR_INVALID_LENGTH;
- }
- struct pldm_event_message_buffer_size_resp *response =
- (struct pldm_event_message_buffer_size_resp *)msg->payload;
+ pldm_msgbuf_extract(buf, terminus_max_buffer_size);
- *terminus_max_buffer_size = response->terminus_max_buffer_size;
-
- return PLDM_SUCCESS;
+ return pldm_msgbuf_destroy_consumed(buf);
}
int encode_event_message_supported_req(uint8_t instance_id,