From: richardbarry Date: Thu, 7 Nov 2013 16:45:30 +0000 (+0000) Subject: Add configASSERT()s to ensure counting semaphores are not created with a max count... X-Git-Tag: V7.6.0~17 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=88355587f25bbb984e7d50e206988792f3a25d18;p=freertos Add configASSERT()s to ensure counting semaphores are not created with a max count of zero or an initial count greater than the max count. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2090 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Source/include/queue.h b/FreeRTOS/Source/include/queue.h index b5fac2b7d..421655db4 100644 --- a/FreeRTOS/Source/include/queue.h +++ b/FreeRTOS/Source/include/queue.h @@ -1473,7 +1473,7 @@ signed portBASE_TYPE xQueueCRReceive( xQueueHandle xQueue, void *pvBuffer, portT * these functions directly. */ xQueueHandle xQueueCreateMutex( unsigned char ucQueueType ) PRIVILEGED_FUNCTION; -xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION; +xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxMaxCount, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION; void* xQueueGetMutexHolder( xQueueHandle xSemaphore ) PRIVILEGED_FUNCTION; /* diff --git a/FreeRTOS/Source/queue.c b/FreeRTOS/Source/queue.c index 0622eee13..7eec2160b 100644 --- a/FreeRTOS/Source/queue.c +++ b/FreeRTOS/Source/queue.c @@ -534,11 +534,14 @@ xQueueHandle xReturn = NULL; #if ( configUSE_COUNTING_SEMAPHORES == 1 ) - xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) + xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxMaxCount, unsigned portBASE_TYPE uxInitialCount ) { xQueueHandle xHandle; - xHandle = xQueueGenericCreate( uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); + configASSERT( uxMaxCount != 0 ); + configASSERT( uxInitialCount <= uxMaxCount ); + + xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); if( xHandle != NULL ) {