diff --git a/include/nuttx/mm/iob.h b/include/nuttx/mm/iob.h index ede9816f9e..326597753c 100644 --- a/include/nuttx/mm/iob.h +++ b/include/nuttx/mm/iob.h @@ -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 diff --git a/mm/iob/iob_clone.c b/mm/iob/iob_clone.c index 166c9692c9..9f34221e6f 100644 --- a/mm/iob/iob_clone.c +++ b/mm/iob/iob_clone.c @@ -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);