posix: clock: fix maybe-uninitialized warning in z_clock_gettime

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é <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé 2025-05-14 10:42:27 +02:00 committed by Benjamin Cabé
commit a3f658454a

View file

@ -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: