1.1 --- a/libipc/lib/src/message.c Sun Jan 21 17:35:01 2024 +0100
1.2 +++ b/libipc/lib/src/message.c Sun Jan 21 17:56:36 2024 +0100
1.3 @@ -213,6 +213,7 @@
1.4 msg->discarded_items = 0;
1.5 msg->words = 0;
1.6 msg->items = 0;
1.7 + msg->import_item = 0;
1.8
1.9 /* Message label overriding. */
1.10
1.11 @@ -279,7 +280,7 @@
1.12 void ipc_message_add_receive_capability(ipc_message_t *msg, l4_cap_idx_t cap)
1.13 {
1.14 (void) cap;
1.15 - return _expect_capability(&msg->bregs, msg->receive_items++);
1.16 + _expect_capability(&msg->bregs, msg->receive_items++);
1.17 }
1.18
1.19 /* Add a receive window flexpage item to the message. */
1.20 @@ -502,14 +503,16 @@
1.21 long err;
1.22 int local;
1.23
1.24 - err = _import_capability(msg->tag, &msg->bregs, &msg->mregs, item, ref, &local);
1.25 + err = _import_capability(msg->tag, &msg->bregs, &msg->mregs, item, msg->import_item, ref, &local);
1.26 if (err)
1.27 return err;
1.28
1.29 if (local)
1.30 return L4_EOK;
1.31
1.32 - return ipc_message_expect_capability(msg, item);
1.33 + err = ipc_message_expect_capability(msg, msg->import_item);
1.34 + msg->import_item += 1;
1.35 + return err;
1.36 }
1.37
1.38 /* Import from the message a dataspace, mapping it to an address, updating the
1.39 @@ -520,14 +523,16 @@
1.40 long err;
1.41 int local;
1.42
1.43 - err = _import_dataspace(msg->tag, &msg->bregs, &msg->mregs, item, mem, addr, &local);
1.44 + err = _import_dataspace(msg->tag, &msg->bregs, &msg->mregs, item, msg->import_item, mem, addr, &local);
1.45 if (err)
1.46 return err;
1.47
1.48 if (local)
1.49 return L4_EOK;
1.50
1.51 - return ipc_message_expect_capability(msg, item);
1.52 + err = ipc_message_expect_capability(msg, msg->import_item);
1.53 + msg->import_item += 1;
1.54 + return err;
1.55 }
1.56
1.57 /* Import from the message the capability at the given item position. */
1.58 @@ -535,8 +540,14 @@
1.59 long ipc_message_import_capability(ipc_message_t *msg, int item, l4_cap_idx_t *ref)
1.60 {
1.61 int local;
1.62 + long err;
1.63
1.64 - return _import_capability(msg->tag, &msg->bregs, &msg->mregs, item, ref, &local);
1.65 + err = _import_capability(msg->tag, &msg->bregs, &msg->mregs, item, msg->import_item, ref, &local);
1.66 + if (err)
1.67 + return err;
1.68 +
1.69 + msg->import_item += local ? 0 : 1;
1.70 + return L4_EOK;
1.71 }
1.72
1.73 /* Import from the message a dataspace, mapping it to an address. */
1.74 @@ -544,8 +555,14 @@
1.75 long ipc_message_import_dataspace(ipc_message_t *msg, int item, l4re_ds_t *mem, l4_addr_t *addr)
1.76 {
1.77 int local;
1.78 + long err;
1.79
1.80 - return _import_dataspace(msg->tag, &msg->bregs, &msg->mregs, item, mem, addr, &local);
1.81 + err = _import_dataspace(msg->tag, &msg->bregs, &msg->mregs, item, msg->import_item, mem, addr, &local);
1.82 + if (err)
1.83 + return err;
1.84 +
1.85 + msg->import_item += local ? 0 : 1;
1.86 + return L4_EOK;
1.87 }
1.88
1.89 /* Import from the message the flexpage at the given item position. */