From a3f658454ab9db3656fe7604950c1e43b9958a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Wed, 14 May 2025 10:42:27 +0200 Subject: [PATCH] posix: clock: fix maybe-uninitialized warning in z_clock_gettime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiler gets confused and thinks base may be used uninitialized. This shouldn't be possible, but to make the warning go away, initialize it. Signed-off-by: Benjamin Cabé --- lib/posix/options/clock_common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/posix/options/clock_common.c b/lib/posix/options/clock_common.c index 2819f3e3c43..daacd3c7b80 100644 --- a/lib/posix/options/clock_common.c +++ b/lib/posix/options/clock_common.c @@ -59,12 +59,10 @@ int z_vrfy___posix_clock_get_base(clockid_t clock_id, struct timespec *ts) int z_clock_gettime(clockid_t clock_id, struct timespec *ts) { - struct timespec base; + struct timespec base = {.tv_sec = 0, .tv_nsec = 0}; switch (clock_id) { case CLOCK_MONOTONIC: - base.tv_sec = 0; - base.tv_nsec = 0; break; case CLOCK_REALTIME: