mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-13 01:27:48 -04:00
Improve comments and assertions in stream buffer
This commit is contained in:
parent
66b3f908df
commit
927204a493
1 changed files with 17 additions and 25 deletions
|
@ -49,7 +49,7 @@
|
||||||
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */
|
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */
|
||||||
|
|
||||||
/* If the user has not provided application specific Rx notification macros,
|
/* If the user has not provided application specific Rx notification macros,
|
||||||
* or #defined the notification macros away, them provide default implementations
|
* or #defined the notification macros away, then provide default implementations
|
||||||
* that uses task notifications. */
|
* that uses task notifications. */
|
||||||
/*lint -save -e9026 Function like macros allowed and needed here so they can be overridden. */
|
/*lint -save -e9026 Function like macros allowed and needed here so they can be overridden. */
|
||||||
#ifndef sbRECEIVE_COMPLETED
|
#ifndef sbRECEIVE_COMPLETED
|
||||||
|
@ -268,7 +268,6 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
|
||||||
pucAllocatedMemory = NULL;
|
pucAllocatedMemory = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( pucAllocatedMemory != NULL )
|
if( pucAllocatedMemory != NULL )
|
||||||
{
|
{
|
||||||
prvInitialiseNewStreamBuffer( ( StreamBuffer_t * ) pucAllocatedMemory, /* Structure at the start of the allocated memory. */ /*lint !e9087 Safe cast as allocated memory is aligned. */ /*lint !e826 Area is not too small and alignment is guaranteed provided malloc() behaves as expected and returns aligned buffer. */
|
prvInitialiseNewStreamBuffer( ( StreamBuffer_t * ) pucAllocatedMemory, /* Structure at the start of the allocated memory. */ /*lint !e9087 Safe cast as allocated memory is aligned. */ /*lint !e826 Area is not too small and alignment is guaranteed provided malloc() behaves as expected and returns aligned buffer. */
|
||||||
|
@ -340,27 +339,19 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
|
||||||
} /*lint !e529 xSize is referenced is configASSERT() is defined. */
|
} /*lint !e529 xSize is referenced is configASSERT() is defined. */
|
||||||
#endif /* configASSERT_DEFINED */
|
#endif /* configASSERT_DEFINED */
|
||||||
|
|
||||||
if( ( pucStreamBufferStorageArea != NULL ) && ( pxStaticStreamBuffer != NULL ) )
|
prvInitialiseNewStreamBuffer( pxStreamBuffer,
|
||||||
{
|
pucStreamBufferStorageArea,
|
||||||
prvInitialiseNewStreamBuffer( pxStreamBuffer,
|
xBufferSizeBytes,
|
||||||
pucStreamBufferStorageArea,
|
xTriggerLevelBytes,
|
||||||
xBufferSizeBytes,
|
ucFlags );
|
||||||
xTriggerLevelBytes,
|
|
||||||
ucFlags );
|
|
||||||
|
|
||||||
/* Remember this was statically allocated in case it is ever deleted
|
/* Remember this was statically allocated in case it is ever deleted
|
||||||
* again. */
|
* again. */
|
||||||
pxStreamBuffer->ucFlags |= sbFLAGS_IS_STATICALLY_ALLOCATED;
|
pxStreamBuffer->ucFlags |= sbFLAGS_IS_STATICALLY_ALLOCATED;
|
||||||
|
|
||||||
traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer );
|
traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer );
|
||||||
|
|
||||||
xReturn = ( StreamBufferHandle_t ) pxStaticStreamBuffer; /*lint !e9087 Data hiding requires cast to opaque type. */
|
xReturn = ( StreamBufferHandle_t ) pxStaticStreamBuffer; /*lint !e9087 Data hiding requires cast to opaque type. */
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xReturn = NULL;
|
|
||||||
traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer );
|
|
||||||
}
|
|
||||||
|
|
||||||
return xReturn;
|
return xReturn;
|
||||||
}
|
}
|
||||||
|
@ -466,7 +457,7 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
|
||||||
|
|
||||||
/* The trigger level is the number of bytes that must be in the stream
|
/* The trigger level is the number of bytes that must be in the stream
|
||||||
* buffer before a task that is waiting for data is unblocked. */
|
* buffer before a task that is waiting for data is unblocked. */
|
||||||
if( xTriggerLevel <= pxStreamBuffer->xLength )
|
if( xTriggerLevel < pxStreamBuffer->xLength )
|
||||||
{
|
{
|
||||||
pxStreamBuffer->xTriggerLevelBytes = xTriggerLevel;
|
pxStreamBuffer->xTriggerLevelBytes = xTriggerLevel;
|
||||||
xReturn = pdPASS;
|
xReturn = pdPASS;
|
||||||
|
@ -525,14 +516,15 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
|
||||||
size_t xReturn, xSpace = 0;
|
size_t xReturn, xSpace = 0;
|
||||||
size_t xRequiredSpace = xDataLengthBytes;
|
size_t xRequiredSpace = xDataLengthBytes;
|
||||||
TimeOut_t xTimeOut;
|
TimeOut_t xTimeOut;
|
||||||
|
size_t xMaxReportedSpace = 0;
|
||||||
/* The maximum amount of space a stream buffer will ever report is its length
|
|
||||||
* minus 1. */
|
|
||||||
const size_t xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1;
|
|
||||||
|
|
||||||
configASSERT( pvTxData );
|
configASSERT( pvTxData );
|
||||||
configASSERT( pxStreamBuffer );
|
configASSERT( pxStreamBuffer );
|
||||||
|
|
||||||
|
/* The maximum amount of space a stream buffer will ever report is its length
|
||||||
|
* minus 1. */
|
||||||
|
xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1;
|
||||||
|
|
||||||
/* This send function is used to write to both message buffers and stream
|
/* This send function is used to write to both message buffers and stream
|
||||||
* buffers. If this is a message buffer then the space needed must be
|
* buffers. If this is a message buffer then the space needed must be
|
||||||
* increased by the amount of bytes needed to store the length of the
|
* increased by the amount of bytes needed to store the length of the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue