mm/iob: Support neg offset in iob_clone
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
fb861c0a29
commit
cd1decf4a5
@ -476,8 +476,8 @@ int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2,
|
||||
****************************************************************************/
|
||||
|
||||
int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
|
||||
unsigned int offset1, FAR struct iob_s *iob2,
|
||||
unsigned int offset2, bool throttled, bool block);
|
||||
int offset1, FAR struct iob_s *iob2,
|
||||
int offset2, bool throttled, bool block);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iob_concat
|
||||
|
@ -109,8 +109,8 @@ static int iob_next(FAR struct iob_s *iob, bool throttled, bool block)
|
||||
****************************************************************************/
|
||||
|
||||
int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
|
||||
unsigned int offset1, FAR struct iob_s *iob2,
|
||||
unsigned int offset2, bool throttled, bool block)
|
||||
int offset1, FAR struct iob_s *iob2,
|
||||
int offset2, bool throttled, bool block)
|
||||
{
|
||||
FAR uint8_t *src;
|
||||
FAR uint8_t *dest;
|
||||
@ -129,7 +129,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
|
||||
* the list, Skip I/O buffer containing the data offset.
|
||||
*/
|
||||
|
||||
while (iob1 != NULL && offset1 >= iob1->io_len)
|
||||
while (iob1 != NULL && (int)(offset1 - iob1->io_len) >= 0)
|
||||
{
|
||||
offset1 -= iob1->io_len;
|
||||
iob1 = iob1->io_flink;
|
||||
@ -195,7 +195,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
|
||||
|
||||
/* Have we taken all of the data from the source I/O buffer? */
|
||||
|
||||
if (offset1 >= iob1->io_len)
|
||||
if ((int)(offset1 - iob1->io_len) >= 0)
|
||||
{
|
||||
/* Skip over empty entries in the chain (there should not be any
|
||||
* but just to be safe).
|
||||
@ -218,7 +218,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
|
||||
* transferred?
|
||||
*/
|
||||
|
||||
if (offset2 >= (CONFIG_IOB_BUFSIZE - iob2->io_offset) &&
|
||||
if ((int)(offset2 + iob2->io_offset - CONFIG_IOB_BUFSIZE) >= 0 &&
|
||||
iob1 != NULL)
|
||||
{
|
||||
ret = iob_next(iob2, throttled, block);
|
||||
|
Loading…
Reference in New Issue
Block a user