Skip to content

Commit 3372cd5

Browse files
fix deprecated volatile compound assignment (#152)
* fixed deprecated volatile compound assignment C++20 deprecates some undefined or unclear use cases of 'volatile' like compound assignments and compliant compilers warn about those deprecated operations. In vStreamBufferMoveMid the deprecated compound assignment and other direct accesses to volatile 'StreamBuffer_t->uxMid' is replaced using a local variable stored back when done. * Uncrustify Co-authored-by: Aniruddha Kanhere <[email protected]> Co-authored-by: Aniruddha Kanhere <[email protected]>
1 parent c2a7066 commit 3372cd5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

include/FreeRTOS_Stream_Buffer.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,22 @@
163163
{
164164
/* Increment uxMid, but no further than uxHead */
165165
size_t uxSize = uxStreamBufferMidSpace( pxBuffer );
166+
size_t uxMid = pxBuffer->uxMid;
166167
size_t uxMoveCount = uxCount;
167168

168169
if( uxMoveCount > uxSize )
169170
{
170171
uxMoveCount = uxSize;
171172
}
172173

173-
pxBuffer->uxMid += uxMoveCount;
174+
uxMid += uxMoveCount;
174175

175-
if( pxBuffer->uxMid >= pxBuffer->LENGTH )
176+
if( uxMid >= pxBuffer->LENGTH )
176177
{
177-
pxBuffer->uxMid -= pxBuffer->LENGTH;
178+
uxMid -= pxBuffer->LENGTH;
178179
}
180+
181+
pxBuffer->uxMid = uxMid;
179182
}
180183
/*-----------------------------------------------------------*/
181184

0 commit comments

Comments
 (0)