kernel: thread: fix warning of always false

K_KERNEL_STACK_RESERVED can be 0 which can give a warning with
-Wtype-limits. Only perform the check if ARCH_KERNEL_STACK_RESERVED
is set. Also remove the the unncessary sets in arch.h where it's
manually set to 0, it defaults to 0 anyways.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
This commit is contained in:
Ryan McClelland 2024-11-01 16:05:05 -07:00 committed by Benjamin Cabé
commit 37e4af63a9
3 changed files with 2 additions and 3 deletions

View file

@ -107,7 +107,6 @@ struct z_x86_thread_stack_header {
#define ARCH_KERNEL_STACK_RESERVED CONFIG_MMU_PAGE_SIZE
#define ARCH_KERNEL_STACK_OBJ_ALIGN CONFIG_MMU_PAGE_SIZE
#else
#define ARCH_KERNEL_STACK_RESERVED 0
#define ARCH_KERNEL_STACK_OBJ_ALIGN ARCH_STACK_PTR_ALIGN
#endif

View file

@ -68,7 +68,6 @@ struct xtensa_thread_stack_header {
ROUND_UP((size), XTENSA_STACK_SIZE_ALIGN)
/* kernel stack */
#define ARCH_KERNEL_STACK_RESERVED 0
#define ARCH_KERNEL_STACK_OBJ_ALIGN ARCH_STACK_PTR_ALIGN
#endif /* _ASMLANGUAGE */

View file

@ -400,6 +400,7 @@ static char *setup_thread_stack(struct k_thread *new_thread,
stack_buf_start = K_KERNEL_STACK_BUFFER(stack);
stack_buf_size = stack_obj_size - K_KERNEL_STACK_RESERVED;
#if defined(ARCH_KERNEL_STACK_RESERVED)
/* Zephyr treats stack overflow as an app bug. But
* this particular overflow can be seen by static
* analysis so needs to be handled somehow.
@ -407,7 +408,7 @@ static char *setup_thread_stack(struct k_thread *new_thread,
if (K_KERNEL_STACK_RESERVED > stack_obj_size) {
k_panic();
}
#endif
}
#ifdef CONFIG_THREAD_STACK_MEM_MAPPED