From 22b45dd6404dc6d0e355b84253009409b64f8cc5 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Sun, 19 May 2013 10:11:10 +0000 Subject: [PATCH] Ensure a queue or semaphore that is not empty cannot be added to a queue set. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1900 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- FreeRTOS/Source/queue.c | 19 +++++++++++++------ FreeRTOS/Source/tasks.c | 6 +++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/FreeRTOS/Source/queue.c b/FreeRTOS/Source/queue.c index 560049e89..bdb25271f 100644 --- a/FreeRTOS/Source/queue.c +++ b/FreeRTOS/Source/queue.c @@ -56,19 +56,19 @@ *************************************************************************** - http://www.FreeRTOS.org - Documentation, books, training, latest versions, + http://www.FreeRTOS.org - Documentation, books, training, latest versions, license and Real Time Engineers Ltd. contact details. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool, and our new fully thread aware and reentrant UDP/IP stack. - http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems, who sell the code with commercial support, + http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High + Integrity Systems, who sell the code with commercial support, indemnification and middleware, under the OpenRTOS brand. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and mission critical applications that require provable dependability. */ @@ -1855,6 +1855,13 @@ signed portBASE_TYPE xReturn; if( ( ( xQUEUE * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL ) { + /* Cannot add a queue/semaphore to more than one queue set. */ + xReturn = pdFAIL; + } + else if( ( ( xQUEUE * ) xQueueOrSemaphore )->uxMessagesWaiting != 0 ) + { + /* Cannot add a queue/semaphore to a queue set if there are already + items in the queue/semaphore. */ xReturn = pdFAIL; } else diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c index f892f7caf..c72239cbc 100644 --- a/FreeRTOS/Source/tasks.c +++ b/FreeRTOS/Source/tasks.c @@ -2489,7 +2489,7 @@ tskTCB *pxNewTCB; if( pxNextTCB->ulRunTimeCounter == 0UL ) { /* The task has used no CPU time at all. */ - sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName ); + sprintf( ( char * ) &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName ); } else { @@ -2508,7 +2508,7 @@ tskTCB *pxNewTCB; { /* sizeof( int ) == sizeof( long ) so a smaller printf() library can be used. */ - sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); + sprintf( ( char * ) &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); } #endif } @@ -2524,7 +2524,7 @@ tskTCB *pxNewTCB; { /* sizeof( int ) == sizeof( long ) so a smaller printf() library can be used. */ - sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter ); + sprintf( ( char * ) &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter ); } #endif } -- 2.39.5