Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 157f9a9

Browse files
committed
rp2/machine_rtc: Check return value from rtc_set_alarm.
The rtc_set_datetime() from pico-sdk will validate the values in the datetime_t structure and refuse to set the time if they aren't valid. It makes sense to raise an exception if this happens instead of failing silently which might be confusing (as an example, see: #6928 (comment) ).
1 parent 66115a3 commit 157f9a9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/mbedtls

ports/rp2/machine_rtc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ STATIC mp_obj_t machine_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
100100
.sec = mp_obj_get_int(items[6]),
101101
};
102102

103-
rtc_set_datetime(&t);
103+
if (!rtc_set_datetime(&t)) {
104+
mp_raise_OSError(MP_EINVAL);
105+
}
104106

105107
}
106108
return mp_const_none;

0 commit comments

Comments
 (0)