Skip to content

Commit

Permalink
tests: kernel: sleep: Fix uninitialised variable warning
Browse files Browse the repository at this point in the history
This commit sets an initial value of 0 for the `elapsed_ms` variable,
which may be used uninitialised when the while loop below does not
execute.

This fixes the "‘elapsed_ms’ may be used uninitialized" warning
generated by the GCC 12.

Signed-off-by: Stephanos Ioannidis <[email protected]>
  • Loading branch information
stephanosio committed Jul 29, 2022
1 parent 33cbd84 commit 73dccf6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/kernel/sleep/src/usleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
ZTEST_USER(sleep, test_usleep)
{
int retries = 0;
int64_t elapsed_ms;
int64_t elapsed_ms = 0;

while (retries < RETRIES) {
int64_t start_ms;
Expand Down

0 comments on commit 73dccf6

Please sign in to comment.