Skip to content

Commit 7de647c

Browse files
authored
Merge pull request #4904 from rtthread-bot/rtt_bot
[update] RT-Thread Robot automatic submission
2 parents d57caa7 + 26acd64 commit 7de647c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/drivers/src/ringbuffer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* 2012-09-30 Bernard first version.
99
* 2013-05-08 Grissiom reimplement
1010
* 2016-08-18 heyuanjie add interface
11+
* 2021-07-20 arminker fix write_index bug in function rt_ringbuffer_put_force
1112
*/
1213

1314
#include <rtthread.h>
@@ -138,7 +139,8 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb,
138139

139140
if (length > space_length)
140141
{
141-
rb->read_mirror = ~rb->read_mirror;
142+
if (rb->write_index <= rb->read_index)
143+
rb->read_mirror = ~rb->read_mirror;
142144
rb->read_index = rb->write_index;
143145
}
144146

0 commit comments

Comments
 (0)