Skip to content

Commit a3f6584

Browse files
committed
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>
1 parent 0b9fce4 commit a3f6584

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/posix/options/clock_common.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ int z_vrfy___posix_clock_get_base(clockid_t clock_id, struct timespec *ts)
5959

6060
int z_clock_gettime(clockid_t clock_id, struct timespec *ts)
6161
{
62-
struct timespec base;
62+
struct timespec base = {.tv_sec = 0, .tv_nsec = 0};
6363

6464
switch (clock_id) {
6565
case CLOCK_MONOTONIC:
66-
base.tv_sec = 0;
67-
base.tv_nsec = 0;
6866
break;
6967

7068
case CLOCK_REALTIME:

0 commit comments

Comments
 (0)