After previous cleanups, virSocketSendFD() is but a thin wrapper
over virSocketSendMsgWithFDs(). Replace the body of the former
with a call to the latter.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virsocket.c | 28 +++-------------------------
1 file changed, 3 insertions(+), 25 deletions(-)
diff --git a/src/util/virsocket.c b/src/util/virsocket.c
index a7272a3ec9..c4e214e76a 100644
--- a/src/util/virsocket.c
+++ b/src/util/virsocket.c
@@ -388,32 +388,10 @@ int
virSocketSendFD(int sock, int fd)
{
char byte = 0;
- struct iovec iov;
- struct msghdr msg = { 0 };
- struct cmsghdr *cmsg;
- char buf[CMSG_SPACE(sizeof(fd))];
+ int fds[] = { fd };
- /* send at least one char */
- iov.iov_base = &byte;
- iov.iov_len = 1;
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
- msg.msg_name = NULL;
- msg.msg_namelen = 0;
-
- msg.msg_control = buf;
- msg.msg_controllen = sizeof(buf);
- cmsg = CMSG_FIRSTHDR(&msg);
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
- /* Initialize the payload: */
- memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
- msg.msg_controllen = cmsg->cmsg_len;
-
- if (sendmsg(sock, &msg, 0) != iov.iov_len)
- return -1;
- return 0;
+ return virSocketSendMsgWithFDs(sock, &byte, sizeof(byte),
+ fds, G_N_ELEMENTS(fds));
}
--
2.43.0