mm/circbuf: fix minor issue about update buffer head

update head pointer with skip before write buffer.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1
2023-02-27 17:34:15 +08:00
committed by Xiang Xiao
parent b178ce4da9
commit 81825bc003
+2 -1
View File
@@ -526,6 +526,7 @@ ssize_t circbuf_overwrite(FAR struct circbuf_s *circ,
overwrite = bytes - space + skip; overwrite = bytes - space + skip;
} }
circ->head += skip;
off = circ->head % circ->size; off = circ->head % circ->size;
space = circ->size - off; space = circ->size - off;
if (bytes < space) 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((FAR char *)circ->base + off, src, space);
memcpy(circ->base, (FAR char *)src + space, bytes - space); memcpy(circ->base, (FAR char *)src + space, bytes - space);
circ->head += bytes + skip; circ->head += bytes;
circ->tail += overwrite; circ->tail += overwrite;
return overwrite; return overwrite;