[PATCH 1/5] lxc: virLXCProcessReadLogOutput: Automatically close FD

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

 



Switch to 'VIR_AUTOCLOSE' to simplify cleanup.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/lxc/lxc_process.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index fe5cab3df6..39dcf53c67 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1076,8 +1076,7 @@ virLXCProcessReadLogOutput(virDomainObj *vm,
                            char *buf,
                            size_t buflen)
 {
-    int fd = -1;
-    int ret;
+    VIR_AUTOCLOSE fd = -1;

     if ((fd = open(logfile, O_RDONLY)) < 0) {
         virReportSystemError(errno,
@@ -1090,17 +1089,10 @@ virLXCProcessReadLogOutput(virDomainObj *vm,
         virReportSystemError(errno,
                              _("Unable to seek log file %s to %llu"),
                              logfile, (unsigned long long)pos);
-        VIR_FORCE_CLOSE(fd);
         return -1;
     }

-    ret = virLXCProcessReadLogOutputData(vm,
-                                         fd,
-                                         buf,
-                                         buflen);
-
-    VIR_FORCE_CLOSE(fd);
-    return ret;
+    return virLXCProcessReadLogOutputData(vm, fd, buf, buflen);
 }


-- 
2.37.1




[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