diff --git a/compat/posix/src/mqueue.c b/compat/posix/src/mqueue.c index 85a924d7..9f1f0318 100644 --- a/compat/posix/src/mqueue.c +++ b/compat/posix/src/mqueue.c @@ -739,11 +739,8 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms (VOID)pthread_mutex_lock(&g_mqueueMutex); privateMqPersonal = MqGetPrivDataBuff(personal); - if (privateMqPersonal == NULL) { - goto ERROUT_UNLOCK; - } - OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF); + OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF); mqueueCB = privateMqPersonal->mq_posixdes; OS_MQ_GOTO_ERROUT_UNLOCK_IF(msgLen > (size_t)(mqueueCB->mqcb->queueSize - sizeof(UINT32)), EMSGSIZE); @@ -786,10 +783,7 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int * (VOID)pthread_mutex_lock(&g_mqueueMutex); privateMqPersonal = MqGetPrivDataBuff(personal); - if (privateMqPersonal == NULL) { - goto ERROUT_UNLOCK; - } - if (privateMqPersonal->mq_status != MQ_USE_MAGIC) { + if (privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC) { errno = EBADF; goto ERROUT_UNLOCK; } diff --git a/kernel/base/vm/shm.c b/kernel/base/vm/shm.c index 9de9d54e..aadca5f1 100644 --- a/kernel/base/vm/shm.c +++ b/kernel/base/vm/shm.c @@ -435,11 +435,6 @@ INT32 ShmGet(key_t key, size_t size, INT32 shmflg) INT32 shmid; SYSV_SHM_LOCK(); - if (!((UINT32)shmflg & IPC_CREAT) && - ((UINT32)shmflg & IPC_EXCL)) { - ret = -EINVAL; - goto ERROR; - } if (key == IPC_PRIVATE) { ret = ShmAllocSeg(key, size, shmflg); @@ -454,6 +449,11 @@ INT32 ShmGet(key_t key, size_t size, INT32 shmflg) } } else { shmid = ret; + if (((UINT32)shmflg & IPC_CREAT) && + ((UINT32)shmflg & IPC_EXCL)) { + ret = -EEXIST; + goto ERROR; + } ret = ShmPermCheck(ShmFindSeg(shmid), (UINT32)shmflg & ACCESSPERMS); if (ret != 0) { ret = -ret;