From 7a181a8d474174c8708e9c8c8d41561133ee2623 Mon Sep 17 00:00:00 2001 From: arminker Date: Tue, 20 Jul 2021 13:09:25 +0800 Subject: [PATCH 1/3] bugfix:fix write_index bug in rt_ringbuffer_put_force --- components/drivers/src/ringbuffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c index 29de20b087..80fa940f86 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 @@ -138,7 +139,9 @@ 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; } -- Gitee From e50be7a84f3507693dda922fa05b838d8acc8cc5 Mon Sep 17 00:00:00 2001 From: arminker Date: Tue, 20 Jul 2021 13:47:20 +0800 Subject: [PATCH 2/3] fixbug:write_index bug in rt_ringbuffer_put_force --- components/drivers/src/ringbuffer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c index 80fa940f86..0d40564690 100644 --- a/components/drivers/src/ringbuffer.c +++ b/components/drivers/src/ringbuffer.c @@ -139,9 +139,8 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb, if (length > space_length) { - if(rb->write_index <= rb->read_index) - 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; } -- Gitee From a7f4ca880d39eb01ebbd19735cd8c39daadf9a6a Mon Sep 17 00:00:00 2001 From: arminker Date: Tue, 20 Jul 2021 06:19:57 +0000 Subject: [PATCH 3/3] update components/drivers/src/ringbuffer.c. code format --- components/drivers/src/ringbuffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c index 0d40564690..7c08678f6d 100644 --- a/components/drivers/src/ringbuffer.c +++ b/components/drivers/src/ringbuffer.c @@ -139,8 +139,8 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb, if (length > space_length) { - if(rb->write_index <= rb->read_index) - 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; } -- Gitee