msgbuf: Define a separate msgbuf structure for encode/decode function
Define separate msgbuf structures to avoid casting away const-qualifiers
in the msgbuf constructor function:
* pldm_msgbuf_rw: for encode functions with non const-qualified buffer
* pldm_msgbuf_ro: for decode functions with const-qualified buffer
Further, use _Generic() to keep the API ergonomic while still yielding a
compile error when wrong msgbuf type is passed.
Change-Id: I71dbcb7996e9fb402b49870fce539a939c1497e5
Signed-off-by: John Chung <john.chung@arm.com>
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/src/dsp/base.c b/src/dsp/base.c
index 05fcb9a..816a871 100644
--- a/src/dsp/base.c
+++ b/src/dsp/base.c
@@ -506,7 +506,7 @@
int decode_set_tid_req(const struct pldm_msg *msg, size_t payload_length,
uint8_t *tid)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!msg || !tid) {
@@ -533,7 +533,7 @@
uint32_t *section_offset,
uint32_t *section_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || pldm_type == NULL || transfer_opflag == NULL ||
@@ -587,7 +587,7 @@
uint8_t instance_id, const struct pldm_base_multipart_receive_req *req,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (req == NULL || msg == NULL || payload_length == NULL) {
@@ -627,7 +627,7 @@
struct pldm_base_multipart_receive_resp *resp,
uint32_t *data_integrity_checksum)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || resp == NULL || data_integrity_checksum == NULL) {
@@ -663,7 +663,7 @@
if (resp->data.length > 0) {
resp->data.ptr = NULL;
pldm_msgbuf_span_required(buf, resp->data.length,
- (void **)&resp->data.ptr);
+ (const void **)&resp->data.ptr);
}
if (resp->transfer_flag !=
@@ -680,7 +680,7 @@
const struct pldm_base_multipart_receive_resp *resp, uint32_t checksum,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!msg || !resp || !payload_length || !resp->data.ptr) {
@@ -795,7 +795,7 @@
const struct pldm_base_negotiate_transfer_params_req *req,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (req == NULL || msg == NULL || payload_length == NULL) {
@@ -837,7 +837,7 @@
const struct pldm_msg *msg, size_t payload_length,
struct pldm_base_negotiate_transfer_params_resp *resp)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || resp == NULL) {
diff --git a/src/dsp/file.c b/src/dsp/file.c
index 07a283c..f22e977 100644
--- a/src/dsp/file.c
+++ b/src/dsp/file.c
@@ -18,7 +18,7 @@
const struct pldm_file_df_open_req *req,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (req == NULL || msg == NULL) {
@@ -53,7 +53,7 @@
size_t payload_length,
struct pldm_file_df_open_req *req)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!msg || !req) {
@@ -77,7 +77,7 @@
const struct pldm_file_df_open_resp *resp,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!msg || !resp) {
@@ -114,7 +114,7 @@
size_t payload_length,
struct pldm_file_df_open_resp *resp)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!msg || !resp) {
@@ -149,7 +149,7 @@
const struct pldm_file_df_close_req *req,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!req || !msg) {
@@ -184,7 +184,7 @@
size_t payload_length,
struct pldm_file_df_close_req *req)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!msg || !req) {
@@ -208,7 +208,7 @@
const struct pldm_file_df_close_resp *resp,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!msg || !resp) {
@@ -256,7 +256,7 @@
uint8_t instance_id, const struct pldm_file_df_heartbeat_req *req,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!req || !msg) {
@@ -291,7 +291,7 @@
size_t payload_length,
struct pldm_file_df_heartbeat_resp *resp)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!msg || !resp) {
diff --git a/src/dsp/firmware_update.c b/src/dsp/firmware_update.c
index 7381546..e7befe8 100644
--- a/src/dsp/firmware_update.c
+++ b/src/dsp/firmware_update.c
@@ -393,11 +393,11 @@
uint32_t package_header_checksum = 0;
size_t package_header_variable_size;
size_t package_header_payload_size;
+ const void *package_payload_offset;
size_t package_header_areas_size;
uint16_t package_header_size;
- void *package_payload_offset;
size_t package_payload_size;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int checksums = 1;
int rc;
@@ -511,8 +511,9 @@
return pldm_msgbuf_discard(buf, rc);
}
- pldm_msgbuf_span_required(buf, hdr->package_version_string.length,
- (void **)&hdr->package_version_string.ptr);
+ pldm_msgbuf_span_required(
+ buf, hdr->package_version_string.length,
+ (const void **)&hdr->package_version_string.ptr);
if (package_header_size < (PLDM_FWUP_PACKAGE_HEADER_FIXED_SIZE + 3 +
checksums * sizeof(uint32_t))) {
@@ -530,7 +531,7 @@
package_header_areas_size = package_header_variable_size -
hdr->package_version_string.length;
rc = pldm_msgbuf_span_required(buf, package_header_areas_size,
- (void **)&pkg->areas.ptr);
+ (const void **)&pkg->areas.ptr);
if (rc) {
return pldm_msgbuf_discard(buf, rc);
}
@@ -638,12 +639,12 @@
}
/* Currently only used for decode_firmware_device_id_record_errno() */
-static int pldm_msgbuf_init_dynamic_uint16(struct pldm_msgbuf *buf, size_t req,
- void *data, size_t len,
+static int pldm_msgbuf_init_dynamic_uint16(struct pldm_msgbuf_ro *buf,
+ size_t req, void *data, size_t len,
void **tail_data, size_t *tail_len)
{
+ const void *dyn_start;
size_t dyn_length;
- void *dyn_start;
int rc;
rc = pldm_msgbuf_init_errno(buf, req, data, len);
@@ -676,7 +677,8 @@
return pldm_msgbuf_discard(buf, rc);
}
- rc = pldm_msgbuf_span_remaining(buf, tail_data, tail_len);
+ rc = pldm_msgbuf_span_remaining(buf, (const void **)tail_data,
+ tail_len);
if (rc) {
return pldm_msgbuf_discard(buf, rc);
}
@@ -696,7 +698,7 @@
struct pldm_package_firmware_device_id_record *rec)
{
size_t firmware_device_package_data_offset;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
uint16_t record_len = 0;
int rc;
@@ -756,7 +758,7 @@
assert((hdr->component_bitmap_bit_length & 7) == 0);
rc = pldm_msgbuf_span_required(
buf, hdr->component_bitmap_bit_length / 8,
- (void **)&rec->applicable_components.bitmap.ptr);
+ (const void **)&rec->applicable_components.bitmap.ptr);
if (rc) {
return pldm_msgbuf_discard(buf, rc);
}
@@ -765,7 +767,7 @@
pldm_msgbuf_span_required(
buf, rec->component_image_set_version_string.length,
- (void **)&rec->component_image_set_version_string.ptr);
+ (const void **)&rec->component_image_set_version_string.ptr);
/* The total length reserved for `package_data` and `reference_manifest_data` */
firmware_device_package_data_offset =
@@ -773,12 +775,12 @@
rec->reference_manifest_data.length;
pldm_msgbuf_span_until(buf, firmware_device_package_data_offset,
- (void **)&rec->record_descriptors.ptr,
+ (const void **)&rec->record_descriptors.ptr,
&rec->record_descriptors.length);
pldm_msgbuf_span_required(
buf, rec->firmware_device_package_data.length,
- (void **)&rec->firmware_device_package_data.ptr);
+ (const void **)&rec->firmware_device_package_data.ptr);
if (!rec->firmware_device_package_data.length) {
rec->firmware_device_package_data.ptr = NULL;
}
@@ -787,7 +789,7 @@
PLDM_PACKAGE_HEADER_FORMAT_REVISION_FR04H) {
pldm_msgbuf_span_required(
buf, rec->reference_manifest_data.length,
- (void **)&rec->reference_manifest_data.ptr);
+ (const void **)&rec->reference_manifest_data.ptr);
} else {
assert(rec->reference_manifest_data.length == 0);
@@ -851,7 +853,7 @@
int decode_pldm_descriptor_from_iter(struct pldm_descriptor_iter *iter,
struct pldm_descriptor *desc)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!iter || !iter->field || !desc) {
@@ -872,9 +874,9 @@
desc->descriptor_data = NULL;
pldm_msgbuf_span_required(buf, desc->descriptor_length,
- (void **)&desc->descriptor_data);
+ (const void **)&desc->descriptor_data);
iter->field->ptr = NULL;
- pldm_msgbuf_span_remaining(buf, (void **)&iter->field->ptr,
+ pldm_msgbuf_span_remaining(buf, (const void **)&iter->field->ptr,
&iter->field->length);
return pldm_msgbuf_complete(buf);
@@ -1149,7 +1151,7 @@
const struct pldm_descriptor *descriptors, struct pldm_msg *msg,
size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (descriptors == NULL || msg == NULL || payload_length == NULL) {
@@ -1324,7 +1326,7 @@
const struct pldm_get_firmware_parameters_resp_full *resp_data,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (resp_data == NULL || msg == NULL || payload_length == NULL) {
@@ -1380,7 +1382,7 @@
const struct pldm_component_parameter_entry_full *comp,
uint8_t *payload, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (comp == NULL || payload == NULL || payload_length == NULL) {
@@ -1530,7 +1532,7 @@
const struct pldm_msg *msg, size_t payload_length,
struct pldm_query_downstream_devices_resp *resp_data)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || resp_data == NULL || !payload_length) {
@@ -1580,7 +1582,7 @@
const struct pldm_query_downstream_identifiers_req *params_req,
struct pldm_msg *msg, size_t payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!msg || !params_req) {
@@ -1623,8 +1625,8 @@
struct pldm_query_downstream_identifiers_resp *resp_data,
struct pldm_downstream_device_iter *iter)
{
- PLDM_MSGBUF_DEFINE_P(buf);
- void *remaining = NULL;
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
+ const void *remaining = NULL;
int rc = 0;
if (msg == NULL || resp_data == NULL || iter == NULL ||
@@ -1679,7 +1681,7 @@
struct pldm_downstream_device_iter *iter,
struct pldm_downstream_device *dev)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!iter || !iter->field.ptr || !dev) {
@@ -1694,7 +1696,7 @@
pldm_msgbuf_extract(buf, dev->downstream_device_index);
pldm_msgbuf_extract(buf, dev->downstream_descriptor_count);
- pldm_msgbuf_span_remaining(buf, (void **)&iter->field.ptr,
+ pldm_msgbuf_span_remaining(buf, (const void **)&iter->field.ptr,
&iter->field.length);
return pldm_msgbuf_complete(buf);
@@ -1706,7 +1708,7 @@
const struct pldm_get_downstream_firmware_parameters_req *params_req,
struct pldm_msg *msg, size_t payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!msg || !params_req) {
@@ -1749,8 +1751,8 @@
struct pldm_get_downstream_firmware_parameters_resp *resp_data,
struct pldm_downstream_device_parameters_iter *iter)
{
- PLDM_MSGBUF_DEFINE_P(buf);
- void *remaining = NULL;
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
+ const void *remaining = NULL;
size_t length;
int rc;
@@ -1805,10 +1807,10 @@
struct pldm_downstream_device_parameters_iter *iter,
struct pldm_downstream_device_parameters_entry *entry)
{
- PLDM_MSGBUF_DEFINE_P(buf);
- void *comp_ver_str;
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
+ const void *comp_ver_str;
+ const void *cursor;
size_t remaining;
- void *cursor;
int rc;
if (iter == NULL || iter->field.ptr == NULL || entry == NULL) {
@@ -1894,7 +1896,7 @@
const struct pldm_request_downstream_device_update_req *req_data,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!req_data || !msg || !payload_length ||
@@ -1935,7 +1937,7 @@
struct pldm_request_downstream_device_update_req *req)
{
int rc;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
if (!msg || !req) {
return -EINVAL;
@@ -1961,7 +1963,7 @@
const struct pldm_request_downstream_device_update_resp *resp_data,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!resp_data || !msg || !payload_length) {
@@ -1997,7 +1999,7 @@
const struct pldm_msg *msg, size_t payload_length,
struct pldm_request_downstream_device_update_resp *resp_data)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!msg || !resp_data) {
@@ -2094,7 +2096,7 @@
{
int rc;
uint8_t t;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
if (msg == NULL || req == NULL) {
return -EINVAL;
@@ -2167,7 +2169,7 @@
const struct pldm_request_update_resp *resp_data,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL || payload_length == NULL) {
@@ -2266,7 +2268,7 @@
{
int rc;
uint8_t t;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
if (msg == NULL || pcomp == NULL) {
return -EINVAL;
@@ -2348,7 +2350,7 @@
const struct pldm_pass_component_table_resp *resp_data,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL || payload_length == NULL) {
@@ -2439,7 +2441,7 @@
{
int rc;
uint8_t t;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
if (msg == NULL || up == NULL) {
return -EINVAL;
@@ -2531,7 +2533,7 @@
uint8_t instance_id, const struct pldm_update_component_resp *resp_data,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL || payload_length == NULL) {
@@ -2587,7 +2589,7 @@
const struct pldm_request_firmware_data_req *req_params,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL || payload_length == NULL) {
@@ -2657,7 +2659,7 @@
int encode_transfer_complete_req(uint8_t instance_id, uint8_t transfer_result,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL || payload_length == NULL) {
@@ -2727,7 +2729,7 @@
int encode_verify_complete_req(uint8_t instance_id, uint8_t verify_result,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL || payload_length == NULL) {
@@ -2811,7 +2813,7 @@
const struct pldm_apply_complete_req *req_data,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL || payload_length == NULL) {
@@ -2868,7 +2870,7 @@
size_t payload_length, bool *self_contained)
{
uint8_t self_contained_u8 = 0;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || self_contained == NULL) {
@@ -2962,7 +2964,7 @@
const struct pldm_activate_firmware_resp *resp_data,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL || payload_length == NULL) {
@@ -3083,7 +3085,7 @@
const struct pldm_get_status_resp *status,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (status == NULL || msg == NULL || payload_length == NULL) {
@@ -3229,7 +3231,7 @@
const struct pldm_cancel_update_resp *resp_data,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL || payload_length == NULL) {
@@ -3278,7 +3280,7 @@
int pldm_package_firmware_device_id_record_iter_init(struct pldm_package *pkg)
{
struct pldm_package_iter *iter;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!pkg || !pkg->pin || !pkg->hdr) {
@@ -3315,7 +3317,7 @@
}
pldm_msgbuf_extract_uint8_to_size(buf, iter->entries);
- pldm_msgbuf_span_remaining(buf, (void **)&iter->field.ptr,
+ pldm_msgbuf_span_remaining(buf, (const void **)&iter->field.ptr,
&iter->field.length);
return pldm_msgbuf_complete(buf);
@@ -3342,7 +3344,7 @@
int pldm_package_downstream_device_id_record_iter_init(struct pldm_package *pkg)
{
struct pldm_package_iter *iter;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!pkg || !pkg->pin || !pkg->hdr) {
@@ -3396,7 +3398,7 @@
}
pldm_msgbuf_extract_uint8_to_size(buf, iter->entries);
- pldm_msgbuf_span_remaining(buf, (void **)&iter->field.ptr,
+ pldm_msgbuf_span_remaining(buf, (const void **)&iter->field.ptr,
&iter->field.length);
return pldm_msgbuf_complete(buf);
@@ -3410,7 +3412,7 @@
{
struct pldm_package_iter *iter;
size_t package_data_offset;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
uint16_t record_len = 0;
int rc;
@@ -3478,7 +3480,7 @@
assert((pkg->hdr->component_bitmap_bit_length & 7) == 0);
rc = pldm_msgbuf_span_required(
buf, pkg->hdr->component_bitmap_bit_length / 8,
- (void **)&rec->applicable_components.bitmap.ptr);
+ (const void **)&rec->applicable_components.bitmap.ptr);
if (rc) {
return pldm_msgbuf_discard(buf, rc);
}
@@ -3487,7 +3489,8 @@
pldm_msgbuf_span_required(
buf, rec->self_contained_activation_min_version_string.length,
- (void **)&rec->self_contained_activation_min_version_string.ptr);
+ (const void **)&rec
+ ->self_contained_activation_min_version_string.ptr);
if (rec->update_option_flags.bits.bit0) {
pldm_msgbuf_extract(
buf,
@@ -3501,18 +3504,18 @@
rec->package_data.length + rec->reference_manifest_data.length;
pldm_msgbuf_span_until(buf, package_data_offset,
- (void **)&rec->record_descriptors.ptr,
+ (const void **)&rec->record_descriptors.ptr,
&rec->record_descriptors.length);
pldm_msgbuf_span_required(buf, rec->package_data.length,
- (void **)&rec->package_data.ptr);
+ (const void **)&rec->package_data.ptr);
/* Supported in package header revision 1.3 (FR04H) and above. */
if (pkg->hdr->package_header_format_revision >=
PLDM_PACKAGE_HEADER_FORMAT_REVISION_FR04H) {
pldm_msgbuf_span_required(
buf, rec->reference_manifest_data.length,
- (void **)&rec->reference_manifest_data.ptr);
+ (const void **)&rec->reference_manifest_data.ptr);
} else {
assert(rec->reference_manifest_data.length == 0);
rec->reference_manifest_data.ptr = NULL;
@@ -3526,7 +3529,7 @@
{
struct pldm_package_iter *iter;
uint16_t component_image_count;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!pkg || !pkg->pin || !pkg->hdr) {
@@ -3576,7 +3579,7 @@
}
iter->entries = component_image_count;
- pldm_msgbuf_span_remaining(buf, (void **)&iter->field.ptr,
+ pldm_msgbuf_span_remaining(buf, (const void **)&iter->field.ptr,
&iter->field.length);
return pldm_msgbuf_complete(buf);
@@ -3591,7 +3594,7 @@
uint32_t component_location_offset = 0;
struct pldm_package_iter *iter;
uint32_t component_size = 0;
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!pkg || !info) {
@@ -3637,8 +3640,9 @@
return pldm_msgbuf_discard(buf, rc);
}
- pldm_msgbuf_span_required(buf, info->component_version_string.length,
- (void **)&info->component_version_string.ptr);
+ pldm_msgbuf_span_required(
+ buf, info->component_version_string.length,
+ (const void **)&info->component_version_string.ptr);
/* Supported in package header revision 1.2 (FR03H) and above. */
if (pkg->hdr->package_header_format_revision >=
@@ -3650,7 +3654,7 @@
}
pldm_msgbuf_span_required(
buf, info->component_opaque_data.length,
- (void **)&info->component_opaque_data.ptr);
+ (const void **)&info->component_opaque_data.ptr);
} else {
info->component_opaque_data.length = 0;
}
@@ -3659,7 +3663,7 @@
info->component_opaque_data.ptr = NULL;
}
- pldm_msgbuf_span_remaining(buf, (void **)&iter->field.ptr,
+ pldm_msgbuf_span_remaining(buf, (const void **)&iter->field.ptr,
&iter->field.length);
rc = pldm_msgbuf_complete_consumed(buf);
@@ -3681,7 +3685,7 @@
pldm_msgbuf_span_required(buf, component_location_offset, NULL);
pldm_msgbuf_span_required(buf, component_size,
- (void **)&info->component_image.ptr);
+ (const void **)&info->component_image.ptr);
rc = pldm_msgbuf_complete(buf);
if (rc) {
diff --git a/src/dsp/pdr.c b/src/dsp/pdr.c
index f8873b1..fd36b56 100644
--- a/src/dsp/pdr.c
+++ b/src/dsp/pdr.c
@@ -6,10 +6,11 @@
#include <assert.h>
#include <endian.h>
+#include <errno.h>
+#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
#define PDR_ENTITY_ASSOCIATION_MIN_SIZE \
(sizeof(struct pldm_pdr_hdr) + \
@@ -407,7 +408,7 @@
static int decode_pldm_state_sensor_pdr(uint8_t *data, uint32_t size,
struct pldm_state_sensor_pdr *pdr)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc = 0;
rc = pldm_msgbuf_init_errno(buf, sizeof(struct pldm_state_sensor_pdr),
(uint8_t *)data, size);
@@ -534,7 +535,7 @@
static int decode_pldm_state_effecter_pdr(uint8_t *data, uint32_t size,
struct pldm_state_effecter_pdr *pdr)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc = 0;
rc = pldm_msgbuf_init_errno(buf, sizeof(struct pldm_state_effecter_pdr),
(uint8_t *)data, size);
@@ -619,8 +620,8 @@
record = repo->first;
while (record != NULL) {
- struct pldm_msgbuf _buf;
- struct pldm_msgbuf *buf = &_buf;
+ struct pldm_msgbuf_ro _buf;
+ struct pldm_msgbuf_ro *buf = &_buf;
rc = pldm_msgbuf_init_errno(buf, sizeof(struct pldm_pdr_hdr),
record->data, record->size);
@@ -1701,8 +1702,8 @@
int rc = 0;
uint16_t header_length = 0;
uint8_t num_children = 0;
- PLDM_MSGBUF_DEFINE_P(src);
- PLDM_MSGBUF_DEFINE_P(dst);
+ PLDM_MSGBUF_RO_DEFINE_P(src);
+ PLDM_MSGBUF_RW_DEFINE_P(dst);
pldm_pdr_find_record_by_handle(&record, &prev, pdr_record_handle);
@@ -1851,9 +1852,9 @@
uint16_t new_pdr_size;
uint16_t container_id = 0;
void *container_id_addr;
- PLDM_MSGBUF_DEFINE_P(dst);
- PLDM_MSGBUF_DEFINE_P(src_p);
- PLDM_MSGBUF_DEFINE_P(src_c);
+ PLDM_MSGBUF_RW_DEFINE_P(dst);
+ PLDM_MSGBUF_RO_DEFINE_P(src_p);
+ PLDM_MSGBUF_RO_DEFINE_P(src_c);
int rc = 0;
pldm_pdr_record *prev = repo->first;
@@ -1998,7 +1999,7 @@
pldm_pdr_record *record = repo->first;
while (record != NULL) {
- PLDM_MSGBUF_DEFINE_P(dst);
+ PLDM_MSGBUF_RO_DEFINE_P(dst);
rc = pldm_msgbuf_init_errno(dst,
PDR_ENTITY_ASSOCIATION_MIN_SIZE,
@@ -2057,8 +2058,8 @@
{
uint16_t header_length = 0;
uint8_t num_children = 0;
- PLDM_MSGBUF_DEFINE_P(src);
- PLDM_MSGBUF_DEFINE_P(dst);
+ PLDM_MSGBUF_RO_DEFINE_P(src);
+ PLDM_MSGBUF_RW_DEFINE_P(dst);
int rc;
pldm_pdr_record *record;
pldm_pdr_record *prev;
@@ -2241,7 +2242,7 @@
uint16_t record_fru_rsi = 0;
uint8_t *skip_data = NULL;
uint8_t skip_data_size = 0;
- PLDM_MSGBUF_DEFINE_P(dst);
+ PLDM_MSGBUF_RO_DEFINE_P(dst);
int rc = 0;
rc = pldm_msgbuf_init_errno(dst, PDR_FRU_RECORD_SET_MIN_SIZE,
@@ -2250,7 +2251,8 @@
return rc;
}
skip_data_size = sizeof(struct pldm_pdr_hdr) + sizeof(uint16_t);
- pldm_msgbuf_span_required(dst, skip_data_size, (void **)&skip_data);
+ pldm_msgbuf_span_required(dst, skip_data_size,
+ (const void **)&skip_data);
pldm_msgbuf_extract(dst, record_fru_rsi);
rc = pldm_msgbuf_complete(dst);
@@ -2315,7 +2317,7 @@
record = repo->first;
while (record != NULL) {
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
rc = pldm_msgbuf_init_errno(buf, PDR_FRU_RECORD_SET_MIN_SIZE,
record->data, record->size);
diff --git a/src/dsp/platform.c b/src/dsp/platform.c
index 33861e1..d1fdce6 100644
--- a/src/dsp/platform.c
+++ b/src/dsp/platform.c
@@ -265,7 +265,7 @@
uint8_t *comp_effecter_count,
set_effecter_state_field *field)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
int i;
@@ -314,7 +314,7 @@
uint8_t *transfer_op_flag, uint16_t *request_cnt,
uint16_t *record_chg_num)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || record_hndl == NULL || data_transfer_hndl == NULL ||
@@ -466,7 +466,7 @@
uint32_t *repository_size, uint32_t *largest_record_size,
uint8_t *data_transfer_handle_timeout)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || completion_code == NULL ||
@@ -533,7 +533,7 @@
const struct pldm_msg *msg, size_t payload_length,
struct pldm_pdr_repository_info_resp *resp)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || resp == NULL) {
@@ -626,7 +626,7 @@
uint8_t *record_data, size_t record_data_length,
uint8_t *transfer_crc)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || completion_code == NULL ||
@@ -688,7 +688,7 @@
struct pldm_get_pdr_resp *resp, size_t resp_len,
uint8_t *transfer_crc)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || resp == NULL || transfer_crc == NULL) {
@@ -742,7 +742,7 @@
uint8_t *effecter_data_size,
uint8_t effecter_value[4])
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || effecter_id == NULL || effecter_data_size == NULL ||
@@ -966,7 +966,7 @@
uint8_t *comp_sensor_count,
get_sensor_state_field *field)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
uint8_t i;
int rc;
@@ -1022,7 +1022,7 @@
bitfield8_t *sensor_rearm,
uint8_t *reserved)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || sensor_id == NULL || sensor_rearm == NULL) {
@@ -1091,7 +1091,7 @@
uint8_t *event_class,
size_t *event_data_offset)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || format_version == NULL || tid == NULL ||
@@ -1145,7 +1145,7 @@
uint8_t *format_version, uint8_t *transfer_operation_flag,
uint32_t *data_transfer_handle, uint16_t *event_id_to_acknowledge)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || format_version == NULL ||
@@ -1231,7 +1231,7 @@
uint8_t *event_data, uint32_t checksum, struct pldm_msg *msg,
size_t payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!msg) {
@@ -1371,7 +1371,7 @@
uint8_t *completion_code,
uint8_t *platform_event_status)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || completion_code == NULL ||
@@ -1441,7 +1441,7 @@
uint8_t *completion_code,
uint16_t *terminus_max_buffer_size)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || completion_code == NULL ||
@@ -1516,7 +1516,7 @@
uint8_t *event_class,
uint8_t event_class_count)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int i;
int rc;
@@ -1589,7 +1589,7 @@
uint8_t *sensor_event_class_type,
size_t *event_class_data_offset)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (event_data == NULL || sensor_id == NULL ||
@@ -1656,7 +1656,7 @@
int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
uint8_t *present_op_state, uint8_t *previous_op_state)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (sensor_data == NULL || present_op_state == NULL ||
@@ -1688,7 +1688,7 @@
uint8_t *event_state,
uint8_t *previous_event_state)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (sensor_data == NULL || sensor_offset == NULL ||
@@ -1722,7 +1722,7 @@
uint8_t *sensor_data_size,
uint32_t *present_reading)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (sensor_data == NULL || sensor_data_size == NULL ||
@@ -1815,7 +1815,7 @@
const void *pdr_data, size_t pdr_data_length,
struct pldm_numeric_sensor_value_pdr *pdr_value)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!pdr_data || !pdr_value) {
@@ -2027,7 +2027,7 @@
size_t payload_length,
uint16_t *effecter_id)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || effecter_id == NULL) {
@@ -2060,7 +2060,7 @@
uint8_t *pending_value,
uint8_t *present_value)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || effecter_data_size == NULL ||
@@ -2187,7 +2187,7 @@
uint8_t *number_of_change_records,
size_t *change_record_data_offset)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (event_data == NULL || event_data_format == NULL ||
@@ -2222,7 +2222,7 @@
const void *event_data, size_t event_data_length,
struct pldm_message_poll_event *poll_event)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!event_data || !poll_event) {
@@ -2255,7 +2255,7 @@
const struct pldm_message_poll_event *poll_event, void *event_data,
size_t event_data_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (poll_event == NULL || event_data == NULL) {
@@ -2284,7 +2284,7 @@
uint8_t *event_data_operation, uint8_t *number_of_change_entries,
size_t *change_entry_data_offset)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (change_record_data == NULL || event_data_operation == NULL ||
@@ -2351,7 +2351,7 @@
uint8_t *present_state, uint8_t *previous_state, uint8_t *event_state,
uint8_t *present_reading)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || completion_code == NULL ||
@@ -2479,7 +2479,7 @@
size_t payload_length, uint16_t *sensor_id,
uint8_t *rearm_event_state)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || sensor_id == NULL || rearm_event_state == NULL) {
@@ -2508,7 +2508,7 @@
const struct pldm_msg *msg, size_t payload_length,
struct pldm_set_numeric_sensor_enable_req *req)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
uint8_t event_enable = 0;
uint8_t op_state = 0;
int rc;
@@ -2550,7 +2550,7 @@
const struct pldm_msg *msg, size_t payload_length,
struct pldm_set_state_sensor_enables_req *req)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || req == NULL) {
@@ -2621,7 +2621,7 @@
struct pldm_get_event_receiver_resp *event_receiver_info,
struct pldm_msg *msg, size_t *payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (!msg || !event_receiver_info) {
return -EINVAL;
@@ -2661,7 +2661,7 @@
size_t payload_length,
struct pldm_get_event_receiver_resp *resp)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!msg) {
return -EINVAL;
@@ -2742,7 +2742,7 @@
size_t payload_length,
uint8_t *completion_code)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || completion_code == NULL) {
@@ -2774,7 +2774,7 @@
uint16_t *heartbeat_timer)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || event_message_global_enable == NULL ||
@@ -2849,7 +2849,7 @@
struct pldm_msg *msg,
size_t payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL) {
@@ -2901,7 +2901,7 @@
uint8_t *event_class, uint32_t *event_data_size, void **event_data,
uint32_t *event_data_integrity_checksum)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || completion_code == NULL || tid == NULL ||
@@ -2952,7 +2952,8 @@
}
if (*event_data_size > 0) {
- pldm_msgbuf_span_required(buf, *event_data_size, event_data);
+ pldm_msgbuf_span_required(buf, *event_data_size,
+ (const void **)event_data);
}
if (*transfer_flag == PLDM_END ||
@@ -2973,7 +2974,7 @@
const void *pdr_data, size_t pdr_data_length,
struct pldm_numeric_effecter_value_pdr *pdr_value)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
struct pldm_value_pdr_hdr hdr;
int rc;
@@ -3069,7 +3070,7 @@
struct pldm_msg *msg,
size_t payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
int rc;
if (msg == NULL) {
@@ -3104,7 +3105,7 @@
size_t payload_length,
uint16_t *effecter_id)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (msg == NULL || effecter_id == NULL) {
@@ -3128,7 +3129,7 @@
const struct pldm_msg *msg, size_t payload_length,
struct pldm_get_state_effecter_states_resp *resp)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
get_effecter_state_field *field;
int rc;
int i;
@@ -3180,7 +3181,7 @@
uint8_t instance_id, struct pldm_get_state_effecter_states_resp *resp,
struct pldm_msg *msg, size_t payload_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RW_DEFINE_P(buf);
get_effecter_state_field *field;
int rc;
int i;
@@ -3232,11 +3233,11 @@
const void *data, size_t data_length,
struct pldm_entity_auxiliary_names_pdr *pdr, size_t pdr_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
- PLDM_MSGBUF_DEFINE_P(src);
- PLDM_MSGBUF_DEFINE_P(dst);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(src);
+ PLDM_MSGBUF_RW_DEFINE_P(dst);
+ const void *names = NULL;
size_t names_len = 0;
- void *names = NULL;
int rc;
int i;
@@ -3355,7 +3356,7 @@
int decode_pldm_entity_auxiliary_names_pdr_index(
struct pldm_entity_auxiliary_names_pdr *pdr)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
int i;
@@ -3398,13 +3399,13 @@
for (i = 0; i < pdr->name_string_count; i++) {
void *loc = NULL;
- pldm_msgbuf_span_string_utf16(buf, &loc, NULL);
+ pldm_msgbuf_span_string_utf16(buf, (const void **)&loc, NULL);
pdr->names[i].name = loc;
}
for (i = 0; i < pdr->name_string_count; i++) {
void *loc = NULL;
- pldm_msgbuf_span_string_ascii(buf, &loc, NULL);
+ pldm_msgbuf_span_string_ascii(buf, (const void **)&loc, NULL);
pdr->names[i].tag = loc;
}
@@ -3417,7 +3418,7 @@
struct pldm_platform_cper_event *cper_event,
size_t cper_event_length)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!cper_event || !event_data) {
@@ -3477,7 +3478,7 @@
const void *data, size_t data_length,
struct pldm_platform_file_descriptor_pdr *pdr)
{
- PLDM_MSGBUF_DEFINE_P(buf);
+ PLDM_MSGBUF_RO_DEFINE_P(buf);
int rc;
if (!data || !pdr) {
@@ -3519,7 +3520,7 @@
}
pldm_msgbuf_span_required(buf, pdr->file_name.length,
- (void **)&pdr->file_name.ptr);
+ (const void **)&pdr->file_name.ptr);
pdr->oem_file_classification_name.length = 0;
@@ -3532,7 +3533,7 @@
pldm_msgbuf_span_required(
buf, pdr->oem_file_classification_name.length,
- (void **)&pdr->oem_file_classification_name.ptr);
+ (const void **)&pdr->oem_file_classification_name.ptr);
}
return pldm_msgbuf_complete_consumed(buf);