This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 81825bc003 mm/circbuf: fix minor issue about update buffer head
81825bc003 is described below

commit 81825bc0038f9add808148225da621f6ed8c6d6a
Author: dongjiuzhu1 <dongjiuz...@xiaomi.com>
AuthorDate: Mon Feb 27 17:34:15 2023 +0800

    mm/circbuf: fix minor issue about update buffer head
    
    update head pointer with skip before write buffer.
    
    Signed-off-by: dongjiuzhu1 <dongjiuz...@xiaomi.com>
---
 mm/circbuf/circbuf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/circbuf/circbuf.c b/mm/circbuf/circbuf.c
index e703902190..7de8b46bf8 100644
--- a/mm/circbuf/circbuf.c
+++ b/mm/circbuf/circbuf.c
@@ -526,6 +526,7 @@ ssize_t circbuf_overwrite(FAR struct circbuf_s *circ,
       overwrite = bytes - space + skip;
     }
 
+  circ->head += skip;
   off = circ->head % circ->size;
   space = circ->size - off;
   if (bytes < space)
@@ -535,7 +536,7 @@ ssize_t circbuf_overwrite(FAR struct circbuf_s *circ,
 
   memcpy((FAR char *)circ->base + off, src, space);
   memcpy(circ->base, (FAR char *)src + space, bytes - space);
-  circ->head += bytes + skip;
+  circ->head += bytes;
   circ->tail += overwrite;
 
   return overwrite;

Reply via email to