Skip to content

Commit 37e4af6

Browse files
XenuIsWatchingkartben
authored andcommitted
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 <[email protected]>
1 parent a0bdafb commit 37e4af6

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

include/zephyr/arch/x86/thread_stack.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ struct z_x86_thread_stack_header {
107107
#define ARCH_KERNEL_STACK_RESERVED CONFIG_MMU_PAGE_SIZE
108108
#define ARCH_KERNEL_STACK_OBJ_ALIGN CONFIG_MMU_PAGE_SIZE
109109
#else
110-
#define ARCH_KERNEL_STACK_RESERVED 0
111110
#define ARCH_KERNEL_STACK_OBJ_ALIGN ARCH_STACK_PTR_ALIGN
112111
#endif
113112

include/zephyr/arch/xtensa/thread_stack.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ struct xtensa_thread_stack_header {
6868
ROUND_UP((size), XTENSA_STACK_SIZE_ALIGN)
6969

7070
/* kernel stack */
71-
#define ARCH_KERNEL_STACK_RESERVED 0
7271
#define ARCH_KERNEL_STACK_OBJ_ALIGN ARCH_STACK_PTR_ALIGN
7372

7473
#endif /* _ASMLANGUAGE */

kernel/thread.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,15 @@ static char *setup_thread_stack(struct k_thread *new_thread,
400400
stack_buf_start = K_KERNEL_STACK_BUFFER(stack);
401401
stack_buf_size = stack_obj_size - K_KERNEL_STACK_RESERVED;
402402

403+
#if defined(ARCH_KERNEL_STACK_RESERVED)
403404
/* Zephyr treats stack overflow as an app bug. But
404405
* this particular overflow can be seen by static
405406
* analysis so needs to be handled somehow.
406407
*/
407408
if (K_KERNEL_STACK_RESERVED > stack_obj_size) {
408409
k_panic();
409410
}
410-
411+
#endif
411412
}
412413

413414
#ifdef CONFIG_THREAD_STACK_MEM_MAPPED

0 commit comments

Comments
 (0)