summaryrefslogtreecommitdiff
path: root/src/timer.c
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-07-11 21:38:31 +0800
committerGitHub <[email protected]>2018-07-11 21:38:31 +0800
commit44712ba2cfd113374986f7a63d7c48ec34c4a8da (patch)
tree7b3b9c3ad9954bce86ae2fc80d5edc7498808185 /src/timer.c
parent5719a3db3aa1c151df8de35fdf9aff131582da94 (diff)
parentd645525a0b7a6e2f1113910a7a6c2fefd6cd388f (diff)
Merge pull request #1611 from TanekLiang/add-more-assert
add more assert for object check
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/timer.c b/src/timer.c
index d6cf486931..8354d43a43 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -207,6 +207,8 @@ rt_err_t rt_timer_detach(rt_timer_t timer)
/* timer check */
RT_ASSERT(timer != RT_NULL);
+ RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer);
+ RT_ASSERT(rt_object_is_systemobject(&timer->parent));
/* disable interrupt */
level = rt_hw_interrupt_disable();
@@ -268,6 +270,8 @@ rt_err_t rt_timer_delete(rt_timer_t timer)
/* timer check */
RT_ASSERT(timer != RT_NULL);
+ RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer);
+ RT_ASSERT(rt_object_is_systemobject(&timer->parent) == RT_FALSE);
/* disable interrupt */
level = rt_hw_interrupt_disable();
@@ -302,6 +306,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
/* timer check */
RT_ASSERT(timer != RT_NULL);
+ RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer);
/* stop timer firstly */
level = rt_hw_interrupt_disable();
@@ -422,6 +427,8 @@ rt_err_t rt_timer_stop(rt_timer_t timer)
/* timer check */
RT_ASSERT(timer != RT_NULL);
+ RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer);
+
if (!(timer->parent.flag & RT_TIMER_FLAG_ACTIVATED))
return -RT_ERROR;
@@ -455,6 +462,7 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
{
/* timer check */
RT_ASSERT(timer != RT_NULL);
+ RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer);
switch (cmd)
{