summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/bus-socket.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
index 24b9c4d117..881efb176a 100644
--- a/src/libsystemd/sd-bus/bus-socket.c
+++ b/src/libsystemd/sd-bus/bus-socket.c
@@ -492,7 +492,7 @@ static int bus_socket_auth_verify(sd_bus *b) {
static int bus_socket_read_auth(sd_bus *b) {
struct msghdr mh;
- struct iovec iov;
+ struct iovec iov = {};
size_t n;
ssize_t k;
int r;
@@ -527,7 +527,6 @@ static int bus_socket_read_auth(sd_bus *b) {
b->rbuffer = p;
- zero(iov);
iov.iov_base = (uint8_t*) b->rbuffer + b->rbuffer_size;
iov.iov_len = n - b->rbuffer_size;
@@ -808,23 +807,21 @@ int bus_socket_write_message(sd_bus *bus, sd_bus_message *m, size_t *idx) {
if (bus->prefer_writev)
k = writev(bus->output_fd, iov, m->n_iovec);
else {
- struct msghdr mh;
- zero(mh);
+ struct msghdr mh = {
+ .msg_iov = iov,
+ .msg_iovlen = m->n_iovec,
+ };
if (m->n_fds > 0) {
struct cmsghdr *control;
- control = alloca(CMSG_SPACE(sizeof(int) * m->n_fds));
- mh.msg_control = control;
+ mh.msg_control = control = alloca(CMSG_SPACE(sizeof(int) * m->n_fds));
+ mh.msg_controllen = control->cmsg_len = CMSG_LEN(sizeof(int) * m->n_fds);
control->cmsg_level = SOL_SOCKET;
control->cmsg_type = SCM_RIGHTS;
- mh.msg_controllen = control->cmsg_len = CMSG_LEN(sizeof(int) * m->n_fds);
memcpy(CMSG_DATA(control), m->fds, sizeof(int) * m->n_fds);
}
- mh.msg_iov = iov;
- mh.msg_iovlen = m->n_iovec;
-
k = sendmsg(bus->output_fd, &mh, MSG_DONTWAIT|MSG_NOSIGNAL);
if (k < 0 && errno == ENOTSOCK) {
bus->prefer_writev = true;
@@ -936,7 +933,7 @@ static int bus_socket_make_message(sd_bus *bus, size_t size) {
int bus_socket_read_message(sd_bus *bus) {
struct msghdr mh;
- struct iovec iov;
+ struct iovec iov = {};
ssize_t k;
size_t need;
int r;
@@ -966,7 +963,6 @@ int bus_socket_read_message(sd_bus *bus) {
bus->rbuffer = b;
- zero(iov);
iov.iov_base = (uint8_t*) bus->rbuffer + bus->rbuffer_size;
iov.iov_len = need - bus->rbuffer_size;