chore(timer): add assertions for null pointer (#4823)

This commit is contained in:
蒋慧赟 2023-11-18 08:08:54 +00:00 committed by GitHub
parent 2cba406014
commit cd6b4db6e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,6 +183,7 @@ lv_timer_t * lv_timer_create(lv_timer_cb_t timer_xcb, uint32_t period, void * us
void lv_timer_set_cb(lv_timer_t * timer, lv_timer_cb_t timer_cb)
{
LV_ASSERT_NULL(timer);
timer->timer_cb = timer_cb;
}
@ -196,42 +197,50 @@ void lv_timer_delete(lv_timer_t * timer)
void lv_timer_pause(lv_timer_t * timer)
{
LV_ASSERT_NULL(timer);
timer->paused = true;
}
void lv_timer_resume(lv_timer_t * timer)
{
LV_ASSERT_NULL(timer);
timer->paused = false;
lv_timer_handler_resume();
}
void lv_timer_set_period(lv_timer_t * timer, uint32_t period)
{
LV_ASSERT_NULL(timer);
timer->period = period;
}
void lv_timer_ready(lv_timer_t * timer)
{
LV_ASSERT_NULL(timer);
timer->last_run = lv_tick_get() - timer->period - 1;
}
void lv_timer_set_repeat_count(lv_timer_t * timer, int32_t repeat_count)
{
LV_ASSERT_NULL(timer);
timer->repeat_count = repeat_count;
}
void lv_timer_set_auto_delete(lv_timer_t * timer, bool auto_delete)
{
LV_ASSERT_NULL(timer);
timer->auto_delete = auto_delete;
}
void lv_timer_set_user_data(lv_timer_t * timer, void * user_data)
{
LV_ASSERT_NULL(timer);
timer->user_data = user_data;
}
void lv_timer_reset(lv_timer_t * timer)
{
LV_ASSERT_NULL(timer);
timer->last_run = lv_tick_get();
lv_timer_handler_resume();
}