Browse Source

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>
pull/85311/head
Ryan McClelland 8 months ago committed by Benjamin Cabé
parent
commit
37e4af63a9
  1. 1
      include/zephyr/arch/x86/thread_stack.h
  2. 1
      include/zephyr/arch/xtensa/thread_stack.h
  3. 3
      kernel/thread.c

1
include/zephyr/arch/x86/thread_stack.h

@ -107,7 +107,6 @@ struct z_x86_thread_stack_header { @@ -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

1
include/zephyr/arch/xtensa/thread_stack.h

@ -68,7 +68,6 @@ struct xtensa_thread_stack_header { @@ -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 */

3
kernel/thread.c

@ -400,6 +400,7 @@ static char *setup_thread_stack(struct k_thread *new_thread, @@ -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, @@ -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

Loading…
Cancel
Save