Skip to content

Commit 4d39bb0

Browse files
committed
ams: remove unused message-size macros
AMS_MESSAGE_SIZE() and AMS_SLOT_SIZE() assumed the message payload was stored inline after the header, but ams_message_payload.message is a pointer to a caller-owned buffer (set in ams_helper_prepare_payload) and the slot only carries the fixed-size struct. The last use of AMS_MESSAGE_SIZE() was replaced by sizeof(*msg); AMS_SLOT_SIZE() had no users. Remove both as dead and misleading. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 9d815b4 commit 4d39bb0

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

src/include/sof/lib/ams.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
/* Space allocated for async message content*/
3030
#define AMS_MAX_MSG_SIZE 0x1000
3131

32-
/* Size of slots message, module id and instance id */
33-
#define AMS_SLOT_SIZE(msg) (AMS_MESSAGE_SIZE(msg) + sizeof(uint16_t) * 2)
34-
#define AMS_MESSAGE_SIZE(msg) (sizeof(*msg) - sizeof(char) + (sizeof(char) * (msg->message_length)))
35-
3632
/**
3733
* \brief IXC message payload
3834
*

src/lib/ams.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,9 @@ static uint32_t ams_push_slot(struct ams_shared_context __sparse_cache *ctx_shar
285285

286286
for (uint32_t i = 0; i < ARRAY_SIZE(ctx_shared->slots); ++i) {
287287
if (ctx_shared->slot_uses[i] == 0) {
288-
/* the slot stores the payload struct (read back via
289-
* u.msg); AMS_MESSAGE_SIZE() adds message_length, which
290-
* over-reads past the struct since message is a pointer,
291-
* not inline data
288+
/* the slot only carries the payload struct (read back
289+
* via u.msg); message points to a caller-owned buffer
290+
* rather than inline data, so copy exactly the struct
292291
*/
293292
err = memcpy_s((__sparse_force void *)ctx_shared->slots[i].u.msg_raw,
294293
sizeof(ctx_shared->slots[i].u.msg_raw),

0 commit comments

Comments
 (0)