From 7e9c0525ca0bc1829390d6d77c99c0af599d3bab Mon Sep 17 00:00:00 2001 From: Stephanos Ioannidis Date: Fri, 29 Jul 2022 20:12:19 +0900 Subject: [PATCH] tests: kernel: sleep: Fix uninitialised variable warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/kernel/sleep/src/usleep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/kernel/sleep/src/usleep.c b/tests/kernel/sleep/src/usleep.c index 18e8f35b115dbd..5060bd529731ba 100644 --- a/tests/kernel/sleep/src/usleep.c +++ b/tests/kernel/sleep/src/usleep.c @@ -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;