Skip to content

Commit 3bbc01e

Browse files
lrgirdwolgirdwood
authored andcommitted
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 823b799 commit 3bbc01e

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
@@ -284,10 +284,9 @@ static uint32_t ams_push_slot(struct ams_shared_context __sparse_cache *ctx_shar
284284

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

0 commit comments

Comments
 (0)