msgbuf: Enable pldm_msgbuf_extract() into packed members

`pldm_msgbuf_extract()` should work correctly regardless of whether the
`dst` argument is a member of a packed or padded struct.

To get there while still achieving type safety we have to jump through
some hoops. Commentary in the patch hopefully captures many of them, but
a side-effect of the hoop-jumping is a couple of changes to ergonomics
of the msgbuf API:

1. `pldm_msgbuf_extract()` no-longer requires that the `dst`
   argument be a pointer. Instead, it must be an lvalue, removing all
   the `&<lvalue>` noise from the call-sites.

2. However, unfortunately the generic extraction macro has been split in
   two. We now have:

   2.1 `pldm_msgbuf_extract()`, and
   2.2 `pldm_msgbuf_extract_p()`, for when the reference we already have
        for the `dst` object is a pointer and not an lvalue.

The split was necessary because I couldn't get GCC and Clang to play
nice with differences required in the assignment expression for lvalue
and pointer type-names in the one macro. Whilst it causes a bunch of
churn it isn't a great concern as the APIs are purely internal to the
library implementation.

Change-Id: Ifc5440a5b838a48bb84c881ec334d9e145365edb
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
diff --git a/src/platform.c b/src/platform.c
index 1bd7889..6f7b940 100644
--- a/src/platform.c
+++ b/src/platform.c
@@ -276,16 +276,16 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, effecter_id);
-	pldm_msgbuf_extract(buf, comp_effecter_count);
+	pldm_msgbuf_extract_p(buf, effecter_id);
+	pldm_msgbuf_extract_p(buf, comp_effecter_count);
 
 	if (*comp_effecter_count > 8) {
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
 	for (i = 0; i < *comp_effecter_count; i++) {
-		pldm_msgbuf_extract(buf, &field[i].set_request);
-		pldm_msgbuf_extract(buf, &field[i].effecter_state);
+		pldm_msgbuf_extract(buf, field[i].set_request);
+		pldm_msgbuf_extract(buf, field[i].effecter_state);
 	}
 
 	return pldm_msgbuf_destroy(buf);
@@ -317,11 +317,11 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, record_hndl);
-	pldm_msgbuf_extract(buf, data_transfer_hndl);
-	pldm_msgbuf_extract(buf, transfer_op_flag);
-	pldm_msgbuf_extract(buf, request_cnt);
-	pldm_msgbuf_extract(buf, record_chg_num);
+	pldm_msgbuf_extract_p(buf, record_hndl);
+	pldm_msgbuf_extract_p(buf, data_transfer_hndl);
+	pldm_msgbuf_extract_p(buf, transfer_op_flag);
+	pldm_msgbuf_extract_p(buf, request_cnt);
+	pldm_msgbuf_extract_p(buf, record_chg_num);
 
 	return pldm_msgbuf_destroy(buf);
 }
@@ -445,22 +445,22 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, completion_code);
+	pldm_msgbuf_extract_p(buf, completion_code);
 	if (PLDM_SUCCESS != *completion_code) {
 		return PLDM_SUCCESS;
 	}
 
-	pldm_msgbuf_extract(buf, repository_state);
+	pldm_msgbuf_extract_p(buf, repository_state);
 	if (*repository_state > PLDM_FAILED) {
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
 	pldm_msgbuf_extract_array(buf, update_time, PLDM_TIMESTAMP104_SIZE);
 	pldm_msgbuf_extract_array(buf, oem_update_time, PLDM_TIMESTAMP104_SIZE);
-	pldm_msgbuf_extract(buf, record_count);
-	pldm_msgbuf_extract(buf, repository_size);
-	pldm_msgbuf_extract(buf, largest_record_size);
-	pldm_msgbuf_extract(buf, data_transfer_handle_timeout);
+	pldm_msgbuf_extract_p(buf, record_count);
+	pldm_msgbuf_extract_p(buf, repository_size);
+	pldm_msgbuf_extract_p(buf, largest_record_size);
+	pldm_msgbuf_extract_p(buf, data_transfer_handle_timeout);
 
 	return pldm_msgbuf_destroy(buf);
 }
@@ -525,15 +525,15 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, completion_code);
+	pldm_msgbuf_extract_p(buf, completion_code);
 	if (PLDM_SUCCESS != *completion_code) {
 		return PLDM_SUCCESS;
 	}
 
-	pldm_msgbuf_extract(buf, next_record_hndl);
-	pldm_msgbuf_extract(buf, next_data_transfer_hndl);
-	pldm_msgbuf_extract(buf, transfer_flag);
-	rc = pldm_msgbuf_extract(buf, resp_cnt);
+	pldm_msgbuf_extract_p(buf, next_record_hndl);
+	pldm_msgbuf_extract_p(buf, next_data_transfer_hndl);
+	pldm_msgbuf_extract_p(buf, transfer_flag);
+	rc = pldm_msgbuf_extract_p(buf, resp_cnt);
 	if (rc) {
 		return rc;
 	}
@@ -546,7 +546,7 @@
 	}
 
 	if (*transfer_flag == PLDM_END) {
-		pldm_msgbuf_extract(buf, transfer_crc);
+		pldm_msgbuf_extract_p(buf, transfer_crc);
 	}
 
 	return pldm_msgbuf_destroy(buf);
@@ -575,8 +575,8 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, effecter_id);
-	rc = pldm_msgbuf_extract(buf, effecter_data_size);
+	pldm_msgbuf_extract_p(buf, effecter_id);
+	rc = pldm_msgbuf_extract_p(buf, effecter_data_size);
 	if (rc) {
 		return PLDM_ERROR_INVALID_DATA;
 	}
@@ -796,7 +796,7 @@
 		return rc;
 	}
 
-	rc = pldm_msgbuf_extract(buf, completion_code);
+	rc = pldm_msgbuf_extract_p(buf, completion_code);
 	if (rc) {
 		return rc;
 	}
@@ -805,7 +805,7 @@
 		return PLDM_SUCCESS;
 	}
 
-	rc = pldm_msgbuf_extract(buf, comp_sensor_count);
+	rc = pldm_msgbuf_extract_p(buf, comp_sensor_count);
 	if (rc) {
 		return rc;
 	}
@@ -815,10 +815,10 @@
 	}
 
 	for (i = 0; i < *comp_sensor_count; i++) {
-		pldm_msgbuf_extract(buf, &field[i].sensor_op_state);
-		pldm_msgbuf_extract(buf, &field[i].present_state);
-		pldm_msgbuf_extract(buf, &field[i].previous_state);
-		pldm_msgbuf_extract(buf, &field[i].event_state);
+		pldm_msgbuf_extract(buf, field[i].sensor_op_state);
+		pldm_msgbuf_extract(buf, field[i].present_state);
+		pldm_msgbuf_extract(buf, field[i].previous_state);
+		pldm_msgbuf_extract(buf, field[i].event_state);
 	}
 
 	return pldm_msgbuf_destroy_consumed(buf);
@@ -845,9 +845,9 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, sensor_id);
-	pldm_msgbuf_extract(buf, &sensor_rearm->byte);
-	pldm_msgbuf_extract(buf, reserved);
+	pldm_msgbuf_extract_p(buf, sensor_id);
+	pldm_msgbuf_extract(buf, sensor_rearm->byte);
+	pldm_msgbuf_extract_p(buf, reserved);
 
 	return pldm_msgbuf_destroy(buf);
 }
@@ -910,9 +910,9 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, format_version);
-	pldm_msgbuf_extract(buf, tid);
-	pldm_msgbuf_extract(buf, event_class);
+	pldm_msgbuf_extract_p(buf, format_version);
+	pldm_msgbuf_extract_p(buf, tid);
+	pldm_msgbuf_extract_p(buf, event_class);
 	*event_data_offset =
 		sizeof(*format_version) + sizeof(*tid) + sizeof(*event_class);
 
@@ -940,8 +940,8 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, format_version);
-	rc = pldm_msgbuf_extract(buf, transfer_operation_flag);
+	pldm_msgbuf_extract_p(buf, format_version);
+	rc = pldm_msgbuf_extract_p(buf, transfer_operation_flag);
 	if (rc) {
 		return rc;
 	}
@@ -949,8 +949,8 @@
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
-	pldm_msgbuf_extract(buf, data_transfer_handle);
-	rc = pldm_msgbuf_extract(buf, event_id_to_acknowledge);
+	pldm_msgbuf_extract_p(buf, data_transfer_handle);
+	rc = pldm_msgbuf_extract_p(buf, event_id_to_acknowledge);
 	if (rc) {
 		return rc;
 	}
@@ -1136,7 +1136,7 @@
 		return rc;
 	}
 
-	rc = pldm_msgbuf_extract(buf, completion_code);
+	rc = pldm_msgbuf_extract_p(buf, completion_code);
 	if (rc) {
 		return rc;
 	}
@@ -1145,7 +1145,7 @@
 		return PLDM_SUCCESS;
 	}
 
-	rc = pldm_msgbuf_extract(buf, platform_event_status);
+	rc = pldm_msgbuf_extract_p(buf, platform_event_status);
 	if (rc) {
 		return rc;
 	}
@@ -1202,7 +1202,7 @@
 		return rc;
 	}
 
-	rc = pldm_msgbuf_extract(buf, completion_code);
+	rc = pldm_msgbuf_extract_p(buf, completion_code);
 	if (rc) {
 		return rc;
 	}
@@ -1211,7 +1211,7 @@
 		return PLDM_SUCCESS;
 	}
 
-	pldm_msgbuf_extract(buf, terminus_max_buffer_size);
+	pldm_msgbuf_extract_p(buf, terminus_max_buffer_size);
 
 	return pldm_msgbuf_destroy_consumed(buf);
 }
@@ -1274,7 +1274,7 @@
 		return rc;
 	}
 
-	rc = pldm_msgbuf_extract(buf, completion_code);
+	rc = pldm_msgbuf_extract_p(buf, completion_code);
 	if (rc) {
 		return rc;
 	}
@@ -1283,7 +1283,7 @@
 		return PLDM_SUCCESS;
 	}
 
-	rc = pldm_msgbuf_extract(buf, synchrony_config);
+	rc = pldm_msgbuf_extract_p(buf, synchrony_config);
 	if (rc) {
 		return rc;
 	}
@@ -1292,9 +1292,9 @@
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
-	pldm_msgbuf_extract(buf, &synchrony_config_support->byte);
+	pldm_msgbuf_extract_p(buf, &synchrony_config_support->byte);
 
-	rc = pldm_msgbuf_extract(buf, number_event_class_returned);
+	rc = pldm_msgbuf_extract_p(buf, number_event_class_returned);
 	if (rc) {
 		return rc;
 	}
@@ -1308,7 +1308,7 @@
 	}
 
 	for (i = 0; i < *number_event_class_returned; i++) {
-		pldm_msgbuf_extract(buf, &event_class[i]);
+		pldm_msgbuf_extract(buf, event_class[i]);
 	}
 
 	return pldm_msgbuf_destroy_consumed(buf);
@@ -1333,8 +1333,8 @@
 	size_t event_class_data_length =
 		event_data_length - PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES;
 
-	pldm_msgbuf_extract(buf, sensor_id);
-	rc = pldm_msgbuf_extract(buf, sensor_event_class_type);
+	pldm_msgbuf_extract_p(buf, sensor_id);
+	rc = pldm_msgbuf_extract_p(buf, sensor_event_class_type);
 	if (rc) {
 		return rc;
 	}
@@ -1385,8 +1385,8 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, present_op_state);
-	pldm_msgbuf_extract(buf, previous_op_state);
+	pldm_msgbuf_extract_p(buf, present_op_state);
+	pldm_msgbuf_extract_p(buf, previous_op_state);
 
 	return pldm_msgbuf_destroy_consumed(buf);
 }
@@ -1413,9 +1413,9 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, sensor_offset);
-	pldm_msgbuf_extract(buf, event_state);
-	pldm_msgbuf_extract(buf, previous_event_state);
+	pldm_msgbuf_extract_p(buf, sensor_offset);
+	pldm_msgbuf_extract_p(buf, event_state);
+	pldm_msgbuf_extract_p(buf, previous_event_state);
 
 	return pldm_msgbuf_destroy_consumed(buf);
 }
@@ -1448,9 +1448,9 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, event_state);
-	pldm_msgbuf_extract(buf, previous_event_state);
-	rc = pldm_msgbuf_extract(buf, sensor_data_size);
+	pldm_msgbuf_extract_p(buf, event_state);
+	pldm_msgbuf_extract_p(buf, previous_event_state);
+	rc = pldm_msgbuf_extract_p(buf, sensor_data_size);
 	if (rc) {
 		return rc;
 	}
@@ -1463,42 +1463,42 @@
 	switch (*sensor_data_size) {
 	case PLDM_SENSOR_DATA_SIZE_UINT8: {
 		uint8_t val;
-		if (!pldm_msgbuf_extract(buf, &val)) {
+		if (!pldm_msgbuf_extract(buf, val)) {
 			*present_reading = (uint32_t)val;
 		}
 		break;
 	}
 	case PLDM_SENSOR_DATA_SIZE_SINT8: {
 		int8_t val;
-		if (!pldm_msgbuf_extract(buf, &val)) {
+		if (!pldm_msgbuf_extract(buf, val)) {
 			*present_reading = (uint32_t)(int32_t)val;
 		}
 		break;
 	}
 	case PLDM_SENSOR_DATA_SIZE_UINT16: {
 		uint16_t val;
-		if (!pldm_msgbuf_extract(buf, &val)) {
+		if (!pldm_msgbuf_extract(buf, val)) {
 			*present_reading = (uint32_t)val;
 		}
 		break;
 	}
 	case PLDM_SENSOR_DATA_SIZE_SINT16: {
 		int16_t val;
-		if (!pldm_msgbuf_extract(buf, &val)) {
+		if (!pldm_msgbuf_extract(buf, val)) {
 			*present_reading = (uint32_t)(int32_t)val;
 		}
 		break;
 	}
 	case PLDM_SENSOR_DATA_SIZE_UINT32: {
 		uint32_t val;
-		if (!pldm_msgbuf_extract(buf, &val)) {
+		if (!pldm_msgbuf_extract(buf, val)) {
 			*present_reading = (uint32_t)val;
 		}
 		break;
 	}
 	case PLDM_SENSOR_DATA_SIZE_SINT32: {
 		int32_t val;
-		if (!pldm_msgbuf_extract(buf, &val)) {
+		if (!pldm_msgbuf_extract(buf, val)) {
 			*present_reading = (uint32_t)val;
 		}
 		break;
@@ -1537,25 +1537,25 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, &pdr_value->terminus_handle);
-	pldm_msgbuf_extract(buf, &pdr_value->sensor_id);
-	pldm_msgbuf_extract(buf, &pdr_value->entity_type);
-	pldm_msgbuf_extract(buf, &pdr_value->entity_instance_num);
-	pldm_msgbuf_extract(buf, &pdr_value->container_id);
-	pldm_msgbuf_extract(buf, &pdr_value->sensor_init);
-	pldm_msgbuf_extract(buf, &pdr_value->sensor_auxiliary_names_pdr);
-	pldm_msgbuf_extract(buf, &pdr_value->base_unit);
-	pldm_msgbuf_extract(buf, &pdr_value->unit_modifier);
-	pldm_msgbuf_extract(buf, &pdr_value->rate_unit);
-	pldm_msgbuf_extract(buf, &pdr_value->base_oem_unit_handle);
-	pldm_msgbuf_extract(buf, &pdr_value->aux_unit);
-	pldm_msgbuf_extract(buf, &pdr_value->aux_unit_modifier);
-	pldm_msgbuf_extract(buf, &pdr_value->aux_rate_unit);
-	pldm_msgbuf_extract(buf, &pdr_value->rel);
-	pldm_msgbuf_extract(buf, &pdr_value->aux_oem_unit_handle);
-	pldm_msgbuf_extract(buf, &pdr_value->is_linear);
+	pldm_msgbuf_extract(buf, pdr_value->terminus_handle);
+	pldm_msgbuf_extract(buf, pdr_value->sensor_id);
+	pldm_msgbuf_extract(buf, pdr_value->entity_type);
+	pldm_msgbuf_extract(buf, pdr_value->entity_instance_num);
+	pldm_msgbuf_extract(buf, pdr_value->container_id);
+	pldm_msgbuf_extract(buf, pdr_value->sensor_init);
+	pldm_msgbuf_extract(buf, pdr_value->sensor_auxiliary_names_pdr);
+	pldm_msgbuf_extract(buf, pdr_value->base_unit);
+	pldm_msgbuf_extract(buf, pdr_value->unit_modifier);
+	pldm_msgbuf_extract(buf, pdr_value->rate_unit);
+	pldm_msgbuf_extract(buf, pdr_value->base_oem_unit_handle);
+	pldm_msgbuf_extract(buf, pdr_value->aux_unit);
+	pldm_msgbuf_extract(buf, pdr_value->aux_unit_modifier);
+	pldm_msgbuf_extract(buf, pdr_value->aux_rate_unit);
+	pldm_msgbuf_extract(buf, pdr_value->rel);
+	pldm_msgbuf_extract(buf, pdr_value->aux_oem_unit_handle);
+	pldm_msgbuf_extract(buf, pdr_value->is_linear);
 
-	rc = pldm_msgbuf_extract(buf, &pdr_value->sensor_data_size);
+	rc = pldm_msgbuf_extract(buf, pdr_value->sensor_data_size);
 	if (rc) {
 		return rc;
 	}
@@ -1563,24 +1563,24 @@
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
-	pldm_msgbuf_extract(buf, &pdr_value->resolution);
-	pldm_msgbuf_extract(buf, &pdr_value->offset);
-	pldm_msgbuf_extract(buf, &pdr_value->accuracy);
-	pldm_msgbuf_extract(buf, &pdr_value->plus_tolerance);
-	pldm_msgbuf_extract(buf, &pdr_value->minus_tolerance);
+	pldm_msgbuf_extract(buf, pdr_value->resolution);
+	pldm_msgbuf_extract(buf, pdr_value->offset);
+	pldm_msgbuf_extract(buf, pdr_value->accuracy);
+	pldm_msgbuf_extract(buf, pdr_value->plus_tolerance);
+	pldm_msgbuf_extract(buf, pdr_value->minus_tolerance);
 	pldm_msgbuf_extract_sensor_data(buf, pdr_value->sensor_data_size,
 					&pdr_value->hysteresis);
-	pldm_msgbuf_extract(buf, &pdr_value->supported_thresholds.byte);
+	pldm_msgbuf_extract(buf, pdr_value->supported_thresholds.byte);
 	pldm_msgbuf_extract(
-		buf, &pdr_value->threshold_and_hysteresis_volatility.byte);
-	pldm_msgbuf_extract(buf, &pdr_value->state_transition_interval);
-	pldm_msgbuf_extract(buf, &pdr_value->update_interval);
+		buf, pdr_value->threshold_and_hysteresis_volatility.byte);
+	pldm_msgbuf_extract(buf, pdr_value->state_transition_interval);
+	pldm_msgbuf_extract(buf, pdr_value->update_interval);
 	pldm_msgbuf_extract_sensor_data(buf, pdr_value->sensor_data_size,
 					&pdr_value->max_readable);
 	pldm_msgbuf_extract_sensor_data(buf, pdr_value->sensor_data_size,
 					&pdr_value->min_readable);
 
-	rc = pldm_msgbuf_extract(buf, &pdr_value->range_field_format);
+	rc = pldm_msgbuf_extract(buf, pdr_value->range_field_format);
 	if (rc) {
 		return rc;
 	}
@@ -1588,25 +1588,25 @@
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
-	pldm_msgbuf_extract(buf, &pdr_value->range_field_support.byte);
+	pldm_msgbuf_extract(buf, pdr_value->range_field_support.byte);
 	pldm_msgbuf_extract_range_field_format(
-		buf, pdr_value->range_field_format, &pdr_value->nominal_value);
+		buf, pdr_value->range_field_format, pdr_value->nominal_value);
 	pldm_msgbuf_extract_range_field_format(
-		buf, pdr_value->range_field_format, &pdr_value->normal_max);
+		buf, pdr_value->range_field_format, pdr_value->normal_max);
 	pldm_msgbuf_extract_range_field_format(
-		buf, pdr_value->range_field_format, &pdr_value->normal_min);
+		buf, pdr_value->range_field_format, pdr_value->normal_min);
 	pldm_msgbuf_extract_range_field_format(
-		buf, pdr_value->range_field_format, &pdr_value->warning_high);
+		buf, pdr_value->range_field_format, pdr_value->warning_high);
 	pldm_msgbuf_extract_range_field_format(
-		buf, pdr_value->range_field_format, &pdr_value->warning_low);
+		buf, pdr_value->range_field_format, pdr_value->warning_low);
 	pldm_msgbuf_extract_range_field_format(
-		buf, pdr_value->range_field_format, &pdr_value->critical_high);
+		buf, pdr_value->range_field_format, pdr_value->critical_high);
 	pldm_msgbuf_extract_range_field_format(
-		buf, pdr_value->range_field_format, &pdr_value->critical_low);
+		buf, pdr_value->range_field_format, pdr_value->critical_low);
 	pldm_msgbuf_extract_range_field_format(
-		buf, pdr_value->range_field_format, &pdr_value->fatal_high);
+		buf, pdr_value->range_field_format, pdr_value->fatal_high);
 	pldm_msgbuf_extract_range_field_format(
-		buf, pdr_value->range_field_format, &pdr_value->fatal_low);
+		buf, pdr_value->range_field_format, pdr_value->fatal_low);
 
 	return pldm_msgbuf_destroy(buf);
 }
@@ -1738,7 +1738,7 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, effecter_id);
+	pldm_msgbuf_extract_p(buf, effecter_id);
 
 	return pldm_msgbuf_destroy_consumed(buf);
 }
@@ -1769,7 +1769,7 @@
 		return rc;
 	}
 
-	rc = pldm_msgbuf_extract(buf, completion_code);
+	rc = pldm_msgbuf_extract_p(buf, completion_code);
 	if (rc) {
 		return rc;
 	}
@@ -1778,7 +1778,7 @@
 		return PLDM_SUCCESS;
 	}
 
-	rc = pldm_msgbuf_extract(buf, effecter_data_size);
+	rc = pldm_msgbuf_extract_p(buf, effecter_data_size);
 	if (rc) {
 		return rc;
 	}
@@ -1787,7 +1787,7 @@
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
-	rc = pldm_msgbuf_extract(buf, effecter_oper_state);
+	rc = pldm_msgbuf_extract_p(buf, effecter_oper_state);
 	if (rc) {
 		return rc;
 	}
@@ -1890,8 +1890,8 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, event_data_format);
-	pldm_msgbuf_extract(buf, number_of_change_records);
+	pldm_msgbuf_extract_p(buf, event_data_format);
+	pldm_msgbuf_extract_p(buf, number_of_change_records);
 
 	*change_record_data_offset =
 		sizeof(*event_data_format) + sizeof(*number_of_change_records);
@@ -1921,8 +1921,8 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, format_version);
-	rc = pldm_msgbuf_extract(buf, event_id);
+	pldm_msgbuf_extract_p(buf, format_version);
+	rc = pldm_msgbuf_extract_p(buf, event_id);
 	if (rc) {
 		return rc;
 	}
@@ -1931,7 +1931,7 @@
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
-	pldm_msgbuf_extract(buf, data_transfer_handle);
+	pldm_msgbuf_extract_p(buf, data_transfer_handle);
 
 	return pldm_msgbuf_destroy_consumed(buf);
 }
@@ -1988,8 +1988,8 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, event_data_operation);
-	pldm_msgbuf_extract(buf, number_of_change_entries);
+	pldm_msgbuf_extract_p(buf, event_data_operation);
+	pldm_msgbuf_extract_p(buf, number_of_change_entries);
 
 	*change_entry_data_offset = sizeof(*event_data_operation) +
 				    sizeof(*number_of_change_entries);
@@ -2052,7 +2052,7 @@
 		return rc;
 	}
 
-	rc = pldm_msgbuf_extract(buf, completion_code);
+	rc = pldm_msgbuf_extract_p(buf, completion_code);
 	if (rc) {
 		return rc;
 	}
@@ -2061,7 +2061,7 @@
 		return PLDM_SUCCESS;
 	}
 
-	rc = pldm_msgbuf_extract(buf, sensor_data_size);
+	rc = pldm_msgbuf_extract_p(buf, sensor_data_size);
 	if (rc) {
 		return rc;
 	}
@@ -2070,11 +2070,11 @@
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
-	pldm_msgbuf_extract(buf, sensor_operational_state);
-	pldm_msgbuf_extract(buf, sensor_event_message_enable);
-	pldm_msgbuf_extract(buf, present_state);
-	pldm_msgbuf_extract(buf, previous_state);
-	pldm_msgbuf_extract(buf, event_state);
+	pldm_msgbuf_extract_p(buf, sensor_operational_state);
+	pldm_msgbuf_extract_p(buf, sensor_event_message_enable);
+	pldm_msgbuf_extract_p(buf, present_state);
+	pldm_msgbuf_extract_p(buf, previous_state);
+	pldm_msgbuf_extract_p(buf, event_state);
 
 	pldm_msgbuf_extract_sensor_value(buf, *sensor_data_size,
 					 present_reading);
@@ -2172,8 +2172,8 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, sensor_id);
-	pldm_msgbuf_extract(buf, rearm_event_state);
+	pldm_msgbuf_extract_p(buf, sensor_id);
+	pldm_msgbuf_extract_p(buf, rearm_event_state);
 
 	return pldm_msgbuf_destroy(buf);
 }
@@ -2242,7 +2242,7 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, completion_code);
+	pldm_msgbuf_extract_p(buf, completion_code);
 
 	return pldm_msgbuf_destroy(buf);
 }
@@ -2272,10 +2272,10 @@
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, event_message_global_enable);
-	pldm_msgbuf_extract(buf, transport_protocol_type);
-	pldm_msgbuf_extract(buf, event_receiver_address_info);
-	pldm_msgbuf_extract(buf, heartbeat_timer);
+	pldm_msgbuf_extract_p(buf, event_message_global_enable);
+	pldm_msgbuf_extract_p(buf, transport_protocol_type);
+	pldm_msgbuf_extract_p(buf, event_receiver_address_info);
+	pldm_msgbuf_extract_p(buf, heartbeat_timer);
 
 	rc = pldm_msgbuf_destroy(buf);
 	if (rc) {
@@ -2386,7 +2386,7 @@
 		return rc;
 	}
 
-	rc = pldm_msgbuf_extract(buf, completion_code);
+	rc = pldm_msgbuf_extract_p(buf, completion_code);
 	if (rc) {
 		return rc;
 	}
@@ -2394,8 +2394,8 @@
 		return *completion_code;
 	}
 
-	pldm_msgbuf_extract(buf, tid);
-	rc = pldm_msgbuf_extract(buf, event_id);
+	pldm_msgbuf_extract_p(buf, tid);
+	rc = pldm_msgbuf_extract_p(buf, event_id);
 	if (rc) {
 		return rc;
 	}
@@ -2403,14 +2403,14 @@
 		return PLDM_SUCCESS;
 	}
 
-	pldm_msgbuf_extract(buf, next_data_transfer_handle);
-	rc = pldm_msgbuf_extract(buf, transfer_flag);
+	pldm_msgbuf_extract_p(buf, next_data_transfer_handle);
+	rc = pldm_msgbuf_extract_p(buf, transfer_flag);
 	if (rc) {
 		return rc;
 	}
 
-	pldm_msgbuf_extract(buf, event_class);
-	rc = pldm_msgbuf_extract(buf, event_data_size);
+	pldm_msgbuf_extract_p(buf, event_class);
+	rc = pldm_msgbuf_extract_p(buf, event_data_size);
 	if (rc) {
 		return rc;
 	}
@@ -2424,7 +2424,7 @@
 
 	if (*transfer_flag == PLDM_END ||
 	    *transfer_flag == PLDM_START_AND_END) {
-		pldm_msgbuf_extract(buf, event_data_integrity_checksum);
+		pldm_msgbuf_extract_p(buf, event_data_integrity_checksum);
 	}
 
 	return pldm_msgbuf_destroy_consumed(buf);