Skip to content

Commit 1f99a0c

Browse files
naiyuantiancfriedt
authored andcommitted
tests: threads: fix uninitialized scalar variable
In the file variable val is not initialized, causing the variable stack_ptr, pos, points to uninitialized data. Initialize the variable val according to the code and commits. Fixes #37916 Signed-off-by: Naiyuan Tian <[email protected]>
1 parent 1af1052 commit 1f99a0c

File tree

1 file changed

+2
-1
lines changed
  • tests/kernel/threads/thread_stack/src

1 file changed

+2
-1
lines changed

tests/kernel/threads/thread_stack/src/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void stack_buffer_scenarios(void)
9292
k_thread_stack_t *stack_obj = scenario_data.stack;
9393
size_t obj_size = scenario_data.object_size;
9494
size_t stack_size, unused, carveout, reserved, alignment, adjusted;
95-
uint8_t val;
95+
uint8_t val = 0;
9696
char *stack_start, *stack_ptr, *stack_end, *obj_start, *obj_end;
9797
char *stack_buf;
9898
volatile char *pos;
@@ -161,6 +161,7 @@ void stack_buffer_scenarios(void)
161161
* First test does direct read & write starting at the estimated
162162
* stack pointer up to the highest addresses in the buffer
163163
*/
164+
val = *stack_start;
164165
stack_ptr = &val;
165166
for (pos = stack_ptr; pos < stack_end; pos++) {
166167
/* pos is volatile so this doesn't get optimized out */

0 commit comments

Comments
 (0)