xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2062926746
########## sched/semaphore/sem_waitirq.c: ########## @@ -72,30 +72,54 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) { FAR struct tcb_s *rtcb = this_task(); FAR sem_t *sem = wtcb->waitobj; + const bool mutex = NXSEM_IS_MUTEX(sem); /* It is possible that an interrupt/context switch beat us to the punch * and already changed the task's state. */ - DEBUGASSERT(sem != NULL && atomic_read(NXSEM_COUNT(sem)) < 0); + DEBUGASSERT(sem != NULL && + (mutex || atomic_read(NXSEM_COUNT(sem)) < 0) && + (!mutex || Review Comment: the follow two assert equals: ``` DEBUGASSERT(sem != NULL && (mutex || atomic_read(NXSEM_COUNT(sem)) < 0) && (!mutex || (atomic_read(NXSEM_MHOLDER(sem)) & NXSEM_MBLOCKS_BIT))); ``` ``` DEBUGASSERT(sem != NULL && (!mutex && atomic_read(NXSEM_COUNT(sem)) < 0) || (mutex && (atomic_read(NXSEM_MHOLDER(sem)) & NXSEM_MBLOCKS_BIT))); ``` but, the second one use the positive logic. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org