summaryrefslogtreecommitdiff
path: root/src/thread.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/thread.c
parent5719a3db3aa1c151df8de35fdf9aff131582da94 (diff)
parentd645525a0b7a6e2f1113910a7a6c2fefd6cd388f (diff)
Merge pull request #1611 from TanekLiang/add-more-assert
add more assert for object check
Diffstat (limited to 'src/thread.c')
-rw-r--r--src/thread.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c
index 0f0265fc35..9e5c97983b 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -275,6 +275,7 @@ rt_err_t rt_thread_startup(rt_thread_t thread)
/* thread check */
RT_ASSERT(thread != RT_NULL);
RT_ASSERT((thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_INIT);
+ RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
/* set current priority to init priority */
thread->current_priority = thread->init_priority;
@@ -318,6 +319,8 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
/* thread check */
RT_ASSERT(thread != RT_NULL);
+ RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
+ RT_ASSERT(rt_object_is_systemobject((rt_object_t)thread));
if ((thread->stat & RT_THREAD_STAT_MASK) != RT_THREAD_INIT)
{
@@ -416,6 +419,8 @@ rt_err_t rt_thread_delete(rt_thread_t thread)
/* thread check */
RT_ASSERT(thread != RT_NULL);
+ RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
+ RT_ASSERT(rt_object_is_systemobject((rt_object_t)thread) == RT_FALSE);
if ((thread->stat & RT_THREAD_STAT_MASK) != RT_THREAD_INIT)
{
@@ -504,6 +509,7 @@ rt_err_t rt_thread_sleep(rt_tick_t tick)
/* set to current thread */
thread = rt_current_thread;
RT_ASSERT(thread != RT_NULL);
+ RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
/* suspend thread */
rt_thread_suspend(thread);
@@ -572,6 +578,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
/* thread check */
RT_ASSERT(thread != RT_NULL);
+ RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
switch (cmd)
{
@@ -650,6 +657,7 @@ rt_err_t rt_thread_suspend(rt_thread_t thread)
/* thread check */
RT_ASSERT(thread != RT_NULL);
+ RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s\n", thread->name));
@@ -692,6 +700,7 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
/* thread check */
RT_ASSERT(thread != RT_NULL);
+ RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread resume: %s\n", thread->name));
@@ -737,6 +746,7 @@ void rt_thread_timeout(void *parameter)
/* thread check */
RT_ASSERT(thread != RT_NULL);
RT_ASSERT((thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_SUSPEND);
+ RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
/* set error number */
thread->error = -RT_ETIMEOUT;