mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
tree-wide: more IOVEC_MAKE() conversions
This commit is contained in:
parent
324ca05459
commit
cb3108669d
@ -22,3 +22,8 @@ expression s;
|
||||
@@
|
||||
- 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);
|
||||
|
@ -23,10 +23,11 @@
|
||||
#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)
|
||||
@ -1784,8 +1785,7 @@ static int client_receive_message_raw(
|
||||
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) {
|
||||
|
@ -12,6 +12,7 @@
|
||||
#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"
|
||||
@ -943,8 +944,7 @@ static int server_receive_message(sd_event_source *s, int fd,
|
||||
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) {
|
||||
|
@ -554,8 +554,7 @@ int bus_message_from_malloc(
|
||||
|
||||
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)
|
||||
|
@ -19,6 +19,7 @@
|
||||
#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"
|
||||
@ -445,9 +446,7 @@ _public_ int sd_pid_notify_with_fds(
|
||||
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,
|
||||
@ -487,7 +486,7 @@ _public_ int sd_pid_notify_with_fds(
|
||||
|
||||
(void) fd_inc_sndbuf(fd, SNDBUF_SIZE);
|
||||
|
||||
iovec.iov_len = strlen(state);
|
||||
iovec = IOVEC_MAKE_STRING(state);
|
||||
msghdr.msg_namelen = salen;
|
||||
|
||||
send_ucred =
|
||||
|
@ -16,6 +16,7 @@
|
||||
#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"
|
||||
@ -541,10 +542,7 @@ int device_monitor_send_device(
|
||||
/* 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.
|
||||
|
@ -9,6 +9,7 @@
|
||||
#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"
|
||||
@ -334,8 +335,7 @@ int socket_read_message(sd_netlink *rtnl) {
|
||||
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);
|
||||
|
@ -262,10 +262,13 @@ static int send_addrinfo_reply(
|
||||
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;
|
||||
@ -303,11 +306,14 @@ static int send_nameinfo_reply(
|
||||
._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;
|
||||
@ -951,11 +957,11 @@ _public_ int sd_resolve_getaddrinfo(
|
||||
.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)
|
||||
@ -1023,10 +1029,13 @@ _public_ int sd_resolve_getnameinfo(
|
||||
.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;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#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"
|
||||
@ -250,8 +251,8 @@ int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd
|
||||
.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)
|
||||
|
@ -17,6 +17,7 @@
|
||||
#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"
|
||||
@ -24,8 +25,8 @@
|
||||
#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"
|
||||
@ -752,20 +753,17 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
||||
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));
|
||||
@ -934,10 +932,7 @@ static int manager_ipv4_send(
|
||||
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,
|
||||
@ -995,10 +990,7 @@ static int manager_ipv6_send(
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user