pkarashchenko commented on code in PR #7870: URL: https://github.com/apache/nuttx/pull/7870#discussion_r1048881026
########## mm/iob/iob_clone.c: ########## @@ -137,26 +225,37 @@ int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled) * transferred? */ - if (offset2 >= CONFIG_IOB_BUFSIZE && iob1 != NULL) + if (offset2 >= (CONFIG_IOB_BUFSIZE - iob2->io_offset) && + iob1 != NULL) { - FAR struct iob_s *next; - - /* Allocate new destination I/O buffer and hook it into the - * destination I/O buffer chain. - */ - - next = iob_alloc(throttled); - if (!next) + ret = iob_next(iob2, throttled, block); + if (ret < 0) { - ioberr("ERROR: Failed to allocate an I/O buffer\n"); - return -ENOMEM; + return ret; } - iob2->io_flink = next; - iob2 = next; + iob2 = iob2->io_flink; offset2 = 0; } } return 0; } + +/**************************************************************************** + * Name: iob_clone + * + * Description: + * Duplicate (and pack) the data in iob1 in iob2. iob2 must be empty. + * + ****************************************************************************/ + +int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, + bool throttled, bool block) +{ + DEBUGASSERT(iob2->io_len == 0 && iob2->io_offset == 0 && + iob2->io_pktlen == 0 && iob2->io_flink == NULL); Review Comment: ```suggestion DEBUGASSERT(iob2->io_len == 0 && iob2->io_offset == 0 && iob2->io_pktlen == 0 && iob2->io_flink == NULL); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org