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


##########
fs/vfs/fs_write.c:
##########
@@ -68,35 +68,36 @@ static ssize_t file_writev_compat(FAR struct file *filep,
     {
       /* Ignore zero-length writes */
 
-      if (iov[i].iov_len > 0)
+      if (iov[i].iov_len == 0)
         {
-          buffer    = iov[i].iov_base;
-          remaining = iov[i].iov_len;
+          continue;
+        }
+
+      buffer    = iov[i].iov_base;
+      remaining = iov[i].iov_len;
 
-          /* Write repeatedly as necessary to write the entire buffer */
+      nwritten = inode->u.i_ops->write(filep, (void *)buffer, remaining);
 
-          do
-            {
-              nwritten = inode->u.i_ops->write(filep, (void *)buffer,
-                                                      remaining);
+      /* Check for a write error */
 
-              /* Check for a write error */
+      if (nwritten < 0)
+        {
+          return ntotal ? ntotal : nwritten;
+        }
 
-              if (nwritten < 0)
-                {
-                  return ntotal ? ntotal : nwritten;
-                }
+      ntotal    += nwritten;

Review Comment:
   ```suggestion
         ntotal += nwritten;
   ```



##########
fs/vfs/fs_read.c:
##########
@@ -68,42 +68,36 @@ static ssize_t file_readv_compat(FAR struct file *filep,
     {
       /* Ignore zero-length reads */
 
-      if (iov[i].iov_len > 0)
+      if (iov[i].iov_len == 0)
         {
-          buffer    = iov[i].iov_base;
-          remaining = iov[i].iov_len;
-
-          /* Read repeatedly as necessary to fill buffer */
+          continue;
+        }
 
-          do
-            {
-              nread = inode->u.i_ops->read(filep, (void *)buffer,
-                                                  remaining);
+      buffer    = iov[i].iov_base;
+      remaining = iov[i].iov_len;
 
-              /* Check for a read error */
+      nread = inode->u.i_ops->read(filep, (void *)buffer, remaining);
 
-              if (nread < 0)
-                {
-                  return ntotal ? ntotal : nread;
-                }
+      /* Check for a read error */
 
-              /* Check for an end-of-file condition */
+      if (nread < 0)
+        {
+          return ntotal ? ntotal : nread;
+        }
 
-              else if (nread == 0)
-                {
-                  return ntotal;
-                }
+      ntotal    += nread;

Review Comment:
   ```suggestion
         ntotal += nread;
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to