@@
- IOVEC_MAKE(s, strlen(s));
+ IOVEC_MAKE_STRING(s);
+@@
+expression x, y, z;
+@@
+- x = (struct iovec) { .iov_base = y, .iov_len = z };
++ x = IOVEC_MAKE(y, z);
#include "dns-domain.h"
#include "event-util.h"
#include "hostname-util.h"
+#include "io-util.h"
#include "random-util.h"
#include "string-util.h"
-#include "util.h"
#include "strv.h"
+#include "util.h"
#define MAX_CLIENT_ID_LEN (sizeof(uint32_t) + MAX_DUID_LEN) /* Arbitrary limit */
#define MAX_MAC_ADDR_LEN CONST_MAX(INFINIBAND_ALEN, ETH_ALEN)
if (!packet)
return -ENOMEM;
- iov.iov_base = packet;
- iov.iov_len = buflen;
+ iov = IOVEC_MAKE(packet, buflen);
len = recvmsg(fd, &msg, 0);
if (len < 0) {
#include "dhcp-server-internal.h"
#include "fd-util.h"
#include "in-addr-util.h"
+#include "io-util.h"
#include "sd-id128.h"
#include "siphash24.h"
#include "string-util.h"
if (!message)
return -ENOMEM;
- iov.iov_base = message;
- iov.iov_len = buflen;
+ iov = IOVEC_MAKE(message, buflen);
len = recvmsg(fd, &msg, 0);
if (len < 0) {
m->n_iovec = 1;
m->iovec = m->iovec_fixed;
- m->iovec[0].iov_base = buffer;
- m->iovec[0].iov_len = length;
+ m->iovec[0] = IOVEC_MAKE(buffer, length);
r = bus_message_parse_fields(m);
if (r < 0)
#include "alloc-util.h"
#include "fd-util.h"
#include "fs-util.h"
+#include "io-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
unsigned n_fds) {
union sockaddr_union sockaddr = {};
- struct iovec iovec = {
- .iov_base = (char*) state,
- };
+ struct iovec iovec;
struct msghdr msghdr = {
.msg_iov = &iovec,
.msg_iovlen = 1,
(void) fd_inc_sndbuf(fd, SNDBUF_SIZE);
- iovec.iov_len = strlen(state);
+ iovec = IOVEC_MAKE_STRING(state);
msghdr.msg_namelen = salen;
send_ucred =
#include "fd-util.h"
#include "format-util.h"
#include "hashmap.h"
+#include "io-util.h"
#include "missing.h"
#include "mount-util.h"
#include "set.h"
/* add properties list */
nlh.properties_off = iov[0].iov_len;
nlh.properties_len = blen;
- iov[1] = (struct iovec) {
- .iov_base = (char*) buf,
- .iov_len = blen,
- };
+ iov[1] = IOVEC_MAKE((char*) buf, blen);
/*
* Use custom address for target, or the default one.
#include "alloc-util.h"
#include "fd-util.h"
#include "format-util.h"
+#include "io-util.h"
#include "missing.h"
#include "netlink-internal.h"
#include "netlink-types.h"
len, sizeof(uint8_t)))
return -ENOMEM;
- iov.iov_base = rtnl->rbuffer;
- iov.iov_len = rtnl->rbuffer_allocated;
+ iov = IOVEC_MAKE(rtnl->rbuffer, rtnl->rbuffer_allocated);
/* read the pending message */
r = socket_recv_message(rtnl->fd, &iov, &group, false);
if (ai)
freeaddrinfo(ai);
- iov[0] = (struct iovec) { .iov_base = &resp, .iov_len = sizeof(AddrInfoResponse) };
- iov[1] = (struct iovec) { .iov_base = &buffer, .iov_len = resp.header.length - sizeof(AddrInfoResponse) };
+ iov[0] = IOVEC_MAKE(&resp, sizeof(AddrInfoResponse));
+ iov[1] = IOVEC_MAKE(&buffer, resp.header.length - sizeof(AddrInfoResponse));
- mh = (struct msghdr) { .msg_iov = iov, .msg_iovlen = ELEMENTSOF(iov) };
+ mh = (struct msghdr) {
+ .msg_iov = iov,
+ .msg_iovlen = ELEMENTSOF(iov)
+ };
if (sendmsg(out_fd, &mh, MSG_NOSIGNAL) < 0)
return -errno;
._h_errno = _h_errno,
};
- iov[0] = (struct iovec) { .iov_base = &resp, .iov_len = sizeof(NameInfoResponse) };
- iov[1] = (struct iovec) { .iov_base = (void*) host, .iov_len = hl };
- iov[2] = (struct iovec) { .iov_base = (void*) serv, .iov_len = sl };
+ iov[0] = IOVEC_MAKE(&resp, sizeof(NameInfoResponse));
+ iov[1] = IOVEC_MAKE((void*) host, hl);
+ iov[2] = IOVEC_MAKE((void*) serv, sl);
- mh = (struct msghdr) { .msg_iov = iov, .msg_iovlen = ELEMENTSOF(iov) };
+ mh = (struct msghdr) {
+ .msg_iov = iov,
+ .msg_iovlen = ELEMENTSOF(iov)
+ };
if (sendmsg(out_fd, &mh, MSG_NOSIGNAL) < 0)
return -errno;
.ai_protocol = hints ? hints->ai_protocol : 0,
};
- iov[mh.msg_iovlen++] = (struct iovec) { .iov_base = &req, .iov_len = sizeof(AddrInfoRequest) };
+ iov[mh.msg_iovlen++] = IOVEC_MAKE(&req, sizeof(AddrInfoRequest));
if (node)
- iov[mh.msg_iovlen++] = (struct iovec) { .iov_base = (void*) node, .iov_len = req.node_len };
+ iov[mh.msg_iovlen++] = IOVEC_MAKE((void*) node, req.node_len);
if (service)
- iov[mh.msg_iovlen++] = (struct iovec) { .iov_base = (void*) service, .iov_len = req.service_len };
+ iov[mh.msg_iovlen++] = IOVEC_MAKE((void*) service, req.service_len);
mh.msg_iov = iov;
if (sendmsg(resolve->fds[REQUEST_SEND_FD], &mh, MSG_NOSIGNAL) < 0)
.getserv = !!(get & SD_RESOLVE_GET_SERVICE),
};
- iov[0] = (struct iovec) { .iov_base = &req, .iov_len = sizeof(NameInfoRequest) };
- iov[1] = (struct iovec) { .iov_base = (void*) sa, .iov_len = salen };
+ iov[0] = IOVEC_MAKE(&req, sizeof(NameInfoRequest));
+ iov[1] = IOVEC_MAKE((void*) sa, salen);
- mh = (struct msghdr) { .msg_iov = iov, .msg_iovlen = ELEMENTSOF(iov) };
+ mh = (struct msghdr) {
+ .msg_iov = iov,
+ .msg_iovlen = ELEMENTSOF(iov)
+ };
if (sendmsg(resolve->fds[REQUEST_SEND_FD], &mh, MSG_NOSIGNAL) < 0)
return -errno;
#include "format-util.h"
#include "fs-util.h"
#include "in-addr-util.h"
+#include "io-util.h"
#include "local-addresses.h"
#include "machine-dbus.h"
#include "machine.h"
.msg_iovlen = 2,
};
- iov[0] = (struct iovec) { .iov_base = &family, .iov_len = sizeof(family) };
- iov[1] = (struct iovec) { .iov_base = &in_addr, .iov_len = sizeof(in_addr) };
+ iov[0] = IOVEC_MAKE(&family, sizeof(family));
+ iov[1] = IOVEC_MAKE(&in_addr, sizeof(in_addr));
n = recvmsg(pair[0], &mh, 0);
if (n < 0)
#include "fileio-label.h"
#include "hostname-util.h"
#include "io-util.h"
+#include "io-util.h"
#include "netlink-util.h"
#include "network-internal.h"
#include "ordered-set.h"
#include "random-util.h"
#include "resolved-bus.h"
#include "resolved-conf.h"
-#include "resolved-dnssd.h"
#include "resolved-dns-stub.h"
+#include "resolved-dnssd.h"
#include "resolved-etc-hosts.h"
#include "resolved-llmnr.h"
#include "resolved-manager.h"
if (r < 0)
return r;
- iov = (struct iovec) {
- .iov_base = DNS_PACKET_DATA(p),
- iov.iov_len = p->allocated,
- };
+ iov = IOVEC_MAKE(DNS_PACKET_DATA(p), p->allocated);
l = recvmsg(fd, &mh, 0);
- if (l == 0)
- return 0;
if (l < 0) {
if (IN_SET(errno, EAGAIN, EINTR))
return 0;
return -errno;
}
+ if (l == 0)
+ return 0;
assert(!(mh.msg_flags & MSG_CTRUNC));
assert(!(mh.msg_flags & MSG_TRUNC));
assert(port > 0);
assert(p);
- iov = (struct iovec) {
- .iov_base = DNS_PACKET_DATA(p),
- .iov_len = p->size,
- };
+ iov = IOVEC_MAKE(DNS_PACKET_DATA(p), p->size);
sa = (union sockaddr_union) {
.in.sin_family = AF_INET,
assert(port > 0);
assert(p);
- iov = (struct iovec) {
- .iov_base = DNS_PACKET_DATA(p),
- .iov_len = p->size,
- };
+ iov = IOVEC_MAKE(DNS_PACKET_DATA(p), p->size);
sa = (union sockaddr_union) {
.in6.sin6_family = AF_INET6,