]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/queue.c
Linting and MISRA checking
[freertos] / FreeRTOS / Source / queue.c
index 4488169ea8195b69ce58504d380c4c7a1b3c7fab..8968ddf147253af4873db4e32833bfa72d53f6b3 100644 (file)
@@ -88,14 +88,17 @@ 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
 /* 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
@@ -114,7 +117,6 @@ structure member). */
 /* 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
@@ -212,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 ) PRIVILEGED_FUNCTION;\r
+       static portBASE_TYPE prvNotifyQueueSetContainer( const xQUEUE * const pxQueue, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;\r
 #endif\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -245,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
@@ -307,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
@@ -316,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
@@ -398,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
@@ -447,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
@@ -458,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 == ( void * ) 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
@@ -470,11 +470,11 @@ xQueueHandle xReturn = NULL;
                        ( pxMutex->u.uxRecursiveCallCount )--;\r
 \r
                        /* Have we unwound the call count? */\r
-                       if( pxMutex->u.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
@@ -498,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
@@ -508,7 +507,7 @@ xQueueHandle xReturn = NULL;
 \r
                traceTAKE_MUTEX_RECURSIVE( pxMutex );\r
 \r
-               if( pxMutex->pxMutexHolder == ( void * )  xTaskGetCurrentTaskHandle() )\r
+               if( pxMutex->pxMutexHolder == ( void * )  xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as xTaskHandle is a typedef. */\r
                {\r
                        ( pxMutex->u.uxRecursiveCallCount )++;\r
                        xReturn = pdPASS;\r
@@ -541,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
@@ -565,9 +564,8 @@ 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
@@ -661,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
@@ -724,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
@@ -804,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
@@ -825,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
@@ -934,13 +934,28 @@ 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
        queue read, instead we return a flag to say whether a context switch is\r
@@ -1027,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
@@ -1050,7 +1064,7 @@ xQUEUE *pxQueue;
                        the highest priority task wanting to access the queue. */\r
                        if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                        {\r
-                               /* Remember the read position in case the queue is only being \r
+                               /* Remember the read position in case the queue is only being\r
                                peeked. */\r
                                pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
 \r
@@ -1060,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
@@ -1069,7 +1083,7 @@ xQUEUE *pxQueue;
                                                {\r
                                                        /* Record the information required to implement\r
                                                        priority inheritance should it become necessary. */\r
-                                                       pxQueue->pxMutexHolder = ( void * ) xTaskGetCurrentTaskHandle();\r
+                                                       pxQueue->pxMutexHolder = ( void * ) xTaskGetCurrentTaskHandle(); /*lint !e961 Cast is not redundant as xTaskHandle is a typedef. */\r
                                                }\r
                                        }\r
                                        #endif\r
@@ -1124,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
@@ -1179,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
@@ -1199,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
@@ -1238,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
@@ -1249,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
@@ -1261,14 +1348,13 @@ 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
@@ -1329,29 +1415,29 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
        }\r
        else if( xPosition == queueSEND_TO_BACK )\r
        {\r
-               memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) 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->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize );\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 )\r
+               if( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */\r
                {\r
                        pxQueue->u.pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );\r
                }\r
 \r
                if( xPosition == queueOVERWRITE )\r
                {\r
-                       if( pxQueue->uxMessagesWaiting > 0 )\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
+                               /* 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
@@ -1362,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->u.pcReadFrom += pxQueue->uxItemSize;\r
-               if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )\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->u.pcReadFrom = pxQueue->pcHead;\r
                }\r
-               memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) 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
@@ -1481,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
@@ -1501,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
@@ -1511,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
@@ -1550,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
@@ -1558,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
@@ -1629,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
@@ -1704,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
@@ -1739,9 +1819,7 @@ 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
@@ -1821,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
@@ -1830,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
@@ -1885,7 +1961,7 @@ signed portBASE_TYPE xReturn;
                        /* Cannot add a queue/semaphore to more than one queue set. */\r
                        xReturn = pdFAIL;\r
                }\r
-               else if( ( ( xQUEUE * ) xQueueOrSemaphore )->uxMessagesWaiting != 0 )\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
@@ -1912,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
@@ -1940,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
@@ -1951,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
@@ -1964,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
@@ -1973,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