1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-28 11:21:44 +03:00

virsocket: Don't preserve errno in virSocketRecvFD()

When setting O_CLOEXEC flag on received FD fails the FD is closed
using VIR_FORCE_CLOSE(). But the call is wrapped in errno save
which is not necessary because VIR_FORCE_CLOSE() preserves  errno
value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2021-08-20 10:41:41 +02:00
parent 247e8fcc6a
commit 9f33a6dcb4

View File

@ -477,9 +477,7 @@ virSocketRecvFD(int sock, int fdflags)
/* set close-on-exec flag */
if (!MSG_CMSG_CLOEXEC && (fdflags & O_CLOEXEC)) {
if (virSetCloseExec(fd) < 0) {
int saved_errno = errno;
VIR_FORCE_CLOSE(fd);
errno = saved_errno;
return -1;
}
}