fix: sign extension
Unsigned values promoted to signed types, implicitly.
It would be possible to get the values sign extended,
which could lead to wrong results.
Explictly casting the values to wider unsigned types
to avoid issues.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I200f97d52ed9c072477ce6aabd88f25b45106d22
diff --git a/src/api.c b/src/api.c
index b43d054..1d33778 100644
--- a/src/api.c
+++ b/src/api.c
@@ -845,7 +845,7 @@
ret.func = FFA_SUCCESS_64;
ret.arg2 = (sizeof(struct ffa_partition_info) & 0xFFFF) << 48;
- ret.arg2 |= curr_idx << 16;
+ ret.arg2 |= ((uint64_t)curr_idx) << 16;
ret.arg2 |= max_idx;
if (num_entries_to_ret > 1) {
@@ -981,7 +981,8 @@
case FFA_MSG_SEND_32:
return (struct ffa_value){
.func = FFA_MSG_SEND_32,
- .arg1 = (receiver->mailbox.recv_sender << 16) |
+ .arg1 = ((uint64_t)(receiver->mailbox.recv_sender)
+ << 16) |
receiver->id,
.arg3 = receiver->mailbox.recv_size};
default: