refactor(memory share): use receiver_offsets to find receiver array
The receiver_offsets field was introduced to the ffa_memory_region
struct to help with forwards compatability in future FF-A versions
as the size of the `ffa_memory_region` struct varies. This patch moves
away from using `sizeof(ffa_memory_region)` to find the receiver array
and instead to using the `receivers_offset` field.
This is safe to do due to the introdution to the use of the
`ffa_memory_region_check_values` function in the previous patch.
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I6aac59df0ad19ef500550d1bd60d1519a125598a
diff --git a/src/api.c b/src/api.c
index a124abd..9d08db9 100644
--- a/src/api.c
+++ b/src/api.c
@@ -3026,8 +3026,7 @@
memory_region_v1_1->memory_access_desc_size =
sizeof(struct ffa_memory_access_v1_0);
memory_region_v1_1->receiver_count = memory_region_v1_0->receiver_count;
- memory_region_v1_1->receivers_offset =
- offsetof(struct ffa_memory_region, receivers);
+ memory_region_v1_1->receivers_offset = sizeof(struct ffa_memory_region);
/* Zero reserved fields. */
for (uint32_t i = 0; i < 3U; i++) {
@@ -3147,8 +3146,9 @@
space_left -= sizeof(struct ffa_memory_region);
/* Copy memory access information. */
- memcpy_s(memory_region_v1_1->receivers, space_left,
- memory_region_v1_0->receivers, receivers_length);
+ memcpy_s((uint8_t *)memory_region_v1_1 +
+ memory_region_v1_1->receivers_offset,
+ space_left, memory_region_v1_0->receivers, receivers_length);
/* Initialize the memory access descriptors with composite offset. */
for (uint32_t i = 0; i < memory_region_v1_1->receiver_count; i++) {