FOREACH_BTRFS_IOCTL_SEARCH_HEADER(i, sh, args) {
_cleanup_free_ char *p = NULL;
const struct btrfs_root_ref *ref;
- struct btrfs_ioctl_ino_lookup_args ino_args;
btrfs_ioctl_search_args_set(&args, sh);
if (!p)
return -ENOMEM;
- zero(ino_args);
- ino_args.treeid = subvol_id;
- ino_args.objectid = htole64(ref->dirid);
+ struct btrfs_ioctl_ino_lookup_args ino_args = {
+ .treeid = subvol_id,
+ .objectid = htole64(ref->dirid),
+ };
if (ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args) < 0)
return -errno;
FOREACH_BTRFS_IOCTL_SEARCH_HEADER(i, sh, args) {
_cleanup_free_ char *p = NULL, *c = NULL, *np = NULL;
- struct btrfs_ioctl_ino_lookup_args ino_args;
const struct btrfs_root_ref *ref;
_cleanup_close_ int old_child_fd = -1, new_child_fd = -1;
if (!p)
return -ENOMEM;
- zero(ino_args);
- ino_args.treeid = old_subvol_id;
- ino_args.objectid = htole64(ref->dirid);
+ struct btrfs_ioctl_ino_lookup_args ino_args = {
+ .treeid = old_subvol_id,
+ .objectid = htole64(ref->dirid),
+ };
if (ioctl(old_fd, BTRFS_IOC_INO_LOOKUP, &ino_args) < 0)
return -errno;
assert(s);
assert(n_sockets > 0);
- zero(*s);
+ *s = (struct Server) {
+ .epoll_fd = epoll_create1(EPOLL_CLOEXEC),
+ };
- s->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (s->epoll_fd < 0) {
r = log_error_errno(errno,
"Failed to create epoll object: %m");
}
for (i = 0; i < n_sockets; i++) {
- struct epoll_event ev;
Fifo *f;
int fd;
f->fd = -1;
- zero(ev);
- ev.events = EPOLLIN;
- ev.data.ptr = f;
+ struct epoll_event ev = {
+ .events = EPOLLIN,
+ .data.ptr = f,
+ };
+
if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0) {
r = -errno;
fifo_free(f);
int fd = -1, r;
sd_id128_t machine, boot;
char *p = NULL, *k = NULL;
- struct FSSHeader h;
uint64_t n;
struct stat st;
if (r < 0)
log_warning_errno(r, "Failed to set file attributes: %m");
- zero(h);
+ struct FSSHeader h = {
+ .machine_id = machine,
+ .boot_id = boot,
+ .header_size = htole64(sizeof(h)),
+ .start_usec = htole64(n * arg_interval),
+ .interval_usec = htole64(arg_interval),
+ .fsprg_secpar = htole16(FSPRG_RECOMMENDED_SECPAR),
+ .fsprg_state_size = htole64(state_size),
+ };
+
memcpy(h.signature, "KSHHRHLP", 8);
- h.machine_id = machine;
- h.boot_id = boot;
- h.header_size = htole64(sizeof(h));
- h.start_usec = htole64(n * arg_interval);
- h.interval_usec = htole64(arg_interval);
- h.fsprg_secpar = htole16(FSPRG_RECOMMENDED_SECPAR);
- h.fsprg_state_size = htole64(state_size);
r = loop_write(fd, &h, sizeof(h), false);
if (r < 0) {
if (!m->last_unused || m->n_windows <= WINDOWS_MIN) {
/* Allocate a new window */
- w = new0(Window, 1);
+ w = new(Window, 1);
if (!w)
return NULL;
m->n_windows++;
/* Reuse an existing one */
w = m->last_unused;
window_unlink(w);
- zero(*w);
}
- w->cache = m;
- w->fd = f;
- w->prot = prot;
- w->keep_always = keep_always;
- w->offset = offset;
- w->size = size;
- w->ptr = ptr;
+ *w = (Window) {
+ .cache = m,
+ .fd = f,
+ .prot = prot,
+ .keep_always = keep_always,
+ .offset = offset,
+ .size = size,
+ .ptr = ptr,
+ };
LIST_PREPEND(by_fd, f->windows, w);
int introspect_begin(struct introspect *i, bool trusted) {
assert(i);
- zero(*i);
- i->trusted = trusted;
+ *i = (struct introspect) {
+ .trusted = trusted,
+ };
i->f = open_memstream_unlocked(&i->introspection, &i->size);
if (!i->f)
if (b->prefer_writev)
k = writev(b->output_fd, b->auth_iovec + b->auth_index, ELEMENTSOF(b->auth_iovec) - b->auth_index);
else {
- struct msghdr mh;
- zero(mh);
-
- mh.msg_iov = b->auth_iovec + b->auth_index;
- mh.msg_iovlen = ELEMENTSOF(b->auth_iovec) - b->auth_index;
+ struct msghdr mh = {
+ .msg_iov = b->auth_iovec + b->auth_index,
+ .msg_iovlen = ELEMENTSOF(b->auth_iovec) - b->auth_index,
+ };
k = sendmsg(b->output_fd, &mh, MSG_DONTWAIT|MSG_NOSIGNAL);
if (k < 0 && errno == ENOTSOCK) {
if (b->prefer_readv)
k = readv(b->input_fd, &iov, 1);
else {
- zero(mh);
- mh.msg_iov = &iov;
- mh.msg_iovlen = 1;
- mh.msg_control = &control;
- mh.msg_controllen = sizeof(control);
+ mh = (struct msghdr) {
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = &control,
+ .msg_controllen = sizeof(control),
+ };
k = recvmsg_safe(b->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (k == -ENOTSOCK) {
if (bus->prefer_readv)
k = readv(bus->input_fd, &iov, 1);
else {
- zero(mh);
- mh.msg_iov = &iov;
- mh.msg_iovlen = 1;
- mh.msg_control = &control;
- mh.msg_controllen = sizeof(control);
+ mh = (struct msghdr) {
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = &control,
+ .msg_controllen = sizeof(control),
+ };
k = recvmsg_safe(bus->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (k == -ENOTSOCK) {
for (;;) {
char passphrase[LINE_MAX+1];
- struct msghdr msghdr;
struct iovec iovec;
struct ucred *ucred;
union {
iovec = IOVEC_MAKE(passphrase, sizeof(passphrase));
zero(control);
- zero(msghdr);
- msghdr.msg_iov = &iovec;
- msghdr.msg_iovlen = 1;
- msghdr.msg_control = &control;
- msghdr.msg_controllen = sizeof(control);
+ struct msghdr msghdr = {
+ .msg_iov = &iovec,
+ .msg_iovlen = 1,
+ .msg_control = &control,
+ .msg_controllen = sizeof(control),
+ };
n = recvmsg_safe(socket_fd, &msghdr, 0);
if (IN_SET(n, -EAGAIN, -EINTR))
assert(a);
assert(s);
- zero(*a);
- a->type = SOCK_RAW;
+ *a = (SocketAddress) {
+ .type = SOCK_RAW,
+ };
r = extract_first_word(&s, &word, NULL, 0);
if (r < 0)