]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/queue.c
Linting and MISRA checking
[freertos] / FreeRTOS / Source / queue.c
index 75bebd12d5013dcbf741af4d1de9dc504bb7fbcc..8968ddf147253af4873db4e32833bfa72d53f6b3 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V7.4.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+    FreeRTOS V7.4.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
 \r
     FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -39,7 +39,7 @@
     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
     FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\r
     details. You should have received a copy of the GNU General Public License\r
-    and the FreeRTOS license exception along with FreeRTOS; if not itcan be\r
+    and the FreeRTOS license exception along with FreeRTOS; if not it can be\r
     viewed here: http://www.freertos.org/a00114.html and also obtained by\r
     writing to Real Time Engineers Ltd., contact details for whom are available\r
     on the FreeRTOS WEB site.\r
     ***************************************************************************\r
 \r
 \r
-    http://www.FreeRTOS.org - Documentation, books, training, latest versions, \r
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
     license and Real Time Engineers Ltd. contact details.\r
 \r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool, and our new\r
     fully thread aware and reentrant UDP/IP stack.\r
 \r
-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High \r
-    Integrity Systems, who sell the code with commercial support, \r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems, who sell the code with commercial support,\r
     indemnification and middleware, under the OpenRTOS brand.\r
-    \r
-    http://www.SafeRTOS.com - High Integrity Systems also provide a safety \r
-    engineered and independently SIL3 certified version for use in safety and \r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
     mission critical applications that require provable dependability.\r
 */\r
 \r
@@ -88,24 +88,35 @@ task.h is included from an application file. */
        #include "croutine.h"\r
 #endif\r
 \r
-#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+/* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
+MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the\r
+header files above, but not in this file, in order to generate the correct\r
+privileged Vs unprivileged linkage and placement. */\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */\r
+\r
 \r
 /* Constants used with the cRxLock and xTxLock structure members. */\r
 #define queueUNLOCKED                                  ( ( signed portBASE_TYPE ) -1 )\r
 #define queueLOCKED_UNMODIFIED                 ( ( signed portBASE_TYPE ) 0 )\r
 \r
-#define queueERRONEOUS_UNBLOCK                 ( -1 )\r
-\r
-/* Effectively make a union out of the xQUEUE structure. */\r
+/* When the xQUEUE structure is used to represent a base queue its pcHead and\r
+pcTail members are used as pointers into the queue storage area.  When the\r
+xQUEUE structure is used to represent a mutex pcHead and pcTail pointers are\r
+not necessary, and the pcHead pointer is set to NULL to indicate that the\r
+pcTail pointer actually points to the mutex holder (if any).  Map alternative\r
+names to the pcHead and pcTail structure members to ensure the readability of\r
+the code is maintained despite this dual use of two structure members.  An\r
+alternative implementation would be to use a union, but use of a union is\r
+against the coding standard (although an exception to the standard has been\r
+permitted where the dual use also significantly changes the type of the\r
+structure member). */\r
 #define pxMutexHolder                                  pcTail\r
 #define uxQueueType                                            pcHead\r
-#define uxRecursiveCallCount                   pcReadFrom\r
 #define queueQUEUE_IS_MUTEX                            NULL\r
 \r
-/* Semaphores do not actually store or copy data, so have an items size of\r
+/* Semaphores do not actually store or copy data, so have an item size of\r
 zero. */\r
 #define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portBASE_TYPE ) 0 )\r
-#define queueDONT_BLOCK                                         ( ( portTickType ) 0U )\r
 #define queueMUTEX_GIVE_BLOCK_TIME              ( ( portTickType ) 0U )\r
 \r
 \r
@@ -119,7 +130,12 @@ typedef struct QueueDefinition
        signed char *pcTail;                                    /*< Points to the byte at the end of the queue storage area.  Once more byte is allocated than necessary to store the queue items, this is used as a marker. */\r
 \r
        signed char *pcWriteTo;                                 /*< Points to the free next place in the storage area. */\r
-       signed char *pcReadFrom;                                /*< Points to the last place that a queued item was read from. */\r
+\r
+       union                                                                   /* Use of a union is an exception to the coding standard to ensure two mutually exclusive structure members don't appear simultaneously (wasting RAM). */\r
+       {\r
+               signed char *pcReadFrom;                        /*< Points to the last place that a queued item was read from when the structure is used as a queue. */\r
+               unsigned portBASE_TYPE uxRecursiveCallCount;/*< Maintains a count of the numebr of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */\r
+       } u;\r
 \r
        xList xTasksWaitingToSend;                              /*< List of tasks that are blocked waiting to post onto this queue.  Stored in priority order. */\r
        xList xTasksWaitingToReceive;                   /*< List of tasks that are blocked waiting to read from this queue.  Stored in priority order. */\r
@@ -163,10 +179,6 @@ typedef struct QueueDefinition
        array position being vacant. */\r
        xQueueRegistryItem xQueueRegistry[ configQUEUE_REGISTRY_SIZE ];\r
 \r
-       /* Removes a queue from the registry by simply setting the pcQueueName\r
-       member to NULL. */\r
-       static void prvQueueUnregisterQueue( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
-\r
 #endif /* configQUEUE_REGISTRY_SIZE */\r
 \r
 /*\r
@@ -202,14 +214,14 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
 /*\r
  * Copies an item out of a queue.\r
  */\r
-static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) PRIVILEGED_FUNCTION;\r
+static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
        /*\r
         * Checks to see if a queue is a member of a queue set, and if so, notifies\r
         * the queue set that the queue contains data.\r
         */\r
-       static portBASE_TYPE prvNotifyQueueSetContainer( xQUEUE *pxQueue, portBASE_TYPE xCopyPosition );\r
+       static portBASE_TYPE prvNotifyQueueSetContainer( const xQUEUE * const pxQueue, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;\r
 #endif\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -235,9 +247,8 @@ static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer )
 \r
 portBASE_TYPE xQueueGenericReset( xQueueHandle xQueue, portBASE_TYPE xNewQueue )\r
 {\r
-xQUEUE *pxQueue;\r
+xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\r
        configASSERT( pxQueue );\r
 \r
        taskENTER_CRITICAL();\r
@@ -245,7 +256,7 @@ xQUEUE *pxQueue;
                pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize );\r
                pxQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;\r
                pxQueue->pcWriteTo = pxQueue->pcHead;\r
-               pxQueue->pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( unsigned portBASE_TYPE ) 1U ) * pxQueue->uxItemSize );\r
+               pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( unsigned portBASE_TYPE ) 1U ) * pxQueue->uxItemSize );\r
                pxQueue->xRxLock = queueUNLOCKED;\r
                pxQueue->xTxLock = queueUNLOCKED;\r
 \r
@@ -297,7 +308,7 @@ xQueueHandle xReturn = NULL;
                {\r
                        /* Create the list of pointers to queue items.  The queue is one byte\r
                        longer than asked for to make wrap checking easier/faster. */\r
-                       xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1;\r
+                       xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
 \r
                        pxNewQueue->pcHead = ( signed char * ) pvPortMalloc( xQueueSizeInBytes );\r
                        if( pxNewQueue->pcHead != NULL )\r
@@ -306,7 +317,7 @@ xQueueHandle xReturn = NULL;
                                queue type is defined. */\r
                                pxNewQueue->uxLength = uxQueueLength;\r
                                pxNewQueue->uxItemSize = uxItemSize;\r
-                               xQueueGenericReset( pxNewQueue, pdTRUE );\r
+                               ( void ) xQueueGenericReset( pxNewQueue, pdTRUE );\r
 \r
                                #if ( configUSE_TRACE_FACILITY == 1 )\r
                                {\r
@@ -358,7 +369,7 @@ xQueueHandle xReturn = NULL;
                        /* Queues used as a mutex no data is actually copied into or out\r
                        of the queue. */\r
                        pxNewQueue->pcWriteTo = NULL;\r
-                       pxNewQueue->pcReadFrom = NULL;\r
+                       pxNewQueue->u.pcReadFrom = NULL;\r
 \r
                        /* Each mutex has a length of 1 (like a binary semaphore) and\r
                        an item size of 0 as nothing is actually copied into or out\r
@@ -388,7 +399,7 @@ xQueueHandle xReturn = NULL;
                        traceCREATE_MUTEX( pxNewQueue );\r
 \r
                        /* Start with the semaphore in the expected state. */\r
-                       xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK );\r
+                       ( void ) xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK );\r
                }\r
                else\r
                {\r
@@ -437,9 +448,8 @@ xQueueHandle xReturn = NULL;
        portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex )\r
        {\r
        portBASE_TYPE xReturn;\r
-       xQUEUE *pxMutex;\r
+       xQUEUE * const pxMutex = ( xQUEUE * ) xMutex;\r
 \r
-               pxMutex = ( xQUEUE * ) xMutex;\r
                configASSERT( pxMutex );\r
 \r
                /* If this is the task that holds the mutex then pxMutexHolder will not\r
@@ -448,7 +458,7 @@ xQueueHandle xReturn = NULL;
                this is the only condition we are interested in it does not matter if\r
                pxMutexHolder is accessed simultaneously by another task.  Therefore no\r
                mutual exclusion is required to test the pxMutexHolder variable. */\r
-               if( pxMutex->pxMutexHolder == xTaskGetCurrentTaskHandle() )\r
+               if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Not a redundant cast as xTaskHandle is a typedef. */\r
                {\r
                        traceGIVE_MUTEX_RECURSIVE( pxMutex );\r
 \r
@@ -457,14 +467,14 @@ xQueueHandle xReturn = NULL;
                        uxRecursiveCallCount is only modified by the mutex holder, and as\r
                        there can only be one, no mutual exclusion is required to modify the\r
                        uxRecursiveCallCount member. */\r
-                       ( pxMutex->uxRecursiveCallCount )--;\r
+                       ( pxMutex->u.uxRecursiveCallCount )--;\r
 \r
                        /* Have we unwound the call count? */\r
-                       if( pxMutex->uxRecursiveCallCount == 0 )\r
+                       if( pxMutex->u.uxRecursiveCallCount == ( unsigned portBASE_TYPE ) 0 )\r
                        {\r
                                /* Return the mutex.  This will automatically unblock any other\r
                                task that might be waiting to access the mutex. */\r
-                               xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );\r
+                               ( void ) xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );\r
                        }\r
 \r
                        xReturn = pdPASS;\r
@@ -488,9 +498,8 @@ xQueueHandle xReturn = NULL;
        portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime )\r
        {\r
        portBASE_TYPE xReturn;\r
-       xQUEUE *pxMutex;\r
+       xQUEUE * const pxMutex = ( xQUEUE * ) xMutex;\r
 \r
-               pxMutex = ( xQUEUE * ) xMutex;\r
                configASSERT( pxMutex );\r
 \r
                /* Comments regarding mutual exclusion as per those within\r
@@ -498,9 +507,9 @@ xQueueHandle xReturn = NULL;
 \r
                traceTAKE_MUTEX_RECURSIVE( pxMutex );\r
 \r
-               if( pxMutex->pxMutexHolder == xTaskGetCurrentTaskHandle() )\r
+               if( pxMutex->pxMutexHolder == ( void * )  xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as xTaskHandle is a typedef. */\r
                {\r
-                       ( pxMutex->uxRecursiveCallCount )++;\r
+                       ( pxMutex->u.uxRecursiveCallCount )++;\r
                        xReturn = pdPASS;\r
                }\r
                else\r
@@ -511,7 +520,7 @@ xQueueHandle xReturn = NULL;
                        we may have blocked to reach here. */\r
                        if( xReturn == pdPASS )\r
                        {\r
-                               ( pxMutex->uxRecursiveCallCount )++;\r
+                               ( pxMutex->u.uxRecursiveCallCount )++;\r
                        }\r
                        else\r
                        {\r
@@ -531,7 +540,7 @@ xQueueHandle xReturn = NULL;
        {\r
        xQueueHandle xHandle;\r
 \r
-               xHandle = xQueueGenericCreate( ( unsigned portBASE_TYPE ) uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r
+               xHandle = xQueueGenericCreate( uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r
 \r
                if( xHandle != NULL )\r
                {\r
@@ -555,11 +564,11 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
 {\r
 signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
 xTimeOutType xTimeOut;\r
-xQUEUE *pxQueue;\r
+xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\r
        configASSERT( pxQueue );\r
        configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+       configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );\r
 \r
        /* This function relaxes the coding standard somewhat to allow return\r
        statements within the function itself.  This is done in the interest\r
@@ -568,9 +577,11 @@ xQUEUE *pxQueue;
        {\r
                taskENTER_CRITICAL();\r
                {\r
-                       /* Is there room on the queue now?  To be running we must be\r
-                       the highest priority task wanting to access the queue. */\r
-                       if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+                       /* Is there room on the queue now?  The running task must be\r
+                       the highest priority task wanting to access the queue.  If\r
+                       the head item in the queue is to be overwritten then it does\r
+                       not matter if the queue is full. */\r
+                       if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r
                        {\r
                                traceQUEUE_SEND( pxQueue );\r
                                prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
@@ -648,6 +659,10 @@ xQUEUE *pxQueue;
                                        vTaskSetTimeOutState( &xTimeOut );\r
                                        xEntryTimeSet = pdTRUE;\r
                                }\r
+                               else\r
+                               {\r
+                                       /* Entry time was already set. */                                       \r
+                               }\r
                        }\r
                }\r
                taskEXIT_CRITICAL();\r
@@ -711,9 +726,8 @@ xQUEUE *pxQueue;
        {\r
        signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
        xTimeOutType xTimeOut;\r
-       xQUEUE *pxQueue;\r
+       xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
-               pxQueue = ( xQUEUE * ) xQueue;\r
                configASSERT( pxQueue );\r
                configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
 \r
@@ -791,9 +805,8 @@ xQUEUE *pxQueue;
        signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
        xTimeOutType xTimeOut;\r
        signed char *pcOriginalReadPosition;\r
-       xQUEUE *pxQueue;\r
+       xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
-               pxQueue = ( xQUEUE * ) xQueue;\r
                configASSERT( pxQueue );\r
                configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
 \r
@@ -804,7 +817,7 @@ xQUEUE *pxQueue;
                                if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                                {\r
                                        /* Remember our read position in case we are just peeking. */\r
-                                       pcOriginalReadPosition = pxQueue->pcReadFrom;\r
+                                       pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
 \r
                                        prvCopyDataFromQueue( pxQueue, pvBuffer );\r
 \r
@@ -812,7 +825,7 @@ xQUEUE *pxQueue;
                                        {\r
                                                traceQUEUE_RECEIVE( pxQueue );\r
 \r
-                                               /* We are actually removing data. */\r
+                                               /* Data is actually being removed (not just peeked). */\r
                                                --( pxQueue->uxMessagesWaiting );\r
 \r
                                                #if ( configUSE_MUTEXES == 1 )\r
@@ -821,7 +834,7 @@ xQUEUE *pxQueue;
                                                        {\r
                                                                /* Record the information required to implement\r
                                                                priority inheritance should it become necessary. */\r
-                                                               pxQueue->pxMutexHolder = xTaskGetCurrentTaskHandle();\r
+                                                               pxQueue->pxMutexHolder = ( void * ) xTaskGetCurrentTaskHandle();\r
                                                        }\r
                                                }\r
                                                #endif\r
@@ -840,7 +853,7 @@ xQUEUE *pxQueue;
 \r
                                                /* We are not removing the data, so reset our read\r
                                                pointer. */\r
-                                               pxQueue->pcReadFrom = pcOriginalReadPosition;\r
+                                               pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
 \r
                                                /* The data is being left in the queue, so see if there are\r
                                                any other tasks waiting for the data. */\r
@@ -921,11 +934,27 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle xQueue, const void *
 {\r
 signed portBASE_TYPE xReturn;\r
 unsigned portBASE_TYPE uxSavedInterruptStatus;\r
-xQUEUE *pxQueue;\r
+xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\r
        configASSERT( pxQueue );\r
        configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+       configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are keep permanently enabled, even\r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum\r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt\r
+       safe API to ensure interrupt entry is as fast and as simple as possible.\r
+       More information (albeit Cortex-M specific) is provided on the following\r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
 \r
        /* Similar to xQueueGenericSend, except we don't block if there is no room\r
        in the queue.  Also we don't directly wake a task that was blocked on a\r
@@ -934,7 +963,7 @@ xQUEUE *pxQueue;
        by this post). */\r
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+               if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r
                {\r
                        traceQUEUE_SEND_FROM_ISR( pxQueue );\r
 \r
@@ -1013,14 +1042,13 @@ xQUEUE *pxQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )\r
+signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )\r
 {\r
 signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
 xTimeOutType xTimeOut;\r
 signed char *pcOriginalReadPosition;\r
-xQUEUE *pxQueue;\r
+xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\r
        configASSERT( pxQueue );\r
        configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
 \r
@@ -1036,8 +1064,9 @@ xQUEUE *pxQueue;
                        the highest priority task wanting to access the queue. */\r
                        if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                        {\r
-                               /* Remember our read position in case we are just peeking. */\r
-                               pcOriginalReadPosition = pxQueue->pcReadFrom;\r
+                               /* Remember the read position in case the queue is only being\r
+                               peeked. */\r
+                               pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
 \r
                                prvCopyDataFromQueue( pxQueue, pvBuffer );\r
 \r
@@ -1045,7 +1074,7 @@ xQUEUE *pxQueue;
                                {\r
                                        traceQUEUE_RECEIVE( pxQueue );\r
 \r
-                                       /* We are actually removing data. */\r
+                                       /* Actually removing data, not just peeking. */\r
                                        --( pxQueue->uxMessagesWaiting );\r
 \r
                                        #if ( configUSE_MUTEXES == 1 )\r
@@ -1054,7 +1083,7 @@ xQUEUE *pxQueue;
                                                {\r
                                                        /* Record the information required to implement\r
                                                        priority inheritance should it become necessary. */\r
-                                                       pxQueue->pxMutexHolder = xTaskGetCurrentTaskHandle();\r
+                                                       pxQueue->pxMutexHolder = ( void * ) xTaskGetCurrentTaskHandle(); /*lint !e961 Cast is not redundant as xTaskHandle is a typedef. */\r
                                                }\r
                                        }\r
                                        #endif\r
@@ -1073,7 +1102,7 @@ xQUEUE *pxQueue;
 \r
                                        /* The data is not being removed, so reset the read\r
                                        pointer. */\r
-                                       pxQueue->pcReadFrom = pcOriginalReadPosition;\r
+                                       pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
 \r
                                        /* The data is being left in the queue, so see if there are\r
                                        any other tasks waiting for the data. */\r
@@ -1109,6 +1138,10 @@ xQUEUE *pxQueue;
                                        vTaskSetTimeOutState( &xTimeOut );\r
                                        xEntryTimeSet = pdTRUE;\r
                                }\r
+                               else\r
+                               {\r
+                                       /* Entry time was already set. */\r
+                               }\r
                        }\r
                }\r
                taskEXIT_CRITICAL();\r
@@ -1164,19 +1197,34 @@ xQUEUE *pxQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken )\r
+signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, const void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken )\r
 {\r
 signed portBASE_TYPE xReturn;\r
 unsigned portBASE_TYPE uxSavedInterruptStatus;\r
-xQUEUE *pxQueue;\r
+xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\r
        configASSERT( pxQueue );\r
        configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
 \r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are keep permanently enabled, even \r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h \r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum \r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt \r
+       safe API to ensure interrupt entry is as fast and as simple as possible.  \r
+       More information (albeit Cortex-M specific) is provided on the following \r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               /* We cannot block from an ISR, so check there is data available. */\r
+               /* Cannot block in an ISR, so check there is data available. */\r
                if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                {\r
                        traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
@@ -1184,9 +1232,10 @@ xQUEUE *pxQueue;
                        prvCopyDataFromQueue( pxQueue, pvBuffer );\r
                        --( pxQueue->uxMessagesWaiting );\r
 \r
-                       /* If the queue is locked we will not modify the event list.  Instead\r
-                       we update the lock count so the task that unlocks the queue will know\r
-                       that an ISR has removed data while the queue was locked. */\r
+                       /* If the queue is locked the event list will not be modified.\r
+                       Instead update the lock count so the task that unlocks the queue\r
+                       will know that an ISR has removed data while the queue was\r
+                       locked. */\r
                        if( pxQueue->xRxLock == queueUNLOCKED )\r
                        {\r
                                if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
@@ -1223,6 +1272,59 @@ xQUEUE *pxQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, const void * const pvBuffer )\r
+{\r
+signed portBASE_TYPE xReturn;\r
+unsigned portBASE_TYPE uxSavedInterruptStatus;\r
+signed char *pcOriginalReadPosition;\r
+xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
+\r
+       configASSERT( pxQueue );\r
+       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are keep permanently enabled, even \r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h \r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum \r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt \r
+       safe API to ensure interrupt entry is as fast and as simple as possible.  \r
+       More information (albeit Cortex-M specific) is provided on the following \r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+       uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               /* Cannot block in an ISR, so check there is data available. */\r
+               if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
+               {\r
+                       traceQUEUE_PEEK_FROM_ISR( pxQueue );\r
+\r
+                       /* Remember the read position so it can be reset as nothing is\r
+                       actually being removed from the queue. */\r
+                       pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
+                       prvCopyDataFromQueue( pxQueue, pvBuffer );\r
+                       pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
+\r
+                       xReturn = pdPASS;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFAIL;\r
+                       traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue );\r
+               }\r
+       }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue )\r
 {\r
 unsigned portBASE_TYPE uxReturn;\r
@@ -1234,7 +1336,7 @@ unsigned portBASE_TYPE uxReturn;
        taskEXIT_CRITICAL();\r
 \r
        return uxReturn;\r
-}\r
+} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */\r
 /*-----------------------------------------------------------*/\r
 \r
 unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle xQueue )\r
@@ -1246,20 +1348,19 @@ unsigned portBASE_TYPE uxReturn;
        uxReturn = ( ( xQUEUE * ) xQueue )->uxMessagesWaiting;\r
 \r
        return uxReturn;\r
-}\r
+} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */\r
 /*-----------------------------------------------------------*/\r
 \r
 void vQueueDelete( xQueueHandle xQueue )\r
 {\r
-xQUEUE *pxQueue;\r
+xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\r
        configASSERT( pxQueue );\r
 \r
        traceQUEUE_DELETE( pxQueue );\r
        #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
        {\r
-               prvQueueUnregisterQueue( pxQueue );\r
+               vQueueUnregisterQueue( pxQueue );\r
        }\r
        #endif\r
        vPortFree( pxQueue->pcHead );\r
@@ -1310,24 +1411,36 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
                                pxQueue->pxMutexHolder = NULL;\r
                        }\r
                }\r
-               #endif\r
+               #endif /* configUSE_MUTEXES */\r
        }\r
        else if( xPosition == queueSEND_TO_BACK )\r
        {\r
-               memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize );\r
+               ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports, plus previous logic ensures a null pointer can only be passed to memcpy() if the copy size is 0. */\r
                pxQueue->pcWriteTo += pxQueue->uxItemSize;\r
-               if( pxQueue->pcWriteTo >= pxQueue->pcTail )\r
+               if( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */\r
                {\r
                        pxQueue->pcWriteTo = pxQueue->pcHead;\r
                }\r
        }\r
        else\r
        {\r
-               memcpy( ( void * ) pxQueue->pcReadFrom, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize );\r
-               pxQueue->pcReadFrom -= pxQueue->uxItemSize;\r
-               if( pxQueue->pcReadFrom < pxQueue->pcHead )\r
+               ( void ) memcpy( ( void * ) pxQueue->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+               pxQueue->u.pcReadFrom -= pxQueue->uxItemSize;\r
+               if( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */\r
                {\r
-                       pxQueue->pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );\r
+                       pxQueue->u.pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );\r
+               }\r
+\r
+               if( xPosition == queueOVERWRITE )\r
+               {\r
+                       if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
+                       {\r
+                               /* An item is not being added but overwritten, so subtract\r
+                               one from the recorded number of items in the queue so when\r
+                               one is added again below the number of recorded items remains\r
+                               correct. */\r
+                               --( pxQueue->uxMessagesWaiting );\r
+                       }\r
                }\r
        }\r
 \r
@@ -1335,16 +1448,16 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer )\r
+static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void * const pvBuffer )\r
 {\r
        if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX )\r
        {\r
-               pxQueue->pcReadFrom += pxQueue->uxItemSize;\r
-               if( pxQueue->pcReadFrom >= pxQueue->pcTail )\r
+               pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+               if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */\r
                {\r
-                       pxQueue->pcReadFrom = pxQueue->pcHead;\r
+                       pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
                }\r
-               memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+               ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports.  Also previous logic ensures a null pointer can only be passed to memcpy() when the count is 0. */\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -1454,7 +1567,7 @@ signed portBASE_TYPE xReturn;
 \r
        taskENTER_CRITICAL();\r
        {\r
-               if( pxQueue->uxMessagesWaiting == 0 )\r
+               if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE )  0 )\r
                {\r
                        xReturn = pdTRUE;\r
                }\r
@@ -1474,7 +1587,7 @@ signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle xQueue )
 signed portBASE_TYPE xReturn;\r
 \r
        configASSERT( xQueue );\r
-       if( ( ( xQUEUE * ) xQueue )->uxMessagesWaiting == 0 )\r
+       if( ( ( xQUEUE * ) xQueue )->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 )\r
        {\r
                xReturn = pdTRUE;\r
        }\r
@@ -1484,7 +1597,7 @@ signed portBASE_TYPE xReturn;
        }\r
 \r
        return xReturn;\r
-}\r
+} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */\r
 /*-----------------------------------------------------------*/\r
 \r
 static signed portBASE_TYPE prvIsQueueFull( const xQUEUE *pxQueue )\r
@@ -1523,7 +1636,7 @@ signed portBASE_TYPE xReturn;
        }\r
 \r
        return xReturn;\r
-}\r
+} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */\r
 /*-----------------------------------------------------------*/\r
 \r
 #if ( configUSE_CO_ROUTINES == 1 )\r
@@ -1531,9 +1644,7 @@ signed portBASE_TYPE xReturn;
        signed portBASE_TYPE xQueueCRSend( xQueueHandle xQueue, const void *pvItemToQueue, portTickType xTicksToWait )\r
        {\r
        signed portBASE_TYPE xReturn;\r
-       xQUEUE *pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\r
+       xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
                /* If the queue is already full we may have to block.  A critical section\r
                is required to prevent an interrupt removing something from the queue\r
@@ -1602,9 +1713,7 @@ signed portBASE_TYPE xReturn;
        signed portBASE_TYPE xQueueCRReceive( xQueueHandle xQueue, void *pvBuffer, portTickType xTicksToWait )\r
        {\r
        signed portBASE_TYPE xReturn;\r
-       xQUEUE *pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\r
+       xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
                /* If the queue is already empty we may have to block.  A critical section\r
                is required to prevent an interrupt adding something to the queue\r
@@ -1637,13 +1746,13 @@ signed portBASE_TYPE xReturn;
                        if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                        {\r
                                /* Data is available from the queue. */\r
-                               pxQueue->pcReadFrom += pxQueue->uxItemSize;\r
-                               if( pxQueue->pcReadFrom >= pxQueue->pcTail )\r
+                               pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+                               if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )\r
                                {\r
-                                       pxQueue->pcReadFrom = pxQueue->pcHead;\r
+                                       pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
                                }\r
                                --( pxQueue->uxMessagesWaiting );\r
-                               memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+                               memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
 \r
                                xReturn = pdPASS;\r
 \r
@@ -1677,9 +1786,7 @@ signed portBASE_TYPE xReturn;
 \r
        signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle xQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken )\r
        {\r
-       xQUEUE *pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\r
+       xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
                /* Cannot block within an ISR so if there is no space on the queue then\r
                exit without doing anything. */\r
@@ -1712,22 +1819,20 @@ signed portBASE_TYPE xReturn;
        signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle xQueue, void *pvBuffer, signed portBASE_TYPE *pxCoRoutineWoken )\r
        {\r
        signed portBASE_TYPE xReturn;\r
-       xQUEUE * pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\r
+       xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
                /* We cannot block from an ISR, so check there is data available. If\r
                not then just leave without doing anything. */\r
                if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                {\r
                        /* Copy the data from the queue. */\r
-                       pxQueue->pcReadFrom += pxQueue->uxItemSize;\r
-                       if( pxQueue->pcReadFrom >= pxQueue->pcTail )\r
+                       pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+                       if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )\r
                        {\r
-                               pxQueue->pcReadFrom = pxQueue->pcHead;\r
+                               pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
                        }\r
                        --( pxQueue->uxMessagesWaiting );\r
-                       memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+                       memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
 \r
                        if( ( *pxCoRoutineWoken ) == pdFALSE )\r
                        {\r
@@ -1778,7 +1883,7 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
 \r
-       static void prvQueueUnregisterQueue( xQueueHandle xQueue )\r
+       void vQueueUnregisterQueue( xQueueHandle xQueue )\r
        {\r
        unsigned portBASE_TYPE ux;\r
 \r
@@ -1794,7 +1899,7 @@ signed portBASE_TYPE xReturn;
                        }\r
                }\r
 \r
-       }\r
+       } /*lint !e818 xQueue could not be pointer to const because it is a typedef. */\r
 \r
 #endif /* configQUEUE_REGISTRY_SIZE */\r
 /*-----------------------------------------------------------*/\r
@@ -1803,9 +1908,7 @@ signed portBASE_TYPE xReturn;
 \r
        void vQueueWaitForMessageRestricted( xQueueHandle xQueue, portTickType xTicksToWait )\r
        {\r
-       xQUEUE *pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\r
+       xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;\r
 \r
                /* This function should not be called by application code hence the\r
                'Restricted' in its name.  It is not part of the public API.  It is\r
@@ -1855,6 +1958,13 @@ signed portBASE_TYPE xReturn;
 \r
                if( ( ( xQUEUE * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL )\r
                {\r
+                       /* Cannot add a queue/semaphore to more than one queue set. */\r
+                       xReturn = pdFAIL;\r
+               }\r
+               else if( ( ( xQUEUE * ) xQueueOrSemaphore )->uxMessagesWaiting != ( unsigned portBASE_TYPE ) 0 )\r
+               {\r
+                       /* Cannot add a queue/semaphore to a queue set if there are already\r
+                       items in the queue/semaphore. */\r
                        xReturn = pdFAIL;\r
                }\r
                else\r
@@ -1878,16 +1988,14 @@ signed portBASE_TYPE xReturn;
        portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )\r
        {\r
        portBASE_TYPE xReturn;\r
-       xQUEUE *pxQueueOrSemaphore;\r
-\r
-               pxQueueOrSemaphore = ( xQUEUE * ) xQueueOrSemaphore;\r
+       xQUEUE * const pxQueueOrSemaphore = ( xQUEUE * ) xQueueOrSemaphore;\r
 \r
                if( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet )\r
                {\r
                        /* The queue was not a member of the set. */\r
                        xReturn = pdFAIL;\r
                }\r
-               else if( pxQueueOrSemaphore->uxMessagesWaiting != 0 )\r
+               else if( pxQueueOrSemaphore->uxMessagesWaiting != ( unsigned portBASE_TYPE ) 0 )\r
                {\r
                        /* It is dangerous to remove a queue from a set when the queue is\r
                        not empty because the queue set will still hold pending events for\r
@@ -1906,7 +2014,7 @@ signed portBASE_TYPE xReturn;
                }\r
 \r
                return xReturn;\r
-       }\r
+       } /*lint !e818 xQueueSet could not be declared as pointing to const as it is a typedef. */\r
 \r
 #endif /* configUSE_QUEUE_SETS */\r
 /*-----------------------------------------------------------*/\r
@@ -1917,7 +2025,7 @@ signed portBASE_TYPE xReturn;
        {\r
        xQueueSetMemberHandle xReturn = NULL;\r
 \r
-               xQueueGenericReceive( ( xQueueHandle ) xQueueSet, &xReturn, xBlockTimeTicks, pdFALSE );\r
+               ( void ) xQueueGenericReceive( ( xQueueHandle ) xQueueSet, &xReturn, xBlockTimeTicks, pdFALSE ); /*lint !e961 Casting from one typedef to another is not redundant. */\r
                return xReturn;\r
        }\r
 \r
@@ -1930,7 +2038,7 @@ signed portBASE_TYPE xReturn;
        {\r
        xQueueSetMemberHandle xReturn = NULL;\r
 \r
-               xQueueReceiveFromISR( ( xQueueHandle ) xQueueSet, &xReturn, NULL );\r
+               ( void ) xQueueReceiveFromISR( ( xQueueHandle ) xQueueSet, &xReturn, NULL ); /*lint !e961 Casting from one typedef to another is not redundant. */\r
                return xReturn;\r
        }\r
 \r
@@ -1939,7 +2047,7 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
 \r
-       static portBASE_TYPE prvNotifyQueueSetContainer( xQUEUE *pxQueue, portBASE_TYPE xCopyPosition )\r
+       static portBASE_TYPE prvNotifyQueueSetContainer( const xQUEUE * const pxQueue, portBASE_TYPE xCopyPosition )\r
        {\r
        xQUEUE *pxQueueSetContainer = pxQueue->pxQueueSetContainer;\r
        portBASE_TYPE xReturn = pdFALSE;\r