mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
lxc: virLXCProcessReadLogOutput: Automatically close FD
Switch to 'VIR_AUTOCLOSE' to simplify cleanup. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b0c680853a
commit
68d5617c3c
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user