Fix misra violations in queue.c by introducing a union that allows the correct data types to be used in place of void *, then tidy up where the union is used.

This commit is contained in:
Richard Barry 2018-06-11 18:51:53 +00:00
parent 4a8c4c9eaf
commit 4fbcdbf13b
6 changed files with 78 additions and 70 deletions

View File

@ -93,7 +93,7 @@ QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType );
QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ); QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue );
QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ); QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount );
QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ); QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue );
void* MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ); TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore );
BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ); BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait );
BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ); BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex );
void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ); void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName );

View File

@ -1415,8 +1415,8 @@ QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t
QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION;
BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
void* xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
/* /*
* For internal use only. Use xSemaphoreTakeMutexRecursive() or * For internal use only. Use xSemaphoreTakeMutexRecursive() or

View File

@ -2321,7 +2321,7 @@ eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
* For internal use only. Increment the mutex held count when a mutex is * For internal use only. Increment the mutex held count when a mutex is
* taken and return the handle of the task that has taken the mutex. * taken and return the handle of the task that has taken the mutex.
*/ */
void *pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION; TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
/* /*
* For internal use only. Same as vTaskSetTimeOutState(), but without a critial * For internal use only. Same as vTaskSetTimeOutState(), but without a critial

View File

@ -632,12 +632,12 @@ BaseType_t xReturn;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void* MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore )
{ {
BaseType_t xRunningPrivileged = xPortRaisePrivilege(); BaseType_t xRunningPrivileged = xPortRaisePrivilege();
void * xReturn; void * xReturn;
xReturn = ( void * ) xQueueGetMutexHolder( xSemaphore ); xReturn = xQueueGetMutexHolder( xSemaphore );
vPortResetPrivilege( xRunningPrivileged ); vPortResetPrivilege( xRunningPrivileged );
return xReturn; return xReturn;
} }

View File

@ -56,17 +56,26 @@ correct privileged Vs unprivileged linkage and placement. */
pcTail members are used as pointers into the queue storage area. When the pcTail members are used as pointers into the queue storage area. When the
Queue_t structure is used to represent a mutex pcHead and pcTail pointers are Queue_t structure is used to represent a mutex pcHead and pcTail pointers are
not necessary, and the pcHead pointer is set to NULL to indicate that the not necessary, and the pcHead pointer is set to NULL to indicate that the
pcTail pointer actually points to the mutex holder (if any). Map alternative structure instead holds a pointer to the mutex holder (if any). Map alternative
names to the pcHead and pcTail structure members to ensure the readability of names to the pcHead and structure member to ensure the readability of the code
the code is maintained despite this dual use of two structure members. An is maintained. The QueuePointers_t and SemaphoreData_t types are used to form
alternative implementation would be to use a union, but use of a union is a union as their usage is mutually exclusive dependent on what the queue is
against the coding standard (although an exception to the standard has been being used for. */
permitted where the dual use also significantly changes the type of the
structure member). */
#define pxMutexHolder pcTail
#define uxQueueType pcHead #define uxQueueType pcHead
#define queueQUEUE_IS_MUTEX NULL #define queueQUEUE_IS_MUTEX NULL
typedef struct QueuePointers
{
int8_t *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. */
int8_t *pcReadFrom; /*< Points to the last place that a queued item was read from when the structure is used as a queue. */
} QueuePointers_t;
typedef struct SemaphoreData
{
TaskHandle_t xMutexHolder; /*< The handle of the task that holds the mutex. */
UBaseType_t uxRecursiveCallCount;/*< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */
} SemaphoreData_t;
/* Semaphores do not actually store or copy data, so have an item size of /* Semaphores do not actually store or copy data, so have an item size of
zero. */ zero. */
#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 ) #define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 )
@ -88,13 +97,12 @@ zero. */
typedef struct QueueDef_t typedef struct QueueDef_t
{ {
int8_t *pcHead; /*< Points to the beginning of the queue storage area. */ int8_t *pcHead; /*< Points to the beginning of the queue storage area. */
int8_t *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. */
int8_t *pcWriteTo; /*< Points to the free next place in the storage area. */ int8_t *pcWriteTo; /*< Points to the free next place in the storage area. */
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). */ union
{ {
int8_t *pcReadFrom; /*< Points to the last place that a queued item was read from when the structure is used as a queue. */ QueuePointers_t xQueue; /*< Data required exclusively when this structure is used as a queue. */
UBaseType_t uxRecursiveCallCount;/*< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */ SemaphoreData_t xSemaphore; /*< Data required exclusively when this structure is used as a semaphore. */
} u; } u;
List_t xTasksWaitingToSend; /*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */ List_t xTasksWaitingToSend; /*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */
@ -252,10 +260,10 @@ Queue_t * const pxQueue = xQueue;
taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;
pxQueue->pcWriteTo = pxQueue->pcHead; pxQueue->pcWriteTo = pxQueue->pcHead;
pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize ); pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
pxQueue->cRxLock = queueUNLOCKED; pxQueue->cRxLock = queueUNLOCKED;
pxQueue->cTxLock = queueUNLOCKED; pxQueue->cTxLock = queueUNLOCKED;
@ -392,7 +400,8 @@ Queue_t * const pxQueue = xQueue;
{ {
/* Jump past the queue structure to find the location of the queue /* Jump past the queue structure to find the location of the queue
storage area. */ storage area. */
pucQueueStorage = ( ( uint8_t * ) pxNewQueue ) + sizeof( Queue_t ); pucQueueStorage = ( uint8_t * ) pxNewQueue;
pucQueueStorage += sizeof( Queue_t ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
#if( configSUPPORT_STATIC_ALLOCATION == 1 ) #if( configSUPPORT_STATIC_ALLOCATION == 1 )
{ {
@ -469,11 +478,11 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
correctly for a generic queue, but this function is creating a correctly for a generic queue, but this function is creating a
mutex. Overwrite those members that need to be set differently - mutex. Overwrite those members that need to be set differently -
in particular the information required for priority inheritance. */ in particular the information required for priority inheritance. */
pxNewQueue->pxMutexHolder = NULL; pxNewQueue->u.xSemaphore.xMutexHolder = NULL;
pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX; pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX;
/* In case this is a recursive mutex. */ /* In case this is a recursive mutex. */
pxNewQueue->u.uxRecursiveCallCount = 0; pxNewQueue->u.xSemaphore.uxRecursiveCallCount = 0;
traceCREATE_MUTEX( pxNewQueue ); traceCREATE_MUTEX( pxNewQueue );
@ -527,9 +536,9 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore )
{ {
void *pxReturn; TaskHandle_t pxReturn;
Queue_t * const pxSemaphore = ( Queue_t * ) xSemaphore; Queue_t * const pxSemaphore = ( Queue_t * ) xSemaphore;
/* This function is called by xSemaphoreGetMutexHolder(), and should not /* This function is called by xSemaphoreGetMutexHolder(), and should not
@ -541,7 +550,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
{ {
if( pxSemaphore->uxQueueType == queueQUEUE_IS_MUTEX ) if( pxSemaphore->uxQueueType == queueQUEUE_IS_MUTEX )
{ {
pxReturn = ( void * ) pxSemaphore->pxMutexHolder; pxReturn = pxSemaphore->u.xSemaphore.xMutexHolder;
} }
else else
{ {
@ -558,9 +567,9 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
void* xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore )
{ {
void *pxReturn; TaskHandle_t pxReturn;
configASSERT( xSemaphore ); configASSERT( xSemaphore );
@ -569,7 +578,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
not required here. */ not required here. */
if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX ) if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )
{ {
pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder; pxReturn = ( ( Queue_t * ) xSemaphore )->u.xSemaphore.xMutexHolder;
} }
else else
{ {
@ -591,25 +600,25 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
configASSERT( pxMutex ); configASSERT( pxMutex );
/* If this is the task that holds the mutex then pxMutexHolder will not /* If this is the task that holds the mutex then xMutexHolder will not
change outside of this task. If this task does not hold the mutex then change outside of this task. If this task does not hold the mutex then
pxMutexHolder can never coincidentally equal the tasks handle, and as pxMutexHolder can never coincidentally equal the tasks handle, and as
this is the only condition we are interested in it does not matter if this is the only condition we are interested in it does not matter if
pxMutexHolder is accessed simultaneously by another task. Therefore no pxMutexHolder is accessed simultaneously by another task. Therefore no
mutual exclusion is required to test the pxMutexHolder variable. */ mutual exclusion is required to test the pxMutexHolder variable. */
if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Not a redundant cast as TaskHandle_t is a typedef. */ if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() )
{ {
traceGIVE_MUTEX_RECURSIVE( pxMutex ); traceGIVE_MUTEX_RECURSIVE( pxMutex );
/* uxRecursiveCallCount cannot be zero if pxMutexHolder is equal to /* uxRecursiveCallCount cannot be zero if xMutexHolder is equal to
the task handle, therefore no underflow check is required. Also, the task handle, therefore no underflow check is required. Also,
uxRecursiveCallCount is only modified by the mutex holder, and as uxRecursiveCallCount is only modified by the mutex holder, and as
there can only be one, no mutual exclusion is required to modify the there can only be one, no mutual exclusion is required to modify the
uxRecursiveCallCount member. */ uxRecursiveCallCount member. */
( pxMutex->u.uxRecursiveCallCount )--; ( pxMutex->u.xSemaphore.uxRecursiveCallCount )--;
/* Has the recursive call count unwound to 0? */ /* Has the recursive call count unwound to 0? */
if( pxMutex->u.uxRecursiveCallCount == ( UBaseType_t ) 0 ) if( pxMutex->u.xSemaphore.uxRecursiveCallCount == ( UBaseType_t ) 0 )
{ {
/* Return the mutex. This will automatically unblock any other /* Return the mutex. This will automatically unblock any other
task that might be waiting to access the mutex. */ task that might be waiting to access the mutex. */
@ -651,9 +660,9 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
traceTAKE_MUTEX_RECURSIVE( pxMutex ); traceTAKE_MUTEX_RECURSIVE( pxMutex );
if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */ if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() )
{ {
( pxMutex->u.uxRecursiveCallCount )++; ( pxMutex->u.xSemaphore.uxRecursiveCallCount )++;
xReturn = pdPASS; xReturn = pdPASS;
} }
else else
@ -665,7 +674,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
before reaching here. */ before reaching here. */
if( xReturn != pdFAIL ) if( xReturn != pdFAIL )
{ {
( pxMutex->u.uxRecursiveCallCount )++; ( pxMutex->u.xSemaphore.uxRecursiveCallCount )++;
} }
else else
{ {
@ -1117,7 +1126,7 @@ Queue_t * const pxQueue = xQueue;
/* Normally a mutex would not be given from an interrupt, especially if /* Normally a mutex would not be given from an interrupt, especially if
there is a mutex holder, as priority inheritance makes no sense for an there is a mutex holder, as priority inheritance makes no sense for an
interrupts, only tasks. */ interrupts, only tasks. */
configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->pxMutexHolder != NULL ) ) ); configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->u.xSemaphore.xMutexHolder != NULL ) ) );
/* RTOS ports that support interrupt nesting have the concept of a maximum /* RTOS ports that support interrupt nesting have the concept of a maximum
system call (or maximum API call) interrupt priority. Interrupts that are system call (or maximum API call) interrupt priority. Interrupts that are
@ -1454,7 +1463,7 @@ Queue_t * const pxQueue = xQueue;
{ {
/* Record the information required to implement /* Record the information required to implement
priority inheritance should it become necessary. */ priority inheritance should it become necessary. */
pxQueue->pxMutexHolder = ( int8_t * ) pvTaskIncrementMutexHeldCount(); /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */ pxQueue->u.xSemaphore.xMutexHolder = pvTaskIncrementMutexHeldCount();
} }
else else
{ {
@ -1542,7 +1551,7 @@ Queue_t * const pxQueue = xQueue;
{ {
taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
xInheritanceOccurred = xTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder ); xInheritanceOccurred = xTaskPriorityInherit( pxQueue->u.xSemaphore.xMutexHolder );
} }
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
} }
@ -1601,7 +1610,7 @@ Queue_t * const pxQueue = xQueue;
again, but only as low as the next highest priority again, but only as low as the next highest priority
task that is waiting for the same mutex. */ task that is waiting for the same mutex. */
uxHighestWaitingPriority = prvGetDisinheritPriorityAfterTimeout( pxQueue ); uxHighestWaitingPriority = prvGetDisinheritPriorityAfterTimeout( pxQueue );
vTaskPriorityDisinheritAfterTimeout( ( void * ) pxQueue->pxMutexHolder, uxHighestWaitingPriority ); vTaskPriorityDisinheritAfterTimeout( pxQueue->u.xSemaphore.xMutexHolder, uxHighestWaitingPriority );
} }
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
} }
@ -1642,10 +1651,9 @@ Queue_t * const pxQueue = xQueue;
#endif #endif
/* This function relaxes the coding standard somewhat to allow return /*lint -save -e904 This function relaxes the coding standard somewhat to
statements within the function itself. This is done in the interest allow return statements within the function itself. This is done in the
of execution time efficiency. */ interest of execution time efficiency. */
for( ;; ) for( ;; )
{ {
taskENTER_CRITICAL(); taskENTER_CRITICAL();
@ -1659,13 +1667,13 @@ Queue_t * const pxQueue = xQueue;
/* Remember the read position so it can be reset after the data /* Remember the read position so it can be reset after the data
is read from the queue as this function is only peeking the is read from the queue as this function is only peeking the
data, not removing it. */ data, not removing it. */
pcOriginalReadPosition = pxQueue->u.pcReadFrom; pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom;
prvCopyDataFromQueue( pxQueue, pvBuffer ); prvCopyDataFromQueue( pxQueue, pvBuffer );
traceQUEUE_PEEK( pxQueue ); traceQUEUE_PEEK( pxQueue );
/* The data is not being removed, so reset the read pointer. */ /* The data is not being removed, so reset the read pointer. */
pxQueue->u.pcReadFrom = pcOriginalReadPosition; pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition;
/* The data is being left in the queue, so see if there are /* The data is being left in the queue, so see if there are
any other tasks waiting for the data. */ any other tasks waiting for the data. */
@ -1766,7 +1774,7 @@ Queue_t * const pxQueue = xQueue;
mtCOVERAGE_TEST_MARKER(); mtCOVERAGE_TEST_MARKER();
} }
} }
} } /*lint -restore */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -1897,9 +1905,9 @@ Queue_t * const pxQueue = xQueue;
/* Remember the read position so it can be reset as nothing is /* Remember the read position so it can be reset as nothing is
actually being removed from the queue. */ actually being removed from the queue. */
pcOriginalReadPosition = pxQueue->u.pcReadFrom; pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom;
prvCopyDataFromQueue( pxQueue, pvBuffer ); prvCopyDataFromQueue( pxQueue, pvBuffer );
pxQueue->u.pcReadFrom = pcOriginalReadPosition; pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition;
xReturn = pdPASS; xReturn = pdPASS;
} }
@ -2075,8 +2083,8 @@ UBaseType_t uxMessagesWaiting;
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
{ {
/* The mutex is no longer being held. */ /* The mutex is no longer being held. */
xReturn = xTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder ); xReturn = xTaskPriorityDisinherit( pxQueue->u.xSemaphore.xMutexHolder );
pxQueue->pxMutexHolder = NULL; pxQueue->u.xSemaphore.xMutexHolder = NULL;
} }
else else
{ {
@ -2089,7 +2097,7 @@ UBaseType_t uxMessagesWaiting;
{ {
( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 !e9087 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. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. */ ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 !e9087 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. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. */
pxQueue->pcWriteTo += pxQueue->uxItemSize; /*lint !e9016 Pointer arithmetic on char types ok, especially in this use case where it is the clearest way of conveying intent. */ pxQueue->pcWriteTo += pxQueue->uxItemSize; /*lint !e9016 Pointer arithmetic on char types ok, especially in this use case where it is the clearest way of conveying intent. */
if( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ if( pxQueue->pcWriteTo >= pxQueue->u.xQueue.pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */
{ {
pxQueue->pcWriteTo = pxQueue->pcHead; pxQueue->pcWriteTo = pxQueue->pcHead;
} }
@ -2100,11 +2108,11 @@ UBaseType_t uxMessagesWaiting;
} }
else else
{ {
( void ) memcpy( ( void * ) pxQueue->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e9087 MISRA exception as the casts are only redundant for some ports. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. */ ( void ) memcpy( ( void * ) pxQueue->u.xQueue.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e9087 !e418 MISRA exception as the casts are only redundant for some ports. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. Assert checks null pointer only used when length is 0. */
pxQueue->u.pcReadFrom -= pxQueue->uxItemSize; pxQueue->u.xQueue.pcReadFrom -= pxQueue->uxItemSize;
if( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ if( pxQueue->u.xQueue.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */
{ {
pxQueue->u.pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize ); pxQueue->u.xQueue.pcReadFrom = ( pxQueue->u.xQueue.pcTail - pxQueue->uxItemSize );
} }
else else
{ {
@ -2142,16 +2150,16 @@ static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer
{ {
if( pxQueue->uxItemSize != ( UBaseType_t ) 0 ) if( pxQueue->uxItemSize != ( UBaseType_t ) 0 )
{ {
pxQueue->u.pcReadFrom += pxQueue->uxItemSize; /*lint !e9016 Pointer arithmetic on char types ok, especially in this use case where it is the clearest way of conveying intent. */ pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize; /*lint !e9016 Pointer arithmetic on char types ok, especially in this use case where it is the clearest way of conveying intent. */
if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */ if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */
{ {
pxQueue->u.pcReadFrom = pxQueue->pcHead; pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;
} }
else else
{ {
mtCOVERAGE_TEST_MARKER(); mtCOVERAGE_TEST_MARKER();
} }
( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 !e9087 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. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. */ ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 !e9087 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. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. */
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -2475,17 +2483,17 @@ Queue_t * const pxQueue = xQueue;
if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )
{ {
/* Data is available from the queue. */ /* Data is available from the queue. */
pxQueue->u.pcReadFrom += pxQueue->uxItemSize; pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize;
if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail )
{ {
pxQueue->u.pcReadFrom = pxQueue->pcHead; pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;
} }
else else
{ {
mtCOVERAGE_TEST_MARKER(); mtCOVERAGE_TEST_MARKER();
} }
--( pxQueue->uxMessagesWaiting ); --( pxQueue->uxMessagesWaiting );
( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
xReturn = pdPASS; xReturn = pdPASS;
@ -2583,17 +2591,17 @@ Queue_t * const pxQueue = xQueue;
if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )
{ {
/* Copy the data from the queue. */ /* Copy the data from the queue. */
pxQueue->u.pcReadFrom += pxQueue->uxItemSize; pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize;
if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail )
{ {
pxQueue->u.pcReadFrom = pxQueue->pcHead; pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;
} }
else else
{ {
mtCOVERAGE_TEST_MARKER(); mtCOVERAGE_TEST_MARKER();
} }
--( pxQueue->uxMessagesWaiting ); --( pxQueue->uxMessagesWaiting );
( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
if( ( *pxCoRoutineWoken ) == pdFALSE ) if( ( *pxCoRoutineWoken ) == pdFALSE )
{ {

View File

@ -4426,7 +4426,7 @@ TickType_t uxReturn;
#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
void *pvTaskIncrementMutexHeldCount( void ) TaskHandle_t pvTaskIncrementMutexHeldCount( void )
{ {
/* If xSemaphoreCreateMutex() is called before any tasks have been created /* If xSemaphoreCreateMutex() is called before any tasks have been created
then pxCurrentTCB will be NULL. */ then pxCurrentTCB will be NULL. */