git: 2f363febf8bf - main - tests: unix: pull a recvfd_payload_cmsg out of recvfd_payload
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 19 Jun 2026 04:05:11 UTC
The branch main has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=2f363febf8bf5c3e9ffad95b5998b461adc77c28
commit 2f363febf8bf5c3e9ffad95b5998b461adc77c28
Author: Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2026-06-19 04:03:30 +0000
Commit: Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2026-06-19 04:03:30 +0000
tests: unix: pull a recvfd_payload_cmsg out of recvfd_payload
This is almost a trivial factoring, but it's still a bit of boilerplate
that we don't care to rewrite- the SO_PASSRIGHTS test will still receive
some data, so the iovec construction still saves us a few lines.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D57544
---
tests/sys/kern/unix_passfd_test.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/tests/sys/kern/unix_passfd_test.c b/tests/sys/kern/unix_passfd_test.c
index 66bb406ea14e..2ad40582d058 100644
--- a/tests/sys/kern/unix_passfd_test.c
+++ b/tests/sys/kern/unix_passfd_test.c
@@ -208,13 +208,27 @@ localcreds(int sockfd)
return (val != 0);
}
+static ssize_t
+recvfd_payload_cmsg(int sockfd, void *buf, size_t buflen, struct msghdr *msghdr,
+ int recvmsg_flags)
+{
+ struct iovec iovec;
+
+ iovec.iov_base = buf;
+ iovec.iov_len = buflen;
+
+ msghdr->msg_iov = &iovec;
+ msghdr->msg_iovlen = 1;
+
+ return (recvmsg(sockfd, msghdr, recvmsg_flags));
+}
+
static ssize_t
recvfd_payload(int sockfd, int *recv_fd, void *buf, size_t buflen,
size_t cmsgsz, int recvmsg_flags)
{
struct cmsghdr *cmsghdr;
struct msghdr msghdr;
- struct iovec iovec;
char *message;
ssize_t len;
bool foundcreds;
@@ -226,13 +240,7 @@ recvfd_payload(int sockfd, int *recv_fd, void *buf, size_t buflen,
msghdr.msg_control = message;
msghdr.msg_controllen = cmsgsz;
- iovec.iov_base = buf;
- iovec.iov_len = buflen;
-
- msghdr.msg_iov = &iovec;
- msghdr.msg_iovlen = 1;
-
- len = recvmsg(sockfd, &msghdr, recvmsg_flags);
+ len = recvfd_payload_cmsg(sockfd, buf, buflen, &msghdr, recvmsg_flags);
ATF_REQUIRE_MSG(len != -1, "recvmsg failed: %s", strerror(errno));
cmsghdr = CMSG_FIRSTHDR(&msghdr);