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:
parent
1920ff31d3
commit
33bd797bb3
|
@ -301,12 +301,12 @@ ssize_t circbuf_peekat(FAR struct circbuf_s *circ, size_t pos,
|
|||
|
||||
DEBUGASSERT(circ);
|
||||
|
||||
if (!circ->size)
|
||||
if (!circ->size || pos >= circ->head)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = circbuf_used(circ);
|
||||
len = circ->head - pos;
|
||||
off = pos % circ->size;
|
||||
|
||||
if (bytes > len)
|
||||
|
|
Loading…
Reference in New Issue