Skip to content

Commit 1d6da40

Browse files
aescolarhenrikbrixandersen
authored andcommitted
lib: os: clock: Fix possibly unitialized variable warning
When building with high optimization level, the compiler thinks duration may be used initialized and warns as much. Let's initialize this variable always to ensure it does not happen and with it pacify the compiler. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent 83165ec commit 1d6da40

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/os/clock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int z_impl_sys_clock_nanosleep(int clock_id, int flags, const struct timespec *r
158158
{
159159
k_timepoint_t end;
160160
k_timeout_t timeout;
161-
struct timespec duration;
161+
struct timespec duration = {0, 0};
162162
const bool update_rmtp = rmtp != NULL;
163163
const bool abstime = (flags & SYS_TIMER_ABSTIME) != 0;
164164

0 commit comments

Comments
 (0)