mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
mm/circbuf: skip buffer content according position in circbuf_peekat
The circbuf_peekat should copy valid content from the specfied position of buffer, so skip the area from this position to the tail. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
@@ -301,12 +301,12 @@ ssize_t circbuf_peekat(FAR struct circbuf_s *circ, size_t pos,
|
|||||||
|
|
||||||
DEBUGASSERT(circ);
|
DEBUGASSERT(circ);
|
||||||
|
|
||||||
if (!circ->size)
|
if (!circ->size || pos >= circ->head)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = circbuf_used(circ);
|
len = circ->head - pos;
|
||||||
off = pos % circ->size;
|
off = pos % circ->size;
|
||||||
|
|
||||||
if (bytes > len)
|
if (bytes > len)
|
||||||
|
|||||||
Reference in New Issue
Block a user