Skip to content

Commit c8e5789

Browse files
brandon-exactSeppoTakalo
authored andcommitted
[nrf fromtree] net: lib: lwm2m: lwm2m_rw_senml_cbor: only assign time on get_s64() success
Currently GCC complains that temp64 may be used uninitialized in this function. Adds a check to ensure time is valid before assignining and fixes GCC warning. Signed-off-by: Brandon Allen <[email protected]> (cherry picked from commit bb24c83)
1 parent c88598a commit c8e5789

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/net/lib/lwm2m/lwm2m_rw_senml_cbor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,9 @@ static int get_time(struct lwm2m_input_context *in, time_t *value)
601601
int ret;
602602

603603
ret = get_s64(in, &temp64);
604-
*value = (time_t)temp64;
604+
if (ret == 0) {
605+
*value = (time_t)temp64;
606+
}
605607

606608
return ret;
607609
}

0 commit comments

Comments
 (0)