]> git.sur5r.net Git - freertos/commitdiff
Fix issues whereby vStreamBufferReset() clobbered the flag that indicated the stream...
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 20 Jun 2018 21:21:55 +0000 (21:21 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 20 Jun 2018 21:21:55 +0000 (21:21 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2554 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/stream_buffer.c

index 8d0e3a523d142f7af58e7ed5efa3fb54e3a85f03..158e17763fb385b28f5df7b6fb140357d375291a 100644 (file)
@@ -210,7 +210,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
                                                                                  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
@@ -219,6 +219,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
        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
@@ -226,10 +227,14 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
                to hold at least one message. */\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
@@ -258,7 +263,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
                                                                                   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
@@ -283,6 +288,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
        {\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
@@ -295,6 +301,17 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
                        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
                (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
@@ -317,7 +334,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
                                                                                  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
@@ -375,7 +392,7 @@ StreamBuffer_t * pxStreamBuffer = xStreamBuffer;
 BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )\r
 {\r
 StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
-BaseType_t xReturn = pdFAIL, xIsMessageBuffer;\r
+BaseType_t xReturn = pdFAIL;\r
 \r
 #if( configUSE_TRACE_FACILITY == 1 )\r
        UBaseType_t uxStreamBufferNumber;\r
@@ -398,20 +415,11 @@ BaseType_t xReturn = pdFAIL, xIsMessageBuffer;
                {\r
                        if( pxStreamBuffer->xTaskWaitingToSend == NULL )\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
+                                                                                         pxStreamBuffer->ucFlags );\r
                                xReturn = pdPASS;\r
 \r
                                #if( configUSE_TRACE_FACILITY == 1 )\r
@@ -1202,7 +1210,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
                                                                                  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
@@ -1221,11 +1229,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
        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