Skip to content

Commit 755daad

Browse files
Improve comments and assertions in stream buffer (#277)
* Improve comments and assertions in stream buffer * Add back null check instead of assert * Adding config assert back
1 parent 66b3f90 commit 755daad

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

stream_buffer.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */
5050

5151
/* If the user has not provided application specific Rx notification macros,
52-
* or #defined the notification macros away, them provide default implementations
52+
* or #defined the notification macros away, then provide default implementations
5353
* that uses task notifications. */
5454
/*lint -save -e9026 Function like macros allowed and needed here so they can be overridden. */
5555
#ifndef sbRECEIVE_COMPLETED
@@ -267,7 +267,6 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
267267
{
268268
pucAllocatedMemory = NULL;
269269
}
270-
271270

272271
if( pucAllocatedMemory != NULL )
273272
{
@@ -466,7 +465,7 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
466465

467466
/* The trigger level is the number of bytes that must be in the stream
468467
* buffer before a task that is waiting for data is unblocked. */
469-
if( xTriggerLevel <= pxStreamBuffer->xLength )
468+
if( xTriggerLevel < pxStreamBuffer->xLength )
470469
{
471470
pxStreamBuffer->xTriggerLevelBytes = xTriggerLevel;
472471
xReturn = pdPASS;
@@ -525,14 +524,15 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
525524
size_t xReturn, xSpace = 0;
526525
size_t xRequiredSpace = xDataLengthBytes;
527526
TimeOut_t xTimeOut;
528-
529-
/* The maximum amount of space a stream buffer will ever report is its length
530-
* minus 1. */
531-
const size_t xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1;
527+
size_t xMaxReportedSpace = 0;
532528

533529
configASSERT( pvTxData );
534530
configASSERT( pxStreamBuffer );
535531

532+
/* The maximum amount of space a stream buffer will ever report is its length
533+
* minus 1. */
534+
xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1;
535+
536536
/* This send function is used to write to both message buffers and stream
537537
* buffers. If this is a message buffer then the space needed must be
538538
* increased by the amount of bytes needed to store the length of the

0 commit comments

Comments
 (0)