summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/pthreads/mqueue.c24
-rw-r--r--components/pthreads/pthread.c1
-rw-r--r--components/pthreads/pthread_internal.h7
3 files changed, 10 insertions, 22 deletions
diff --git a/components/pthreads/mqueue.c b/components/pthreads/mqueue.c
index bd31b4450a..f4869a0476 100644
--- a/components/pthreads/mqueue.c
+++ b/components/pthreads/mqueue.c
@@ -55,13 +55,15 @@ static posix_mq_t *posix_mq_find(const char* name)
for (iter = posix_mq_list; iter != RT_NULL; iter = iter->next)
{
- object = (rt_object_t)&(iter->mq);
+ object = (rt_object_t)(iter->mq);
if (strncmp(object->name, name, RT_NAME_MAX) == 0)
{
return iter;
}
}
+
+ return RT_NULL;
}
int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat,
@@ -193,13 +195,6 @@ ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_pri
return -1;
}
- /* permission check */
- if (!(mqdes->flags & O_RDONLY))
- {
- rt_set_errno(EBADF);
- return -1;
- }
-
result = rt_mq_recv(mqdes->mq->mq, msg_ptr, msg_len, RT_WAITING_FOREVER);
if (result == RT_EOK)
return msg_len;
@@ -218,13 +213,6 @@ int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
return -1;
}
- /* permission check */
- if (!(mqdes->flags & O_WRONLY))
- {
- rt_set_errno(EBADF);
- return -1;
- }
-
result = rt_mq_send(mqdes->mq->mq, (void*)msg_ptr, msg_len);
if (result == RT_EOK)
return 0;
@@ -245,12 +233,6 @@ ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
rt_set_errno(EINVAL);
return -1;
}
- /* permission check */
- if (!(mqdes->flags & O_RDONLY))
- {
- rt_set_errno(EBADF);
- return -1;
- }
tick = libc_time_to_tick(abs_timeout);
diff --git a/components/pthreads/pthread.c b/components/pthreads/pthread.c
index fc312dfd11..c4743c0a91 100644
--- a/components/pthreads/pthread.c
+++ b/components/pthreads/pthread.c
@@ -65,6 +65,7 @@ int pthread_create (pthread_t *tid, const pthread_attr_t *attr,
ptd->canceled = 0;
ptd->cancelstate = PTHREAD_CANCEL_DISABLE;
ptd->canceltype = PTHREAD_CANCEL_DEFERRED;
+ ptd->magic = PTHREAD_MAGIC;
if (attr != RT_NULL) ptd->attr = *attr;
else
diff --git a/components/pthreads/pthread_internal.h b/components/pthreads/pthread_internal.h
index 5d00d15091..d9550fe50f 100644
--- a/components/pthreads/pthread_internal.h
+++ b/components/pthreads/pthread_internal.h
@@ -48,9 +48,14 @@ typedef struct _pthread_data _pthread_data_t;
rt_inline _pthread_data_t* _pthread_get_data(pthread_t thread)
{
+ _pthread_data_t* ptd;
RT_ASSERT(thread != RT_NULL);
- return (_pthread_data_t*)thread->user_data;
+ ptd = (_pthread_data_t*)thread->user_data;
+ RT_ASSERT(ptd != RT_NULL);
+ RT_ASSERT(ptd->magic == PTHREAD_MAGIC);
+
+ return ptd;
}
extern int libc_time_to_tick(const struct timespec *time);