--- /dev/null
+@@
+expression x, y, p, l;
+@@
+- x[y].iov_base = p;
+- x[y].iov_len = l;
+- y++;
++ x[y++] = IOVEC_MAKE(p, l);
+@@
+expression x, p, l;
+@@
+- x.iov_base = p;
+- x.iov_len = l;
++ x = IOVEC_MAKE(p, l);
+@@
+expression x, p, l;
+@@
+- x->iov_base = p;
+- x->iov_len = l;
++ *x = IOVEC_MAKE(p, l);
+@@
+expression s;
+@@
+- IOVEC_MAKE(s, strlen(s));
++ IOVEC_MAKE_STRING(s);
iovec[(*n)++] = IOVEC_MAKE_STRING(m);
if (newline_separator) {
- iovec[*n].iov_base = (char*) &nl;
- iovec[*n].iov_len = 1;
+ iovec[*n] = IOVEC_MAKE((char *)&nl, 1);
(*n)++;
}
memcpy(k + (e - p) + 1, e + 1 + sizeof(uint64_t), l);
if (journal_field_valid(p, e - p, false)) {
- iovec[n].iov_base = k;
- iovec[n].iov_len = (e - p) + 1 + l;
+ iovec[n] = IOVEC_MAKE(k, (e - p) + 1 + l);
entry_size += iovec[n].iov_len;
n++;
if (!GREEDY_REALLOC(s->buffer, s->buffer_size, m))
return log_oom();
- iovec.iov_base = s->buffer;
- iovec.iov_len = s->buffer_size - 1; /* Leave room for trailing NUL we add later */
+ iovec = IOVEC_MAKE(s->buffer, s->buffer_size - 1); /* Leave room for trailing NUL we add later */
n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (n < 0) {
#include "sd-journal.h"
#include "alloc-util.h"
+#include "io-util.h"
#include "journal-file.h"
#include "journal-vacuum.h"
#include "log.h"
#include "parse-util.h"
#include "rm-rf.h"
-#include "util.h"
#include "tests.h"
+#include "util.h"
/* This program tests skipping around in a multi-file journal. */
previous_ts = ts;
assert_se(asprintf(&p, "NUMBER=%d", n) >= 0);
- iovec[0].iov_base = p;
- iovec[0].iov_len = strlen(p);
+ iovec[0] = IOVEC_MAKE_STRING(p);
assert_ret(journal_file_append_entry(f, &ts, NULL, iovec, 1, seqnum, NULL, NULL));
free(p);
}
#include <unistd.h>
#include "fd-util.h"
+#include "io-util.h"
#include "journal-file.h"
#include "journal-verify.h"
#include "log.h"
assert_se(asprintf(&test, "RANDOM=%lu", random() % RANDOM_RANGE));
- iovec.iov_base = (void*) test;
- iovec.iov_len = strlen(test);
+ iovec = IOVEC_MAKE_STRING(test);
assert_se(journal_file_append_entry(f, &ts, NULL, &iovec, 1, NULL, NULL, NULL) == 0);
#include <fcntl.h>
#include <unistd.h>
+#include "io-util.h"
#include "journal-authenticate.h"
#include "journal-file.h"
#include "journal-vacuum.h"
assert_se(dual_timestamp_get(&ts));
assert_se(sd_id128_randomize(&fake_boot_id) == 0);
- iovec.iov_base = (void*) test;
- iovec.iov_len = strlen(test);
+ iovec = IOVEC_MAKE_STRING(test);
assert_se(journal_file_append_entry(f, &ts, NULL, &iovec, 1, NULL, NULL, NULL) == 0);
- iovec.iov_base = (void*) test2;
- iovec.iov_len = strlen(test2);
+ iovec = IOVEC_MAKE_STRING(test2);
assert_se(journal_file_append_entry(f, &ts, NULL, &iovec, 1, NULL, NULL, NULL) == 0);
- iovec.iov_base = (void*) test;
- iovec.iov_len = strlen(test);
+ iovec = IOVEC_MAKE_STRING(test);
assert_se(journal_file_append_entry(f, &ts, &fake_boot_id, &iovec, 1, NULL, NULL, NULL) == 0);
#if HAVE_GCRYPT
dual_timestamp_get(&ts);
- iovec.iov_base = (void*) data;
- iovec.iov_len = data_size;
+ iovec = IOVEC_MAKE(data, data_size);
assert_se(journal_file_append_entry(f, &ts, NULL, &iovec, 1, NULL, NULL, NULL) == 0);
#if HAVE_GCRYPT
#include "fd-util.h"
#include "icmp6-util.h"
-#include "socket-util.h"
#include "in-addr-util.h"
+#include "io-util.h"
+#include "socket-util.h"
#define IN6ADDR_ALL_ROUTERS_MULTICAST_INIT \
{ { { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
struct cmsghdr *cmsg;
ssize_t len;
- iov.iov_base = buffer;
- iov.iov_len = size;
+ iov = IOVEC_MAKE(buffer, size);
len = recvmsg(fd, &msg, MSG_DONTWAIT);
if (len < 0)
#include "sd-radv.h"
-#include "macro.h"
#include "alloc-util.h"
#include "dns-domain.h"
#include "ether-addr-util.h"
#include "fd-util.h"
#include "icmp6-util.h"
#include "in-addr-util.h"
+#include "io-util.h"
+#include "macro.h"
#include "radv-internal.h"
+#include "random-util.h"
#include "socket-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
-#include "random-util.h"
_public_ int sd_radv_new(sd_radv **ret) {
_cleanup_(sd_radv_unrefp) sd_radv *ra = NULL;
adv.nd_ra_curhoplimit = ra->hop_limit;
adv.nd_ra_flags_reserved = ra->flags;
adv.nd_ra_router_lifetime = htobe16(router_lifetime);
- iov[msg.msg_iovlen].iov_base = &adv;
- iov[msg.msg_iovlen].iov_len = sizeof(adv);
- msg.msg_iovlen++;
+ iov[msg.msg_iovlen++] = IOVEC_MAKE(&adv, sizeof(adv));
/* MAC address is optional, either because the link does not use L2
addresses or load sharing is desired. See RFC 4861, Section 4.2 */
if (!ether_addr_is_null(&ra->mac_addr)) {
opt_mac.slladdr = ra->mac_addr;
- iov[msg.msg_iovlen].iov_base = &opt_mac;
- iov[msg.msg_iovlen].iov_len = sizeof(opt_mac);
- msg.msg_iovlen++;
+ iov[msg.msg_iovlen++] = IOVEC_MAKE(&opt_mac, sizeof(opt_mac));
}
if (ra->mtu) {
opt_mtu.nd_opt_mtu_mtu = htobe32(ra->mtu);
- iov[msg.msg_iovlen].iov_base = &opt_mtu;
- iov[msg.msg_iovlen].iov_len = sizeof(opt_mtu);
- msg.msg_iovlen++;
+ iov[msg.msg_iovlen++] = IOVEC_MAKE(&opt_mtu, sizeof(opt_mtu));
}
LIST_FOREACH(prefix, p, ra->prefixes) {
else
p->opt.preferred_lifetime = htobe32((p->preferred_until - time_now) / USEC_PER_SEC);
}
- iov[msg.msg_iovlen].iov_base = &p->opt;
- iov[msg.msg_iovlen].iov_len = sizeof(p->opt);
- msg.msg_iovlen++;
+ iov[msg.msg_iovlen++] = IOVEC_MAKE(&p->opt, sizeof(p->opt));
}
- if (ra->rdnss) {
- iov[msg.msg_iovlen].iov_base = ra->rdnss;
- iov[msg.msg_iovlen].iov_len = ra->rdnss->length * 8;
- msg.msg_iovlen++;
- }
+ if (ra->rdnss)
+ iov[msg.msg_iovlen++] = IOVEC_MAKE(ra->rdnss, ra->rdnss->length * 8);
- if (ra->dnssl) {
- iov[msg.msg_iovlen].iov_base = ra->dnssl;
- iov[msg.msg_iovlen].iov_len = ra->dnssl->length * 8;
- msg.msg_iovlen++;
- }
+ if (ra->dnssl)
+ iov[msg.msg_iovlen++] = IOVEC_MAKE(ra->dnssl, ra->dnssl->length * 8);
if (sendmsg(ra->fd, &msg, 0) < 0)
return -errno;
size -= i->iov_len;
- i->iov_base = NULL;
- i->iov_len = 0;
+ *i = IOVEC_MAKE(NULL, 0);
(*idx)++;
}
assert(p);
assert(sz > 0);
- m->iovec[m->n_iovec].iov_base = (void*) p;
- m->iovec[m->n_iovec].iov_len = sz;
- m->n_iovec++;
+ m->iovec[m->n_iovec++] = IOVEC_MAKE((void*) p, sz);
return 0;
}
b->rbuffer = p;
- iov.iov_base = (uint8_t*) b->rbuffer + b->rbuffer_size;
- iov.iov_len = n - b->rbuffer_size;
+ iov = IOVEC_MAKE((uint8_t *)b->rbuffer + b->rbuffer_size, n - b->rbuffer_size);
if (b->prefer_readv)
k = readv(b->input_fd, &iov, 1);
else
auth_suffix = "\r\nBEGIN\r\n";
- b->auth_iovec[0].iov_base = (void*) auth_prefix;
- b->auth_iovec[0].iov_len = 1 + strlen(auth_prefix + 1);
- b->auth_iovec[1].iov_base = (void*) b->auth_buffer;
- b->auth_iovec[1].iov_len = l * 2;
- b->auth_iovec[2].iov_base = (void*) auth_suffix;
- b->auth_iovec[2].iov_len = strlen(auth_suffix);
+ b->auth_iovec[0] = IOVEC_MAKE((void*) auth_prefix, 1 + strlen(auth_prefix + 1));
+ b->auth_iovec[1] = IOVEC_MAKE(b->auth_buffer, l * 2);
+ b->auth_iovec[2] = IOVEC_MAKE_STRING(auth_suffix);
return bus_socket_write_auth(b);
}
bus->rbuffer = b;
- iov.iov_base = (uint8_t*) bus->rbuffer + bus->rbuffer_size;
- iov.iov_len = need - bus->rbuffer_size;
+ iov = IOVEC_MAKE((uint8_t *)bus->rbuffer + bus->rbuffer_size, need - bus->rbuffer_size);
if (bus->prefer_readv)
k = readv(bus->input_fd, &iov, 1);
struct iovec iov[2];
ssize_t ss;
- iov[0].iov_base = &s->write_size;
- iov[0].iov_len = sizeof(s->write_size);
- iov[1].iov_base = DNS_PACKET_DATA(s->write_packet);
- iov[1].iov_len = s->write_packet->size;
+ iov[0] = IOVEC_MAKE(&s->write_size, sizeof(s->write_size));
+ iov[1] = IOVEC_MAKE(DNS_PACKET_DATA(s->write_packet), s->write_packet->size);
IOVEC_INCREMENT(iov, 2, s->n_written);
assert(stream->dnstls_data.write_buffer->data);
struct iovec iov[1];
- iov[0].iov_base = stream->dnstls_data.write_buffer->data;
- iov[0].iov_len = stream->dnstls_data.write_buffer->length;
+ iov[0] = IOVEC_MAKE(stream->dnstls_data.write_buffer->data,
+ stream->dnstls_data.write_buffer->length);
ss = dns_stream_writev(stream, iov, 1, DNS_STREAM_WRITE_TLS_DATA);
if (ss < 0) {
if (ss == -EAGAIN)
goto finish;
}
- zero(iovec);
- iovec.iov_base = passphrase;
- iovec.iov_len = sizeof(passphrase);
+ iovec = IOVEC_MAKE(passphrase, sizeof(passphrase));
zero(control);
zero(msghdr);
#include "alloc-util.h"
#include "fd-util.h"
#include "format-util.h"
+#include "io-util.h"
#include "socket-util.h"
#include "strxcpyx.h"
#include "udev-ctrl.h"
break;
}
- iov.iov_base = &uctrl_msg->ctrl_msg_wire;
- iov.iov_len = sizeof(struct udev_ctrl_msg_wire);
+ iov = IOVEC_MAKE(&uctrl_msg->ctrl_msg_wire, sizeof(struct udev_ctrl_msg_wire));
size = recvmsg(conn->sock, &smsg, 0);
if (size < 0) {