Skip to content

Commit 90be983

Browse files
nordic-krchfabiobaltieri
authored andcommitted
logging: backends: multidomain: Fix compilation warning
Fix compilation warning due to taking member from a packed structure and assigning it to a pointer. Compiler warns that it may be unaligned. However, it is ensured that it will be aligned by operations preceding this assignment. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 2a8b298 commit 90be983

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

subsys/logging/backends/log_multidomain_backend.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ static void process(const struct log_backend *const backend,
3232
return;
3333
}
3434

35-
/* Need to ensure that package is aligned to a pointer size. */
35+
/* Need to ensure that package is aligned to a pointer size even though
36+
* it is in the packed structured.
37+
*/
3638
uint32_t msg_len = Z_LOG_MSG_LEN(fsc_plen, dlen);
3739
uint8_t buf[msg_len + sizeof(void *)] __aligned(sizeof(void *));
3840
size_t msg_offset = offsetof(struct log_multidomain_msg, data);
3941
struct log_multidomain_msg *out_msg =
4042
(struct log_multidomain_msg *)&buf[sizeof(void *) - msg_offset];
41-
struct log_msg *out_log_msg = (struct log_msg *)out_msg->data.log_msg.data;
43+
uintptr_t out_log_msg_ptr = (uintptr_t)out_msg->data.log_msg.data;
44+
struct log_msg *out_log_msg = (struct log_msg *)out_log_msg_ptr;
4245

4346
/* Set ipc message id. */
4447
out_msg->id = Z_LOG_MULTIDOMAIN_ID_MSG;

0 commit comments

Comments
 (0)