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.
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;
typedefstructSemaphoreData
{
TaskHandle_txMutexHolder;/*< The handle of the task that holds the mutex. */
UBaseType_tuxRecursiveCallCount;/*< 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
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. */
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. */
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. */
QueuePointers_txQueue;/*< Data required exclusively when this structure is used as a queue. */
SemaphoreData_t xSemaphore;/*< Data required exclusively when this structure is used as a semaphore. */
}u;
List_txTasksWaitingToSend;/*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */
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->u.xQueue.pcReadFrom =pxQueue->pcHead+((pxQueue->uxLength-1U)*pxQueue->uxItemSize);/*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
(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. */
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. */
(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. */
pxQueue->u.pcReadFrom -=pxQueue->uxItemSize;
if(pxQueue->u.pcReadFrom <pxQueue->pcHead)/*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */
(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;/*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. */
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.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
{
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. */