[PATCH v4 5/6] virFileInData: preserve errno in cleanup path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Callers might be interested in the original value of errno. Let's
not overwrite it with lseek() done in cleanup path.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/util/virfile.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index d444b32f8..2be64f1db 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3900,8 +3900,11 @@ virFileInData(int fd,
     ret = 0;
  cleanup:
     /* At any rate, reposition back to where we started. */
-    if (cur != (off_t) -1)
+    if (cur != (off_t) -1) {
+        int save_errno = errno;
         ignore_value(lseek(fd, cur, SEEK_SET));
+        errno = save_errno;
+    }
     return ret;
 }
 
-- 
2.13.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux