Merge pull request #2593 from jesven/fix_sem_value

修改sem中的value成员变量和赋值参数类型相同
This commit is contained in:
Bernard Xiong 2019-04-24 17:54:28 +08:00 committed by GitHub
commit 14252b4e40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -656,6 +656,7 @@ struct rt_semaphore
struct rt_ipc_object parent; /**< inherit from ipc_object */
rt_uint16_t value; /**< value of semaphore. */
rt_uint16_t reserved; /**< reserved field */
};
typedef struct rt_semaphore *rt_sem_t;
#endif

View File

@ -201,6 +201,7 @@ rt_err_t rt_sem_init(rt_sem_t sem,
rt_uint8_t flag)
{
RT_ASSERT(sem != RT_NULL);
RT_ASSERT(value < 0x10000U);
/* init object */
rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name);
@ -209,7 +210,7 @@ rt_err_t rt_sem_init(rt_sem_t sem,
rt_ipc_object_init(&(sem->parent));
/* set init value */
sem->value = value;
sem->value = (rt_uint16_t)value;
/* set parent */
sem->parent.parent.flag = flag;
@ -261,6 +262,7 @@ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag)
rt_sem_t sem;
RT_DEBUG_NOT_IN_INTERRUPT;
RT_ASSERT(value < 0x10000U);
/* allocate object */
sem = (rt_sem_t)rt_object_allocate(RT_Object_Class_Semaphore, name);