]> git.sur5r.net Git - freertos/commitdiff
Add configASSERT()s to ensure counting semaphores are not created with a max count...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 7 Nov 2013 16:45:30 +0000 (16:45 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 7 Nov 2013 16:45:30 +0000 (16:45 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2090 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/include/queue.h
FreeRTOS/Source/queue.c

index b5fac2b7d76b524d3314cdbbe2ce69a8d41e1cda..421655db465eea70c62d4dcec8219c9fc867bd93 100644 (file)
@@ -1473,7 +1473,7 @@ signed portBASE_TYPE xQueueCRReceive( xQueueHandle xQueue, void *pvBuffer, portT
  * these functions directly.\r
  */\r
 xQueueHandle xQueueCreateMutex( unsigned char ucQueueType ) PRIVILEGED_FUNCTION;\r
-xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION;\r
+xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxMaxCount, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION;\r
 void* xQueueGetMutexHolder( xQueueHandle xSemaphore ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
index 0622eee135fa335d02e24c057cce0d59ff76a350..7eec2160b4e8342e4d45ce8f20237866422de10c 100644 (file)
@@ -534,11 +534,14 @@ xQueueHandle xReturn = NULL;
 \r
 #if ( configUSE_COUNTING_SEMAPHORES == 1 )\r
 \r
-       xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount )\r
+       xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxMaxCount, unsigned portBASE_TYPE uxInitialCount )\r
        {\r
        xQueueHandle xHandle;\r
 \r
-               xHandle = xQueueGenericCreate( uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r
+               configASSERT( uxMaxCount != 0 );\r
+               configASSERT( uxInitialCount <= uxMaxCount );\r
+\r
+               xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r
 \r
                if( xHandle != NULL )\r
                {\r