From 4a03cab6f946986d5ca0deac478f48732dd012c8 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 29 Apr 2022 02:53:40 +0800 Subject: [PATCH] libc: Remove the redundant seek in writev since the file position isn't changed if write return fail Signed-off-by: Xiang Xiao --- 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 02b9fc03269..b8df8ff414d 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; }