#include "croutine.h"\r
#endif\r
\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
+/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified\r
+because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined\r
+for the header files above, but not in this file, in order to generate the\r
+correct privileged Vs unprivileged linkage and placement. */\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */\r
\r
\r
/* Constants used with the cRxLock and cTxLock structure members. */\r
/*\r
* Definition of the queue used by the scheduler.\r
* Items are queued by copy, not reference. See the following link for the\r
- * rationale: http://www.freertos.org/Embedded-RTOS-Queues.html\r
+ * rationale: https://www.freertos.org/Embedded-RTOS-Queues.html\r
*/\r
-typedef struct QueueDefinition\r
+typedef struct QueueDef_t\r
{\r
int8_t *pcHead; /*< Points to the beginning of the queue storage area. */\r
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. */\r
#endif\r
\r
#if ( configUSE_QUEUE_SETS == 1 )\r
- struct QueueDefinition *pxQueueSetContainer;\r
+ struct QueueDef_t *pxQueueSetContainer;\r
#endif\r
\r
#if ( configUSE_TRACE_FACILITY == 1 )\r
\r
BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue )\r
{\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
configASSERT( pxQueue );\r
\r
pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize );\r
pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;\r
pxQueue->pcWriteTo = pxQueue->pcHead;\r
- pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( UBaseType_t ) 1U ) * pxQueue->uxItemSize );\r
+ pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize );\r
pxQueue->cRxLock = queueUNLOCKED;\r
pxQueue->cTxLock = queueUNLOCKED;\r
\r
\r
QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType )\r
{\r
- Queue_t *pxNewQueue = NULL;\r
+ Queue_t *pxNewQueue;\r
\r
configASSERT( uxQueueLength > ( UBaseType_t ) 0 );\r
\r
the real queue and semaphore structures. */\r
volatile size_t xSize = sizeof( StaticQueue_t );\r
configASSERT( xSize == sizeof( Queue_t ) );\r
+ ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */\r
}\r
#endif /* configASSERT_DEFINED */\r
\r
/* The address of a statically allocated queue was passed in, use it.\r
The address of a statically allocated storage area was also passed in\r
but is already set. */\r
- pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */\r
+ pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */\r
\r
if( pxNewQueue != NULL )\r
{\r
xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
}\r
\r
- pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes );\r
+ /* Allocate the queue and storage area. Justification for MISRA\r
+ deviation as follows: pvPortMalloc() always ensures returned memory\r
+ blocks are aligned per the requirements of the MCU stack. In this case\r
+ pvPortMalloc() must return a pointer that is guaranteed to meet the\r
+ alignment requirements of the Queue_t structure - which in this case\r
+ is an int8_t *. Therefore, whenever the stack alignment requirements\r
+ are greater than or equal to the pointer to char requirements the cast\r
+ is safe. In other cases alignment requirements are not strict (one or\r
+ two bytes). */\r
+ pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); /*lint !e9087 !e9079 see comment above. */\r
\r
if( pxNewQueue != NULL )\r
{\r
\r
QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType )\r
{\r
- Queue_t *pxNewQueue;\r
+ QueueHandle_t xNewQueue;\r
const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0;\r
\r
- pxNewQueue = ( Queue_t * ) xQueueGenericCreate( uxMutexLength, uxMutexSize, ucQueueType );\r
- prvInitialiseMutex( pxNewQueue );\r
+ xNewQueue = xQueueGenericCreate( uxMutexLength, uxMutexSize, ucQueueType );\r
+ prvInitialiseMutex( ( Queue_t * ) xNewQueue );\r
\r
- return pxNewQueue;\r
+ return xNewQueue;\r
}\r
\r
#endif /* configUSE_MUTEXES */\r
\r
QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue )\r
{\r
- Queue_t *pxNewQueue;\r
+ QueueHandle_t xNewQueue;\r
const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0;\r
\r
/* Prevent compiler warnings about unused parameters if\r
configUSE_TRACE_FACILITY does not equal 1. */\r
( void ) ucQueueType;\r
\r
- pxNewQueue = ( Queue_t * ) xQueueGenericCreateStatic( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType );\r
- prvInitialiseMutex( pxNewQueue );\r
+ xNewQueue = xQueueGenericCreateStatic( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType );\r
+ prvInitialiseMutex( ( Queue_t * ) xNewQueue );\r
\r
- return pxNewQueue;\r
+ return xNewQueue;\r
}\r
\r
#endif /* configUSE_MUTEXES */\r
void* xQueueGetMutexHolder( QueueHandle_t xSemaphore )\r
{\r
void *pxReturn;\r
+ Queue_t * const pxSemaphore = ( Queue_t * ) xSemaphore;\r
\r
/* This function is called by xSemaphoreGetMutexHolder(), and should not\r
be called directly. Note: This is a good way of determining if the\r
following critical section exiting and the function returning. */\r
taskENTER_CRITICAL();\r
{\r
- if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )\r
+ if( pxSemaphore->uxQueueType == queueQUEUE_IS_MUTEX )\r
{\r
- pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder;\r
+ pxReturn = ( void * ) pxSemaphore->pxMutexHolder;\r
}\r
else\r
{\r
{\r
BaseType_t xEntryTimeSet = pdFALSE, xYieldRequired;\r
TimeOut_t xTimeOut;\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
configASSERT( pxQueue );\r
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
#endif\r
\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
- of execution time efficiency. */\r
+ /*lint -save -e904 This function relaxes the coding standard somewhat to\r
+ allow return statements within the function itself. This is done in the\r
+ interest of execution time efficiency. */\r
for( ;; )\r
{\r
taskENTER_CRITICAL();\r
traceQUEUE_SEND_FAILED( pxQueue );\r
return errQUEUE_FULL;\r
}\r
- }\r
+ } /*lint -restore */\r
}\r
/*-----------------------------------------------------------*/\r
\r
{\r
BaseType_t xReturn;\r
UBaseType_t uxSavedInterruptStatus;\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
configASSERT( pxQueue );\r
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
{\r
BaseType_t xReturn;\r
UBaseType_t uxSavedInterruptStatus;\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
/* Similar to xQueueGenericSendFromISR() but used with semaphores where the\r
item size is 0. Don't directly wake a task that was blocked on a queue\r
{\r
BaseType_t xEntryTimeSet = pdFALSE;\r
TimeOut_t xTimeOut;\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
/* Check the pointer is not NULL. */\r
configASSERT( ( pxQueue ) );\r
#endif\r
\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
- of execution time efficiency. */\r
-\r
+ /*lint -save -e904 This function relaxes the coding standard somewhat to\r
+ allow return statements within the function itself. This is done in the\r
+ interest of execution time efficiency. */\r
for( ;; )\r
{\r
taskENTER_CRITICAL();\r
mtCOVERAGE_TEST_MARKER();\r
}\r
}\r
- }\r
+ } /*lint -restore */\r
}\r
/*-----------------------------------------------------------*/\r
\r
{\r
BaseType_t xEntryTimeSet = pdFALSE;\r
TimeOut_t xTimeOut;\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
#if( configUSE_MUTEXES == 1 )\r
BaseType_t xInheritanceOccurred = pdFALSE;\r
#endif\r
\r
\r
- /* This function relaxes the coding standard somewhat to allow return\r
+ /*lint -save -e904 This function relaxes the coding standard somewhat to allow return\r
statements within the function itself. This is done in the interest\r
of execution time efficiency. */\r
-\r
for( ;; )\r
{\r
taskENTER_CRITICAL();\r
mtCOVERAGE_TEST_MARKER();\r
}\r
}\r
- }\r
+ } /*lint -restore */\r
}\r
/*-----------------------------------------------------------*/\r
\r
BaseType_t xEntryTimeSet = pdFALSE;\r
TimeOut_t xTimeOut;\r
int8_t *pcOriginalReadPosition;\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
/* Check the pointer is not NULL. */\r
configASSERT( ( pxQueue ) );\r
{\r
BaseType_t xReturn;\r
UBaseType_t uxSavedInterruptStatus;\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
configASSERT( pxQueue );\r
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
BaseType_t xReturn;\r
UBaseType_t uxSavedInterruptStatus;\r
int8_t *pcOriginalReadPosition;\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
configASSERT( pxQueue );\r
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue )\r
{\r
UBaseType_t uxReturn;\r
-Queue_t *pxQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
- pxQueue = ( Queue_t * ) xQueue;\r
configASSERT( pxQueue );\r
\r
taskENTER_CRITICAL();\r
UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue )\r
{\r
UBaseType_t uxReturn;\r
+Queue_t * const pxQueue = xQueue;\r
\r
- configASSERT( xQueue );\r
-\r
- uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;\r
+ configASSERT( pxQueue );\r
+ uxReturn = pxQueue->uxMessagesWaiting;\r
\r
return uxReturn;\r
} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */\r
\r
void vQueueDelete( QueueHandle_t xQueue )\r
{\r
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+Queue_t * const pxQueue = xQueue;\r
\r
configASSERT( pxQueue );\r
traceQUEUE_DELETE( pxQueue );\r
other tasks that are waiting for the same mutex. For this purpose,\r
return the priority of the highest priority task that is waiting for the\r
mutex. */\r
- if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0 )\r
+ if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0U )\r
{\r
- uxHighestPriorityOfWaitingTasks = configMAX_PRIORITIES - listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) );\r
+ uxHighestPriorityOfWaitingTasks = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) );\r
}\r
else\r
{\r
}\r
else if( xPosition == queueSEND_TO_BACK )\r
{\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
+ ( 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. */\r
+ 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. */\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
else\r
{\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
+ ( 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. */\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
{\r
if( pxQueue->uxItemSize != ( UBaseType_t ) 0 )\r
{\r
- pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+ 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. */\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
mtCOVERAGE_TEST_MARKER();\r
}\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
+ ( 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. */\r
}\r
}\r
/*-----------------------------------------------------------*/\r
BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue )\r
{\r
BaseType_t xReturn;\r
+Queue_t * const pxQueue = xQueue;\r
\r
- configASSERT( xQueue );\r
- if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( UBaseType_t ) 0 )\r
+ configASSERT( pxQueue );\r
+ if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 )\r
{\r
xReturn = pdTRUE;\r
}\r
BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )\r
{\r
BaseType_t xReturn;\r
+Queue_t * const pxQueue = xQueue;\r
\r
- configASSERT( xQueue );\r
- if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( ( Queue_t * ) xQueue )->uxLength )\r
+ configASSERT( pxQueue );\r
+ if( pxQueue->uxMessagesWaiting == pxQueue->uxLength )\r
{\r
xReturn = pdTRUE;\r
}\r
BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait )\r
{\r
BaseType_t xReturn;\r
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+ Queue_t * const pxQueue = 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
BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait )\r
{\r
BaseType_t xReturn;\r
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+ Queue_t * const pxQueue = 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
\r
BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken )\r
{\r
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+ Queue_t * const pxQueue = xQueue;\r
\r
/* Cannot block within an ISR so if there is no space on the queue then\r
exit without doing anything. */\r
BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxCoRoutineWoken )\r
{\r
BaseType_t xReturn;\r
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+ Queue_t * const pxQueue = 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
\r
void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )\r
{\r
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+ Queue_t * const pxQueue = 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
#error configUSE_TASK_NOTIFICATIONS must be set to 1 to build stream_buffer.c\r
#endif\r
\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
+/* Lint e961, e9021 and e750 are suppressed as a MISRA exception justified\r
+because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined\r
+for the header files above, but not in this file, in order to generate the\r
+correct privileged Vs unprivileged linkage and placement. */\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */\r
\r
/* If the user has not provided application specific Rx notification macros,\r
or #defined the notification macros away, them provide default implementations\r
/*-----------------------------------------------------------*/\r
\r
/* Structure that hold state information on the buffer. */\r
-typedef struct xSTREAM_BUFFER /*lint !e9058 Style convention uses tag. */\r
+typedef struct StreamBufferDef_t /*lint !e9058 Style convention uses tag. */\r
{\r
volatile size_t xTail; /* Index to the next item to read within the buffer. */\r
volatile size_t xHead; /* Index to the next item to write within the buffer. */\r
the buffer was empty. */\r
if( xTriggerLevelBytes == ( size_t ) 0 )\r
{\r
- xTriggerLevelBytes = ( size_t ) 1; /*lint !e9044 Parameter modified to ensure it doesn't have a dangerous value. */\r
+ xTriggerLevelBytes = ( size_t ) 1;\r
}\r
\r
/* A stream buffer requires a StreamBuffer_t structure and a buffer.\r
traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer );\r
}\r
\r
- return ( StreamBufferHandle_t * ) pucAllocatedMemory; /*lint !e9087 !e826 Safe cast as allocated memory is aligned. */\r
+ return ( StreamBufferHandle_t ) pucAllocatedMemory; /*lint !e9087 !e826 Safe cast as allocated memory is aligned. */\r
}\r
\r
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */\r
the buffer was empty. */\r
if( xTriggerLevelBytes == ( size_t ) 0 )\r
{\r
- xTriggerLevelBytes = ( size_t ) 1; /*lint !e9044 Function parameter deliberately modified to ensure it is in range. */\r
+ xTriggerLevelBytes = ( size_t ) 1;\r
}\r
\r
/* In case the stream buffer is going to be used as a message buffer\r
message buffer structure. */\r
volatile size_t xSize = sizeof( StaticStreamBuffer_t );\r
configASSERT( xSize == sizeof( StreamBuffer_t ) );\r
- }\r
+ } /*lint !e529 xSize is referenced is configASSERT() is defined. */\r
#endif /* configASSERT_DEFINED */\r
\r
if( ( pucStreamBufferStorageArea != NULL ) && ( pxStaticStreamBuffer != NULL ) )\r
\r
void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer )\r
{\r
-StreamBuffer_t * pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * pxStreamBuffer = xStreamBuffer;\r
\r
configASSERT( pxStreamBuffer );\r
\r
#endif\r
\r
/* Can only reset a message buffer if there are no tasks blocked on it. */\r
- if( pxStreamBuffer->xTaskWaitingToReceive == NULL )\r
+ taskENTER_CRITICAL();\r
{\r
- if( pxStreamBuffer->xTaskWaitingToSend == NULL )\r
+ if( pxStreamBuffer->xTaskWaitingToReceive == NULL )\r
{\r
- if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )\r
- {\r
- xIsMessageBuffer = pdTRUE;\r
- }\r
- else\r
+ if( pxStreamBuffer->xTaskWaitingToSend == NULL )\r
{\r
- xIsMessageBuffer = pdFALSE;\r
- }\r
+ if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )\r
+ {\r
+ xIsMessageBuffer = pdTRUE;\r
+ }\r
+ else\r
+ {\r
+ xIsMessageBuffer = pdFALSE;\r
+ }\r
\r
- prvInitialiseNewStreamBuffer( pxStreamBuffer,\r
- pxStreamBuffer->pucBuffer,\r
- pxStreamBuffer->xLength,\r
- pxStreamBuffer->xTriggerLevelBytes,\r
- xIsMessageBuffer );\r
- xReturn = pdPASS;\r
+ prvInitialiseNewStreamBuffer( pxStreamBuffer,\r
+ pxStreamBuffer->pucBuffer,\r
+ pxStreamBuffer->xLength,\r
+ pxStreamBuffer->xTriggerLevelBytes,\r
+ xIsMessageBuffer );\r
+ xReturn = pdPASS;\r
\r
- #if( configUSE_TRACE_FACILITY == 1 )\r
- {\r
- pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;\r
- }\r
- #endif\r
+ #if( configUSE_TRACE_FACILITY == 1 )\r
+ {\r
+ pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;\r
+ }\r
+ #endif\r
\r
- traceSTREAM_BUFFER_RESET( xStreamBuffer );\r
+ traceSTREAM_BUFFER_RESET( xStreamBuffer );\r
+ }\r
}\r
}\r
+ taskEXIT_CRITICAL();\r
\r
return xReturn;\r
}\r
\r
BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel )\r
{\r
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
BaseType_t xReturn;\r
\r
configASSERT( pxStreamBuffer );\r
/* It is not valid for the trigger level to be 0. */\r
if( xTriggerLevel == ( size_t ) 0 )\r
{\r
- xTriggerLevel = ( size_t ) 1; /*lint !e9044 Parameter modified to ensure it doesn't have a dangerous value. */\r
+ xTriggerLevel = ( size_t ) 1;\r
}\r
\r
/* The trigger level is the number of bytes that must be in the stream\r
\r
size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer )\r
{\r
-const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
size_t xSpace;\r
\r
configASSERT( pxStreamBuffer );\r
\r
size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer )\r
{\r
-const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
size_t xReturn;\r
\r
configASSERT( pxStreamBuffer );\r
size_t xDataLengthBytes,\r
TickType_t xTicksToWait )\r
{\r
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
size_t xReturn, xSpace = 0;\r
size_t xRequiredSpace = xDataLengthBytes;\r
TimeOut_t xTimeOut;\r
size_t xDataLengthBytes,\r
BaseType_t * const pxHigherPriorityTaskWoken )\r
{\r
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
size_t xReturn, xSpace;\r
size_t xRequiredSpace = xDataLengthBytes;\r
\r
stream of bytes rather than discrete messages. Write as many bytes as\r
possible. */\r
xShouldWrite = pdTRUE;\r
- xDataLengthBytes = configMIN( xDataLengthBytes, xSpace ); /*lint !e9044 Function parameter modified to ensure it is capped to available space. */\r
+ xDataLengthBytes = configMIN( xDataLengthBytes, xSpace );\r
}\r
else if( xSpace >= xRequiredSpace )\r
{\r
size_t xBufferLengthBytes,\r
TickType_t xTicksToWait )\r
{\r
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength;\r
\r
configASSERT( pvRxData );\r
\r
size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer )\r
{\r
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
size_t xReturn, xBytesAvailable, xOriginalTail;\r
configMESSAGE_BUFFER_LENGTH_TYPE xTempReturn;\r
\r
size_t xBufferLengthBytes,\r
BaseType_t * const pxHigherPriorityTaskWoken )\r
{\r
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength;\r
\r
configASSERT( pvRxData );\r
\r
BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer )\r
{\r
-const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
BaseType_t xReturn;\r
size_t xTail;\r
\r
{\r
BaseType_t xReturn;\r
size_t xBytesToStoreMessageLength;\r
-const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
\r
configASSERT( pxStreamBuffer );\r
\r
\r
BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken )\r
{\r
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
BaseType_t xReturn;\r
UBaseType_t uxSavedInterruptStatus;\r
\r
\r
BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken )\r
{\r
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
BaseType_t xReturn;\r
UBaseType_t uxSavedInterruptStatus;\r
\r
result in confusion as to what is actually being observed. */\r
const BaseType_t xWriteValue = 0x55;\r
configASSERT( memset( pucBuffer, ( int ) xWriteValue, xBufferSizeBytes ) == pucBuffer );\r
- }\r
+ } /*lint !e529 !e438 xWriteValue is only used if configASSERT() is defined. */\r
#endif\r
\r
memset( ( void * ) pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); /*lint !e9087 memset() requires void *. */\r
\r
UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer )\r
{\r
- return ( ( StreamBuffer_t * ) xStreamBuffer )->uxStreamBufferNumber;\r
+ return xStreamBuffer->uxStreamBufferNumber;\r
}\r
\r
#endif /* configUSE_TRACE_FACILITY */\r
\r
void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber )\r
{\r
- ( ( StreamBuffer_t * ) xStreamBuffer )->uxStreamBufferNumber = uxStreamBufferNumber;\r
+ xStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;\r
}\r
\r
#endif /* configUSE_TRACE_FACILITY */\r
\r
uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer )\r
{\r
- return ( ( StreamBuffer_t * )xStreamBuffer )->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER;\r
+ return ( xStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER );\r
}\r
\r
#endif /* configUSE_TRACE_FACILITY */\r