tree-wide: more IOVEC_MAKE() conversions

This commit is contained in:
Lennart Poettering
2018-11-28 13:08:19 +09:00
committed by Yu Watanabe
parent 324ca05459
commit cb3108669d
10 changed files with 50 additions and 47 deletions
+1 -2
View File
@@ -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)
+3 -4
View File
@@ -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 =
+2 -4
View File
@@ -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.
+2 -2
View File
@@ -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);
+22 -13
View File
@@ -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;