mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-08 07:07:47 -04:00
Linting and MISRA checking
This commit is contained in:
parent
e83b93f5fc
commit
7d1292ced2
11 changed files with 251 additions and 210 deletions
|
@ -88,14 +88,17 @@ task.h is included from an application file. */
|
|||
#include "croutine.h"
|
||||
#endif
|
||||
|
||||
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
|
||||
/* Lint e961 and e750 are suppressed as a MISRA exception justified because the
|
||||
MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
|
||||
header files above, but not in this file, in order to generate the correct
|
||||
privileged Vs unprivileged linkage and placement. */
|
||||
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
|
||||
|
||||
|
||||
/* Constants used with the cRxLock and xTxLock structure members. */
|
||||
#define queueUNLOCKED ( ( signed portBASE_TYPE ) -1 )
|
||||
#define queueLOCKED_UNMODIFIED ( ( signed portBASE_TYPE ) 0 )
|
||||
|
||||
#define queueERRONEOUS_UNBLOCK ( -1 )
|
||||
|
||||
/* When the xQUEUE structure is used to represent a base queue its pcHead and
|
||||
pcTail members are used as pointers into the queue storage area. When the
|
||||
xQUEUE structure is used to represent a mutex pcHead and pcTail pointers are
|
||||
|
@ -114,7 +117,6 @@ structure member). */
|
|||
/* Semaphores do not actually store or copy data, so have an item size of
|
||||
zero. */
|
||||
#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portBASE_TYPE ) 0 )
|
||||
#define queueDONT_BLOCK ( ( portTickType ) 0U )
|
||||
#define queueMUTEX_GIVE_BLOCK_TIME ( ( portTickType ) 0U )
|
||||
|
||||
|
||||
|
@ -212,14 +214,14 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
|
|||
/*
|
||||
* Copies an item out of a queue.
|
||||
*/
|
||||
static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) PRIVILEGED_FUNCTION;
|
||||
static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void * const pvBuffer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#if ( configUSE_QUEUE_SETS == 1 )
|
||||
/*
|
||||
* Checks to see if a queue is a member of a queue set, and if so, notifies
|
||||
* the queue set that the queue contains data.
|
||||
*/
|
||||
static portBASE_TYPE prvNotifyQueueSetContainer( xQUEUE *pxQueue, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;
|
||||
static portBASE_TYPE prvNotifyQueueSetContainer( const xQUEUE * const pxQueue, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -306,7 +308,7 @@ xQueueHandle xReturn = NULL;
|
|||
{
|
||||
/* Create the list of pointers to queue items. The queue is one byte
|
||||
longer than asked for to make wrap checking easier/faster. */
|
||||
xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1;
|
||||
xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
|
||||
|
||||
pxNewQueue->pcHead = ( signed char * ) pvPortMalloc( xQueueSizeInBytes );
|
||||
if( pxNewQueue->pcHead != NULL )
|
||||
|
@ -315,7 +317,7 @@ xQueueHandle xReturn = NULL;
|
|||
queue type is defined. */
|
||||
pxNewQueue->uxLength = uxQueueLength;
|
||||
pxNewQueue->uxItemSize = uxItemSize;
|
||||
xQueueGenericReset( pxNewQueue, pdTRUE );
|
||||
( void ) xQueueGenericReset( pxNewQueue, pdTRUE );
|
||||
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
{
|
||||
|
@ -397,7 +399,7 @@ xQueueHandle xReturn = NULL;
|
|||
traceCREATE_MUTEX( pxNewQueue );
|
||||
|
||||
/* Start with the semaphore in the expected state. */
|
||||
xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK );
|
||||
( void ) xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -456,7 +458,7 @@ xQueueHandle xReturn = NULL;
|
|||
this is the only condition we are interested in it does not matter if
|
||||
pxMutexHolder is accessed simultaneously by another task. Therefore no
|
||||
mutual exclusion is required to test the pxMutexHolder variable. */
|
||||
if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() )
|
||||
if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Not a redundant cast as xTaskHandle is a typedef. */
|
||||
{
|
||||
traceGIVE_MUTEX_RECURSIVE( pxMutex );
|
||||
|
||||
|
@ -468,11 +470,11 @@ xQueueHandle xReturn = NULL;
|
|||
( pxMutex->u.uxRecursiveCallCount )--;
|
||||
|
||||
/* Have we unwound the call count? */
|
||||
if( pxMutex->u.uxRecursiveCallCount == 0 )
|
||||
if( pxMutex->u.uxRecursiveCallCount == ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
/* Return the mutex. This will automatically unblock any other
|
||||
task that might be waiting to access the mutex. */
|
||||
xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );
|
||||
( void ) xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );
|
||||
}
|
||||
|
||||
xReturn = pdPASS;
|
||||
|
@ -505,7 +507,7 @@ xQueueHandle xReturn = NULL;
|
|||
|
||||
traceTAKE_MUTEX_RECURSIVE( pxMutex );
|
||||
|
||||
if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() )
|
||||
if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as xTaskHandle is a typedef. */
|
||||
{
|
||||
( pxMutex->u.uxRecursiveCallCount )++;
|
||||
xReturn = pdPASS;
|
||||
|
@ -538,7 +540,7 @@ xQueueHandle xReturn = NULL;
|
|||
{
|
||||
xQueueHandle xHandle;
|
||||
|
||||
xHandle = xQueueGenericCreate( ( unsigned portBASE_TYPE ) uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
|
||||
xHandle = xQueueGenericCreate( uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
|
||||
|
||||
if( xHandle != NULL )
|
||||
{
|
||||
|
@ -657,6 +659,10 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
|
|||
vTaskSetTimeOutState( &xTimeOut );
|
||||
xEntryTimeSet = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Entry time was already set. */
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
@ -1036,7 +1042,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )
|
||||
signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )
|
||||
{
|
||||
signed portBASE_TYPE xEntryTimeSet = pdFALSE;
|
||||
xTimeOutType xTimeOut;
|
||||
|
@ -1077,7 +1083,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
|
|||
{
|
||||
/* Record the information required to implement
|
||||
priority inheritance should it become necessary. */
|
||||
pxQueue->pxMutexHolder = ( void * ) xTaskGetCurrentTaskHandle();
|
||||
pxQueue->pxMutexHolder = ( void * ) xTaskGetCurrentTaskHandle(); /*lint !e961 Cast is not redundant as xTaskHandle is a typedef. */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1132,6 +1138,10 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
|
|||
vTaskSetTimeOutState( &xTimeOut );
|
||||
xEntryTimeSet = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Entry time was already set. */
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
@ -1187,7 +1197,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, const void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
signed portBASE_TYPE xReturn;
|
||||
unsigned portBASE_TYPE uxSavedInterruptStatus;
|
||||
|
@ -1262,7 +1272,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, void * const pvBuffer )
|
||||
signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, const void * const pvBuffer )
|
||||
{
|
||||
signed portBASE_TYPE xReturn;
|
||||
unsigned portBASE_TYPE uxSavedInterruptStatus;
|
||||
|
@ -1326,7 +1336,7 @@ unsigned portBASE_TYPE uxReturn;
|
|||
taskEXIT_CRITICAL();
|
||||
|
||||
return uxReturn;
|
||||
}
|
||||
} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle xQueue )
|
||||
|
@ -1338,7 +1348,7 @@ unsigned portBASE_TYPE uxReturn;
|
|||
uxReturn = ( ( xQUEUE * ) xQueue )->uxMessagesWaiting;
|
||||
|
||||
return uxReturn;
|
||||
}
|
||||
} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vQueueDelete( xQueueHandle xQueue )
|
||||
|
@ -1405,25 +1415,25 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
|
|||
}
|
||||
else if( xPosition == queueSEND_TO_BACK )
|
||||
{
|
||||
memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize );
|
||||
( 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. */
|
||||
pxQueue->pcWriteTo += pxQueue->uxItemSize;
|
||||
if( pxQueue->pcWriteTo >= pxQueue->pcTail )
|
||||
if( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */
|
||||
{
|
||||
pxQueue->pcWriteTo = pxQueue->pcHead;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( ( void * ) pxQueue->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize );
|
||||
( void ) memcpy( ( void * ) pxQueue->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
|
||||
pxQueue->u.pcReadFrom -= pxQueue->uxItemSize;
|
||||
if( pxQueue->u.pcReadFrom < pxQueue->pcHead )
|
||||
if( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */
|
||||
{
|
||||
pxQueue->u.pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );
|
||||
}
|
||||
|
||||
if( xPosition == queueOVERWRITE )
|
||||
{
|
||||
if( pxQueue->uxMessagesWaiting > 0 )
|
||||
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
/* An item is not being added but overwritten, so subtract
|
||||
one from the recorded number of items in the queue so when
|
||||
|
@ -1438,16 +1448,16 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer )
|
||||
static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void * const pvBuffer )
|
||||
{
|
||||
if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX )
|
||||
{
|
||||
pxQueue->u.pcReadFrom += pxQueue->uxItemSize;
|
||||
if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )
|
||||
if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */
|
||||
{
|
||||
pxQueue->u.pcReadFrom = pxQueue->pcHead;
|
||||
}
|
||||
memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize );
|
||||
( 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. */
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -1557,7 +1567,7 @@ signed portBASE_TYPE xReturn;
|
|||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if( pxQueue->uxMessagesWaiting == 0 )
|
||||
if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
|
@ -1577,7 +1587,7 @@ signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle xQueue )
|
|||
signed portBASE_TYPE xReturn;
|
||||
|
||||
configASSERT( xQueue );
|
||||
if( ( ( xQUEUE * ) xQueue )->uxMessagesWaiting == 0 )
|
||||
if( ( ( xQUEUE * ) xQueue )->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
|
@ -1587,7 +1597,7 @@ signed portBASE_TYPE xReturn;
|
|||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static signed portBASE_TYPE prvIsQueueFull( const xQUEUE *pxQueue )
|
||||
|
@ -1626,7 +1636,7 @@ signed portBASE_TYPE xReturn;
|
|||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configUSE_CO_ROUTINES == 1 )
|
||||
|
@ -1889,7 +1899,7 @@ signed portBASE_TYPE xReturn;
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */
|
||||
|
||||
#endif /* configQUEUE_REGISTRY_SIZE */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -1951,7 +1961,7 @@ signed portBASE_TYPE xReturn;
|
|||
/* Cannot add a queue/semaphore to more than one queue set. */
|
||||
xReturn = pdFAIL;
|
||||
}
|
||||
else if( ( ( xQUEUE * ) xQueueOrSemaphore )->uxMessagesWaiting != 0 )
|
||||
else if( ( ( xQUEUE * ) xQueueOrSemaphore )->uxMessagesWaiting != ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
/* Cannot add a queue/semaphore to a queue set if there are already
|
||||
items in the queue/semaphore. */
|
||||
|
@ -1985,7 +1995,7 @@ signed portBASE_TYPE xReturn;
|
|||
/* The queue was not a member of the set. */
|
||||
xReturn = pdFAIL;
|
||||
}
|
||||
else if( pxQueueOrSemaphore->uxMessagesWaiting != 0 )
|
||||
else if( pxQueueOrSemaphore->uxMessagesWaiting != ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
/* It is dangerous to remove a queue from a set when the queue is
|
||||
not empty because the queue set will still hold pending events for
|
||||
|
@ -2004,7 +2014,7 @@ signed portBASE_TYPE xReturn;
|
|||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
} /*lint !e818 xQueueSet could not be declared as pointing to const as it is a typedef. */
|
||||
|
||||
#endif /* configUSE_QUEUE_SETS */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -2015,7 +2025,7 @@ signed portBASE_TYPE xReturn;
|
|||
{
|
||||
xQueueSetMemberHandle xReturn = NULL;
|
||||
|
||||
xQueueGenericReceive( ( xQueueHandle ) xQueueSet, &xReturn, xBlockTimeTicks, pdFALSE );
|
||||
( void ) xQueueGenericReceive( ( xQueueHandle ) xQueueSet, &xReturn, xBlockTimeTicks, pdFALSE ); /*lint !e961 Casting from one typedef to another is not redundant. */
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
|
@ -2028,7 +2038,7 @@ signed portBASE_TYPE xReturn;
|
|||
{
|
||||
xQueueSetMemberHandle xReturn = NULL;
|
||||
|
||||
xQueueReceiveFromISR( ( xQueueHandle ) xQueueSet, &xReturn, NULL );
|
||||
( void ) xQueueReceiveFromISR( ( xQueueHandle ) xQueueSet, &xReturn, NULL ); /*lint !e961 Casting from one typedef to another is not redundant. */
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
|
@ -2037,7 +2047,7 @@ signed portBASE_TYPE xReturn;
|
|||
|
||||
#if ( configUSE_QUEUE_SETS == 1 )
|
||||
|
||||
static portBASE_TYPE prvNotifyQueueSetContainer( xQUEUE *pxQueue, portBASE_TYPE xCopyPosition )
|
||||
static portBASE_TYPE prvNotifyQueueSetContainer( const xQUEUE * const pxQueue, portBASE_TYPE xCopyPosition )
|
||||
{
|
||||
xQUEUE *pxQueueSetContainer = pxQueue->pxQueueSetContainer;
|
||||
portBASE_TYPE xReturn = pdFALSE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue