_cleanup_close_ int input_fd = -EBADF, mount_tree_fd = -EBADF;
Context context = {};
struct iovec_wrapper iovw = {};
- struct iovec iovec;
bool first = true;
int r;
.msg_controllen = sizeof(control),
.msg_iovlen = 1,
};
- ssize_t n;
- ssize_t l;
+ ssize_t n, l;
l = next_datagram_size_fd(fd);
if (l < 0) {
goto finish;
}
- iovec.iov_len = l;
- iovec.iov_base = malloc(l + 1);
+ _cleanup_(iovec_done) struct iovec iovec = {
+ .iov_len = l,
+ .iov_base = malloc(l + 1),
+ };
if (!iovec.iov_base) {
r = log_oom();
goto finish;
n = recvmsg_safe(fd, &mh, MSG_CMSG_CLOEXEC);
if (n < 0) {
- free(iovec.iov_base);
r = log_error_errno(n, "Failed to receive datagram: %m");
goto finish;
}
if (n == 0) {
struct cmsghdr *found;
- free(iovec.iov_base);
-
found = cmsg_find(&mh, SOL_SOCKET, SCM_RIGHTS, CMSG_LEN(sizeof(int) * 2));
if (found) {
int fds[2] = EBADF_PAIR;
r = iovw_put(&iovw, iovec.iov_base, iovec.iov_len);
if (r < 0)
goto finish;
+
+ TAKE_STRUCT(iovec);
}
/* Make sure we got all data we really need */