/*\r
- * FreeRTOS Kernel V10.0.0\r
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
+ * FreeRTOS Kernel V10.3.0\r
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
*\r
* Permission is hereby granted, free of charge, to any person obtaining a copy of\r
* this software and associated documentation files (the "Software"), to deal in\r
* subject to the following conditions:\r
*\r
* The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software. If you wish to use our Amazon\r
- * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
+ * copies or substantial portions of the Software.\r
*\r
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
#include "task.h"\r
#include "stream_buffer.h"\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
+#if( configUSE_TASK_NOTIFICATIONS != 1 )\r
+ #error configUSE_TASK_NOTIFICATIONS must be set to 1 to build stream_buffer.c\r
+#endif\r
+\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
/*lint -restore (9026) */\r
\r
/* The number of bytes used to hold the length of a message in the buffer. */\r
-#define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( size_t ) )\r
+#define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) )\r
\r
/* Bits stored in the ucFlags field of the stream buffer. */\r
#define sbFLAGS_IS_MESSAGE_BUFFER ( ( uint8_t ) 1 ) /* Set if the stream buffer was created as a message buffer, in which case it holds discrete messages rather than a stream. */\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
static size_t prvReadBytesFromBuffer( StreamBuffer_t *pxStreamBuffer,\r
uint8_t *pucData,\r
size_t xMaxCount,\r
- size_t xBytesAvailable ); PRIVILEGED_FUNCTION\r
+ size_t xBytesAvailable ) PRIVILEGED_FUNCTION;\r
\r
/*\r
* Called by both pxStreamBufferCreate() and pxStreamBufferCreateStatic() to\r
uint8_t * const pucBuffer,\r
size_t xBufferSizeBytes,\r
size_t xTriggerLevelBytes,\r
- BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION;\r
+ uint8_t ucFlags ) PRIVILEGED_FUNCTION;\r
\r
/*-----------------------------------------------------------*/\r
\r
StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer )\r
{\r
uint8_t *pucAllocatedMemory;\r
+ uint8_t ucFlags;\r
\r
/* In case the stream buffer is going to be used as a message buffer\r
(that is, it will hold discrete messages with a little meta data that\r
says how big the next message is) check the buffer will be large enough\r
to hold at least one message. */\r
- configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH );\r
+ if( xIsMessageBuffer == pdTRUE )\r
+ {\r
+ /* Is a message buffer but not statically allocated. */\r
+ ucFlags = sbFLAGS_IS_MESSAGE_BUFFER;\r
+ configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH );\r
+ }\r
+ else\r
+ {\r
+ /* Not a message buffer and not statically allocated. */\r
+ ucFlags = 0;\r
+ configASSERT( xBufferSizeBytes > 0 );\r
+ }\r
configASSERT( xTriggerLevelBytes <= xBufferSizeBytes );\r
\r
/* A trigger level of 0 would cause a waiting task to unblock even when\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
pucAllocatedMemory + sizeof( StreamBuffer_t ), /* Storage area follows. */ /*lint !e9016 Indexing past structure valid for uint8_t pointer, also storage area has no alignment requirement. */\r
xBufferSizeBytes,\r
xTriggerLevelBytes,\r
- xIsMessageBuffer );\r
+ ucFlags );\r
\r
traceSTREAM_BUFFER_CREATE( ( ( StreamBuffer_t * ) pucAllocatedMemory ), xIsMessageBuffer );\r
}\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
{\r
StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) pxStaticStreamBuffer; /*lint !e740 !e9087 Safe cast as StaticStreamBuffer_t is opaque Streambuffer_t. */\r
StreamBufferHandle_t xReturn;\r
+ uint8_t ucFlags;\r
\r
configASSERT( pucStreamBufferStorageArea );\r
configASSERT( pxStaticStreamBuffer );\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
+ if( xIsMessageBuffer != pdFALSE )\r
+ {\r
+ /* Statically allocated message buffer. */\r
+ ucFlags = sbFLAGS_IS_MESSAGE_BUFFER | sbFLAGS_IS_STATICALLY_ALLOCATED;\r
+ }\r
+ else\r
+ {\r
+ /* Statically allocated stream buffer. */\r
+ ucFlags = sbFLAGS_IS_STATICALLY_ALLOCATED;\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
pucStreamBufferStorageArea,\r
xBufferSizeBytes,\r
xTriggerLevelBytes,\r
- xIsMessageBuffer );\r
+ ucFlags );\r
\r
/* Remember this was statically allocated in case it is ever deleted\r
again. */\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
{\r
/* The structure and buffer were not allocated dynamically and cannot be\r
freed - just scrub the structure so future use will assert. */\r
- memset( pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) );\r
+ ( void ) memset( pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) );\r
}\r
}\r
/*-----------------------------------------------------------*/\r
\r
BaseType_t xStreamBufferReset( 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
-BaseType_t xReturn = pdFAIL, xIsMessageBuffer;\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
+BaseType_t xReturn = pdFAIL;\r
\r
#if( configUSE_TRACE_FACILITY == 1 )\r
UBaseType_t uxStreamBufferNumber;\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
+ if( pxStreamBuffer->xTaskWaitingToSend == NULL )\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
+ pxStreamBuffer->ucFlags );\r
+ xReturn = pdPASS;\r
+\r
+ #if( configUSE_TRACE_FACILITY == 1 )\r
+ {\r
+ pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;\r
+ }\r
+ #endif\r
\r
- #if( configUSE_TRACE_FACILITY == 1 )\r
- {\r
- pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;\r
+ traceSTREAM_BUFFER_RESET( xStreamBuffer );\r
}\r
- #endif\r
-\r
- traceSTREAM_BUFFER_RESET( xStreamBuffer );\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
if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )\r
{\r
xRequiredSpace += sbBYTES_TO_STORE_MESSAGE_LENGTH;\r
+\r
+ /* Overflow? */\r
+ configASSERT( xRequiredSpace > xDataLengthBytes );\r
}\r
else\r
{\r
taskEXIT_CRITICAL();\r
\r
traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer );\r
- ( void ) xTaskNotifyWait( ( uint32_t ) 0, UINT32_MAX, NULL, xTicksToWait );\r
+ ( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );\r
pxStreamBuffer->xTaskWaitingToSend = NULL;\r
\r
} while( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE );\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
/* Wait for data to be available. */\r
traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer );\r
- ( void ) xTaskNotifyWait( ( uint32_t ) 0, UINT32_MAX, NULL, xTicksToWait );\r
+ ( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );\r
pxStreamBuffer->xTaskWaitingToReceive = NULL;\r
\r
/* Recheck the data available after blocking. */\r
}\r
/*-----------------------------------------------------------*/\r
\r
+size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer )\r
+{\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
+size_t xReturn, xBytesAvailable, xOriginalTail;\r
+configMESSAGE_BUFFER_LENGTH_TYPE xTempReturn;\r
+\r
+ configASSERT( pxStreamBuffer );\r
+\r
+ /* Ensure the stream buffer is being used as a message buffer. */\r
+ if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )\r
+ {\r
+ xBytesAvailable = prvBytesInBuffer( pxStreamBuffer );\r
+ if( xBytesAvailable > sbBYTES_TO_STORE_MESSAGE_LENGTH )\r
+ {\r
+ /* The number of bytes available is greater than the number of bytes\r
+ required to hold the length of the next message, so another message\r
+ is available. Return its length without removing the length bytes\r
+ from the buffer. A copy of the tail is stored so the buffer can be\r
+ returned to its prior state as the message is not actually being\r
+ removed from the buffer. */\r
+ xOriginalTail = pxStreamBuffer->xTail;\r
+ ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, xBytesAvailable );\r
+ xReturn = ( size_t ) xTempReturn;\r
+ pxStreamBuffer->xTail = xOriginalTail;\r
+ }\r
+ else\r
+ {\r
+ /* The minimum amount of bytes in a message buffer is\r
+ ( sbBYTES_TO_STORE_MESSAGE_LENGTH + 1 ), so if xBytesAvailable is\r
+ less than sbBYTES_TO_STORE_MESSAGE_LENGTH the only other valid\r
+ value is 0. */\r
+ configASSERT( xBytesAvailable == 0 );\r
+ xReturn = 0;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ xReturn = 0;\r
+ }\r
+\r
+ return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,\r
void *pvRxData,\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
size_t xBytesToStoreMessageLength )\r
{\r
size_t xOriginalTail, xReceivedLength, xNextMessageLength;\r
+configMESSAGE_BUFFER_LENGTH_TYPE xTempNextMessageLength;\r
\r
if( xBytesToStoreMessageLength != ( size_t ) 0 )\r
{\r
returned to its prior state if the length of the message is too\r
large for the provided buffer. */\r
xOriginalTail = pxStreamBuffer->xTail;\r
- ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );\r
+ ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );\r
+ xNextMessageLength = ( size_t ) xTempNextMessageLength;\r
\r
/* Reduce the number of bytes available by the number of bytes just\r
read out. */\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
\r
/* Write as many bytes as can be written in the first write. */\r
configASSERT( ( xNextHead + xFirstLength ) <= pxStreamBuffer->xLength );\r
- memcpy( ( void* ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
+ ( void ) memcpy( ( void* ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
\r
/* If the number of bytes written was less than the number that could be\r
written in the first write... */\r
{\r
/* ...then write the remaining bytes to the start of the buffer. */\r
configASSERT( ( xCount - xFirstLength ) <= pxStreamBuffer->xLength );\r
- memcpy( ( void * ) pxStreamBuffer->pucBuffer, ( const void * ) &( pucData[ xFirstLength ] ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
+ ( void ) memcpy( ( void * ) pxStreamBuffer->pucBuffer, ( const void * ) &( pucData[ xFirstLength ] ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
}\r
else\r
{\r
read. Asserts check bounds of read and write. */\r
configASSERT( xFirstLength <= xMaxCount );\r
configASSERT( ( xNextTail + xFirstLength ) <= pxStreamBuffer->xLength );\r
- memcpy( ( void * ) pucData, ( const void * ) &( pxStreamBuffer->pucBuffer[ xNextTail ] ), xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
+ ( void ) memcpy( ( void * ) pucData, ( const void * ) &( pxStreamBuffer->pucBuffer[ xNextTail ] ), xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
\r
/* If the total number of wanted bytes is greater than the number\r
that could be read in the first read... */\r
{\r
/*...then read the remaining bytes from the start of the buffer. */\r
configASSERT( xCount <= xMaxCount );\r
- memcpy( ( void * ) &( pucData[ xFirstLength ] ), ( void * ) ( pxStreamBuffer->pucBuffer ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
+ ( void ) memcpy( ( void * ) &( pucData[ xFirstLength ] ), ( void * ) ( pxStreamBuffer->pucBuffer ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
}\r
else\r
{\r
uint8_t * const pucBuffer,\r
size_t xBufferSizeBytes,\r
size_t xTriggerLevelBytes,\r
- BaseType_t xIsMessageBuffer )\r
+ uint8_t ucFlags )\r
{\r
/* Assert here is deliberately writing to the entire buffer to ensure it can\r
be written to without generating exceptions, and is setting the buffer to a\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
+ ( void ) memset( ( void * ) pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); /*lint !e9087 memset() requires void *. */\r
pxStreamBuffer->pucBuffer = pucBuffer;\r
pxStreamBuffer->xLength = xBufferSizeBytes;\r
pxStreamBuffer->xTriggerLevelBytes = xTriggerLevelBytes;\r
-\r
- if( xIsMessageBuffer != pdFALSE )\r
- {\r
- pxStreamBuffer->ucFlags |= sbFLAGS_IS_MESSAGE_BUFFER;\r
- }\r
+ pxStreamBuffer->ucFlags = ucFlags;\r
}\r
\r
#if ( configUSE_TRACE_FACILITY == 1 )\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