summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorarminker <[email protected]>2021-07-20 15:47:03 +0800
committerarminker <[email protected]>2021-07-20 15:47:03 +0800
commit2439232c8a81a906bc119f12ed86bada0ed4df42 (patch)
treeebd8d7f9c885739c77796ad157176709ec0d2809 /components
parent55f7d651c58c0ffc499f519037990d739dfbc4bb (diff)
bugfix:write_index bug in rt_ringbuffer_put_force
Diffstat (limited to 'components')
-rw-r--r--components/drivers/src/ringbuffer.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c
index 29de20b087..f01a594609 100644
--- a/components/drivers/src/ringbuffer.c
+++ b/components/drivers/src/ringbuffer.c
@@ -8,6 +8,7 @@
* 2012-09-30 Bernard first version.
* 2013-05-08 Grissiom reimplement
* 2016-08-18 heyuanjie add interface
+ * 2021-07-20 arminker fix write_index bug in function rt_ringbuffer_put_force
*/
#include <rtthread.h>
@@ -138,7 +139,8 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb,
if (length > space_length)
{
- rb->read_mirror = ~rb->read_mirror;
+ if (rb->write_index <= rb->read_index)
+ rb->read_mirror = ~rb->read_mirror;
rb->read_index = rb->write_index;
}