xiaoxiang781216 commented on code in PR #14898:
URL: https://github.com/apache/nuttx/pull/14898#discussion_r1914428146


##########
fs/vfs/fs_uio.c:
##########
@@ -51,18 +51,69 @@ ssize_t uio_total_len(FAR const struct uio *uio)
 {
   const struct iovec *iov = uio->uio_iov;
   int iovcnt = uio->uio_iovcnt;
+  size_t offset_in_iov = uio->uio_offset_in_iov;
   size_t len = 0;
   int i;
 
   for (i = 0; i < iovcnt; i++)
     {
-      if (SSIZE_MAX - len < iov[i].iov_len)
+      DEBUGASSERT(offset_in_iov <= iov[i].iov_len);
+      if (SSIZE_MAX - len < iov[i].iov_len - offset_in_iov)
         {
           return -EOVERFLOW;
         }
 
-      len += iov[i].iov_len;
+      len += iov[i].iov_len - offset_in_iov;
+      offset_in_iov = 0;
     }
 
   return len;
 }
+
+/****************************************************************************
+ * Name: uio_advance
+ *
+ * Description:
+ *   Advance the pointer/offset in uio by the specified amount.
+ *
+ ****************************************************************************/
+
+void uio_advance(FAR struct uio *uio, size_t sz)
+{
+  FAR const struct iovec *iov = uio->uio_iov;
+  int iovcnt = uio->uio_iovcnt;
+  size_t offset_in_iov = uio->uio_offset_in_iov;
+
+  DEBUGASSERT(sz <= uio_total_len(uio));
+  while (iovcnt > 0)
+    {
+      DEBUGASSERT(offset_in_iov <= iov->iov_len);
+      if (sz < iov->iov_len - offset_in_iov)
+        {
+          offset_in_iov += sz;
+          break;
+        }
+
+      sz -= iov->iov_len;

Review Comment:
   please recognize your patchset to sqaush the intermediate change.



-- 
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

Reply via email to