tests: kernel: Fix address-of-packed-mem warning
The warning below appears once -Waddress-of-packed-mem is enabled:
/__w/zephyr/zephyr/tests/kernel/mem_protect/userspace/src/main.c: In
function 'test_main':
/__w/zephyr/zephyr/tests/kernel/mem_protect/userspace/src/main.c:1024:17:
error: converting a packed 'k_thread_stack_t' {aka 'struct
z_thread_stack_element'} pointer (alignment 1) to a 'struct
z_x86_thread_stack_header' pointer (alignment 4096) may result in an
unaligned pointer value [-Werror=address-of-packed-member]
1024 | hdr = ((struct z_x86_thread_stack_header *)ztest_thread_stack);
To avoid the warning, use an intermediate void * variable.
More info in #16587.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
710e03b990
commit
cfbaac6733
@ -1012,16 +1012,18 @@ void test_main(void)
|
||||
|
||||
#if defined(CONFIG_ARM64)
|
||||
struct z_arm64_thread_stack_header *hdr;
|
||||
void *vhdr = ((struct z_arm64_thread_stack_header *)ztest_thread_stack);
|
||||
|
||||
hdr = ((struct z_arm64_thread_stack_header *)ztest_thread_stack);
|
||||
hdr = vhdr;
|
||||
priv_stack_ptr = (((char *)&hdr->privilege_stack) +
|
||||
(sizeof(hdr->privilege_stack) - 1));
|
||||
#elif defined(CONFIG_ARM)
|
||||
priv_stack_ptr = (char *)z_priv_stack_find(ztest_thread_stack);
|
||||
#elif defined(CONFIG_X86)
|
||||
struct z_x86_thread_stack_header *hdr;
|
||||
void *vhdr = ((struct z_x86_thread_stack_header *)ztest_thread_stack);
|
||||
|
||||
hdr = ((struct z_x86_thread_stack_header *)ztest_thread_stack);
|
||||
hdr = vhdr;
|
||||
priv_stack_ptr = (((char *)&hdr->privilege_stack) +
|
||||
(sizeof(hdr->privilege_stack) - 1));
|
||||
#elif defined(CONFIG_RISCV)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user