You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/05/01 07:07:43 UTC

[incubator-nuttx] branch master updated: libc: Remove the redundant seek in writev

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 4a03cab6f9 libc: Remove the redundant seek in writev
4a03cab6f9 is described below

commit 4a03cab6f946986d5ca0deac478f48732dd012c8
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Apr 29 02:53:40 2022 +0800

    libc: Remove the redundant seek in writev
    
    since the file position isn't changed if write return fail
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 libs/libc/uio/lib_writev.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/libs/libc/uio/lib_writev.c b/libs/libc/uio/lib_writev.c
index 02b9fc0326..b8df8ff414 100644
--- a/libs/libc/uio/lib_writev.c
+++ b/libs/libc/uio/lib_writev.c
@@ -78,13 +78,8 @@ ssize_t writev(int fildes, FAR const struct iovec *iov, int iovcnt)
   ssize_t nwritten;
   size_t remaining;
   FAR uint8_t *buffer;
-  off_t pos;
   int i;
 
-  /* Get the current file position in case we have to reset it */
-
-  pos = lseek(fildes, 0, SEEK_CUR);
-
   /* Process each entry in the struct iovec array */
 
   for (i = 0, ntotal = 0; i < iovcnt; i++)
@@ -108,21 +103,6 @@ ssize_t writev(int fildes, FAR const struct iovec *iov, int iovcnt)
 
               if (nwritten < 0)
                 {
-                  if (pos != (off_t)-1)
-                    {
-                      /* Save the errno value */
-
-                      int save = get_errno();
-
-                      /* Restore the file position */
-
-                      lseek(fildes, pos, SEEK_SET);
-
-                      /* Restore the errno value */
-
-                      set_errno(save);
-                    }
-
                   return ntotal ? ntotal : ERROR;
                 }