Assert uxCountValue > 0 in xQueueCreateCountingSemaphore

Posted by beginend1 on November 7, 2013

It can be usefull to add some checking in xQueueCreateCountingSemaphore() against uxCountValue == 0. If you make a mistake and gives 0 when creating counting semaphore as max value the xQUEUE::uxMessagesWaiting will underflow when you use xSemaphoreTakeXXX() There is long way to truck this kind of bugs :(


Assert uxCountValue > 0 in xQueueCreateCountingSemaphore

Posted by richardbarry on November 7, 2013

The following two lines have been added on entry to the function:

configASSERT( uxMaxCount != 0 ); configASSERT( uxInitialCount <= uxMaxCount );

Regards.