Switch to 'VIR_AUTOCLOSE' to simplify cleanup.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
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