* tmpfiles: when applying ownership to /run/log/journal also do this for the journal fails contained in it
-* rework list.h to use typeof() and thus simplify most linked list macros by not requring the type to be specified
-
* we probably should replace the left-over uses of strv_append() and replace them by strv_push() or strv_extend()
* move config_parse_path_strv() out of conf-parser.c
log_uptime();
- LIST_HEAD_INIT(struct list_sample_data, head);
+ LIST_HEAD_INIT(head);
/* main program loop */
for (samples = 0; !exiting && samples < arg_samples_len; samples++) {
/* calculate how many samples we lost and scrap them */
arg_samples_len -= (int)(newint_ns / interval);
}
- LIST_PREPEND(struct list_sample_data, link, head, sampledata);
+ LIST_PREPEND(link, head, sampledata);
}
/* do some cleanup, close fd's */
struct list_sample_data *sampledata_last;
sampledata = head;
- LIST_FIND_TAIL(struct list_sample_data, link, sampledata, head);
+ LIST_FIND_TAIL(link, sampledata, head);
sampledata_last = head;
LIST_FOREACH_BEFORE(link, sampledata, head) {
sampledata_last = sampledata;
assert(c);
assert(a);
- LIST_REMOVE(CGroupDeviceAllow, device_allow, c->device_allow, a);
+ LIST_REMOVE(device_allow, c->device_allow, a);
free(a->path);
free(a);
}
assert(c);
assert(w);
- LIST_REMOVE(CGroupBlockIODeviceWeight, device_weights, c->blockio_device_weights, w);
+ LIST_REMOVE(device_weights, c->blockio_device_weights, w);
free(w->path);
free(w);
}
assert(c);
assert(b);
- LIST_REMOVE(CGroupBlockIODeviceBandwidth, device_bandwidths, c->blockio_device_bandwidths, b);
+ LIST_REMOVE(device_bandwidths, c->blockio_device_bandwidths, b);
free(b->path);
free(b);
}
assert(u);
if (u->in_cgroup_queue) {
- LIST_REMOVE(Unit, cgroup_queue, u->manager->cgroup_queue, u);
+ LIST_REMOVE(cgroup_queue, u->manager->cgroup_queue, u);
u->in_cgroup_queue = false;
}
if (u->in_cgroup_queue)
return;
- LIST_PREPEND(Unit, cgroup_queue, u->manager->cgroup_queue, u);
+ LIST_PREPEND(cgroup_queue, u->manager->cgroup_queue, u);
u->in_cgroup_queue = true;
}
a->bandwidth = u64;
if (!exist)
- LIST_PREPEND(CGroupBlockIODeviceBandwidth, device_bandwidths,
- c->blockio_device_bandwidths, a);
+ LIST_PREPEND(device_bandwidths, c->blockio_device_bandwidths, a);
}
n++;
a->weight = ul;
if (!exist)
- LIST_PREPEND(CGroupBlockIODeviceWeight, device_weights,
- c->blockio_device_weights, a);
+ LIST_PREPEND(device_weights,c->blockio_device_weights, a);
}
n++;
a->m = !!strchr(rwm, 'm');
if (!exist)
- LIST_PREPEND(CGroupDeviceAllow, device_allow, c->device_allow, a);
+ LIST_PREPEND(device_allow, c->device_allow, a);
}
n++;
assert(j);
if (j->in_dbus_queue) {
- LIST_REMOVE(Job, dbus_queue, j->manager->dbus_job_queue, j);
+ LIST_REMOVE(dbus_queue, j->manager->dbus_job_queue, j);
j->in_dbus_queue = false;
}
assert(u);
if (u->in_dbus_queue) {
- LIST_REMOVE(Unit, dbus_queue, u->manager->dbus_unit_queue, u);
+ LIST_REMOVE(dbus_queue, u->manager->dbus_unit_queue, u);
u->in_dbus_queue = false;
}
if (!cl)
goto oom;
- LIST_PREPEND(JobBusClient, client, j->bus_client_list, cl);
+ LIST_PREPEND(client, j->bus_client_list, cl);
reply = dbus_message_new_method_return(message);
if (!reply)
JobBusClient *cl, *nextcl;
LIST_FOREACH_SAFE(client, cl, nextcl, j->bus_client_list) {
if (cl->bus == c) {
- LIST_REMOVE(JobBusClient, client, j->bus_client_list, cl);
+ LIST_REMOVE(client, j->bus_client_list, cl);
free(cl);
}
}
/* Remove this unit from the chain of devices which share the
* same sysfs path. */
first = hashmap_get(UNIT(d)->manager->devices_by_sysfs, d->sysfs);
- LIST_REMOVE(Device, same_sysfs, first, d);
+ LIST_REMOVE(same_sysfs, first, d);
if (first)
hashmap_remove_and_replace(UNIT(d)->manager->devices_by_sysfs, d->sysfs, first->sysfs, first);
}
first = hashmap_get(m->devices_by_sysfs, sysfs);
- LIST_PREPEND(Device, same_sysfs, first, DEVICE(u));
+ LIST_PREPEND(same_sysfs, first, DEVICE(u));
r = hashmap_replace(m->devices_by_sysfs, DEVICE(u)->sysfs, first);
if (r < 0)
ExecCommand *i;
while ((i = c)) {
- LIST_REMOVE(ExecCommand, command, c, i);
+ LIST_REMOVE(command, c, i);
exec_command_done(i);
free(i);
}
if (*l) {
/* It's kind of important, that we keep the order here */
- LIST_FIND_TAIL(ExecCommand, command, *l, end);
- LIST_INSERT_AFTER(ExecCommand, command, *l, end, e);
+ LIST_FIND_TAIL(command, *l, end);
+ LIST_INSERT_AFTER(command, *l, end, e);
} else
*l = e;
}
assert(!j->object_list);
if (j->in_run_queue)
- LIST_REMOVE(Job, run_queue, j->manager->run_queue, j);
+ LIST_REMOVE(run_queue, j->manager->run_queue, j);
if (j->in_dbus_queue)
- LIST_REMOVE(Job, dbus_queue, j->manager->dbus_job_queue, j);
+ LIST_REMOVE(dbus_queue, j->manager->dbus_job_queue, j);
if (j->timer_watch.type != WATCH_INVALID) {
assert(j->timer_watch.type == WATCH_JOB_TIMER);
}
while ((cl = j->bus_client_list)) {
- LIST_REMOVE(JobBusClient, client, j->bus_client_list, cl);
+ LIST_REMOVE(client, j->bus_client_list, cl);
free(cl);
}
free(j);
l->conflicts = conflicts;
if (subject)
- LIST_PREPEND(JobDependency, subject, subject->subject_list, l);
+ LIST_PREPEND(subject, subject->subject_list, l);
- LIST_PREPEND(JobDependency, object, object->object_list, l);
+ LIST_PREPEND(object, object->object_list, l);
return l;
}
assert(l);
if (l->subject)
- LIST_REMOVE(JobDependency, subject, l->subject->subject_list, l);
+ LIST_REMOVE(subject, l->subject->subject_list, l);
- LIST_REMOVE(JobDependency, object, l->object->object_list, l);
+ LIST_REMOVE(object, l->object->object_list, l);
free(l);
}
assert(j->type < _JOB_TYPE_MAX_IN_TRANSACTION);
assert(j->in_run_queue);
- LIST_REMOVE(Job, run_queue, j->manager->run_queue, j);
+ LIST_REMOVE(run_queue, j->manager->run_queue, j);
j->in_run_queue = false;
if (j->state != JOB_WAITING)
if (j->in_run_queue)
return;
- LIST_PREPEND(Job, run_queue, j->manager->run_queue, j);
+ LIST_PREPEND(run_queue, j->manager->run_queue, j);
j->in_run_queue = true;
}
* job might just have been created and not yet assigned to a
* connection/client. */
- LIST_PREPEND(Job, dbus_queue, j->manager->dbus_job_queue, j);
+ LIST_PREPEND(dbus_queue, j->manager->dbus_job_queue, j);
j->in_dbus_queue = true;
}
p->fd = -1;
if (s->ports) {
- LIST_FIND_TAIL(SocketPort, port, s->ports, tail);
- LIST_INSERT_AFTER(SocketPort, port, s->ports, tail, p);
+ LIST_FIND_TAIL(port, s->ports, tail);
+ LIST_INSERT_AFTER(port, s->ports, tail, p);
} else
- LIST_PREPEND(SocketPort, port, s->ports, p);
+ LIST_PREPEND(port, s->ports, p);
return 0;
}
v->value = u;
v->calendar_spec = c;
- LIST_PREPEND(TimerValue, value, t->values, v);
+ LIST_PREPEND(value, t->values, v);
return 0;
}
s->type = b;
s->inotify_fd = -1;
- LIST_PREPEND(PathSpec, spec, p->specs, s);
+ LIST_PREPEND(spec, p->specs, s);
return 0;
}
if (!c)
return log_oom();
- LIST_PREPEND(Condition, conditions, u->conditions, c);
+ LIST_PREPEND(conditions, u->conditions, c);
return 0;
}
if (!c)
return log_oom();
- LIST_PREPEND(Condition, conditions, u->conditions, c);
+ LIST_PREPEND(conditions, u->conditions, c);
return 0;
}
if (!c)
return log_oom();
- LIST_PREPEND(Condition, conditions, u->conditions, c);
+ LIST_PREPEND(conditions, u->conditions, c);
return 0;
}
a->w = !!strchr(m, 'w');
a->m = !!strchr(m, 'm');
- LIST_PREPEND(CGroupDeviceAllow, device_allow, c->device_allow, a);
+ LIST_PREPEND(device_allow, c->device_allow, a);
return 0;
}
w->weight = lu;
- LIST_PREPEND(CGroupBlockIODeviceWeight, device_weights, c->blockio_device_weights, w);
+ LIST_PREPEND(device_weights, c->blockio_device_weights, w);
return 0;
}
b->bandwidth = (uint64_t) bytes;
b->read = read;
- LIST_PREPEND(CGroupBlockIODeviceBandwidth, device_bandwidths, c->blockio_device_bandwidths, b);
+ LIST_PREPEND(device_bandwidths, c->blockio_device_bandwidths, b);
return 0;
}
unit_gc_sweep(u, gc_marker);
- LIST_REMOVE(Unit, gc_queue, m->gc_queue, u);
+ LIST_REMOVE(gc_queue, m->gc_queue, u);
u->in_gc_queue = false;
n++;
while ((s = p->specs)) {
path_spec_unwatch(s, UNIT(p));
- LIST_REMOVE(PathSpec, spec, p->specs, s);
+ LIST_REMOVE(spec, p->specs, s);
path_spec_done(s);
free(s);
}
assert(s);
while ((p = s->ports)) {
- LIST_REMOVE(SocketPort, port, s->ports, p);
+ LIST_REMOVE(port, s->ports, p);
if (p->fd >= 0) {
unit_unwatch_fd(UNIT(s), &p->fd_watch);
* same kernel swap device. */
swaps = UNIT(s)->manager->swaps_by_proc_swaps;
first = hashmap_get(swaps, s->parameters_proc_swaps.what);
- LIST_REMOVE(Swap, same_proc_swaps, first, s);
+ LIST_REMOVE(same_proc_swaps, first, s);
if (first)
hashmap_remove_and_replace(swaps,
p->what = wp;
first = hashmap_get(m->swaps_by_proc_swaps, wp);
- LIST_PREPEND(Swap, same_proc_swaps, first, SWAP(u));
+ LIST_PREPEND(same_proc_swaps, first, SWAP(u));
r = hashmap_replace(m->swaps_by_proc_swaps, wp, first);
if (r < 0)
assert(t);
while ((v = t->values)) {
- LIST_REMOVE(TimerValue, value, t->values, v);
+ LIST_REMOVE(value, t->values, v);
if (v->calendar_spec)
calendar_spec_free(v->calendar_spec);
j->override = override;
j->irreversible = tr->irreversible;
- LIST_PREPEND(Job, transaction, f, j);
+ LIST_PREPEND(transaction, f, j);
if (hashmap_replace(tr->jobs, unit, f) < 0) {
- LIST_REMOVE(Job, transaction, f, j);
+ LIST_REMOVE(transaction, f, j);
job_free(j);
return NULL;
}
typedef struct MountPoint {
char *path;
dev_t devnum;
- LIST_FIELDS (struct MountPoint, mount_point);
+ LIST_FIELDS(struct MountPoint, mount_point);
} MountPoint;
static void mount_point_free(MountPoint **head, MountPoint *m) {
assert(head);
assert(m);
- LIST_REMOVE(MountPoint, mount_point, *head, m);
+ LIST_REMOVE(mount_point, *head, m);
free(m->path);
free(m);
}
m->path = p;
- LIST_PREPEND(MountPoint, mount_point, *head, m);
+ LIST_PREPEND(mount_point, *head, m);
}
r = 0;
}
swap->path = d;
- LIST_PREPEND(MountPoint, mount_point, *head, swap);
+ LIST_PREPEND(mount_point, *head, swap);
}
r = 0;
}
lb->path = loop;
- LIST_PREPEND(MountPoint, mount_point, *head, lb);
+ LIST_PREPEND(mount_point, *head, lb);
}
return 0;
m->path = node;
m->devnum = devnum;
- LIST_PREPEND(MountPoint, mount_point, *head, m);
+ LIST_PREPEND(mount_point, *head, m);
}
return 0;
bool umount_changed;
LIST_HEAD(MountPoint, mp_list_head);
- LIST_HEAD_INIT(MountPoint, mp_list_head);
+ LIST_HEAD_INIT(mp_list_head);
r = mount_points_list_get(&mp_list_head);
if (r < 0)
goto end;
int r;
LIST_HEAD(MountPoint, swap_list_head);
- LIST_HEAD_INIT(MountPoint, swap_list_head);
+ LIST_HEAD_INIT(swap_list_head);
r = swap_list_get(&swap_list_head);
if (r < 0)
int r;
LIST_HEAD(MountPoint, loopback_list_head);
- LIST_HEAD_INIT(MountPoint, loopback_list_head);
+ LIST_HEAD_INIT(loopback_list_head);
r = loopback_list_get(&loopback_list_head);
if (r < 0)
int r;
LIST_HEAD(MountPoint, dm_list_head);
- LIST_HEAD_INIT(MountPoint, dm_list_head);
+ LIST_HEAD_INIT(dm_list_head);
r = dm_list_get(&dm_list_head);
if (r < 0)
u->id = s;
u->instance = i;
- LIST_PREPEND(Unit, units_by_type, u->manager->units_by_type[t], u);
+ LIST_PREPEND(units_by_type, u->manager->units_by_type[t], u);
if (UNIT_VTABLE(u)->init)
UNIT_VTABLE(u)->init(u);
if (u->load_state != UNIT_STUB || u->in_load_queue)
return;
- LIST_PREPEND(Unit, load_queue, u->manager->load_queue, u);
+ LIST_PREPEND(load_queue, u->manager->load_queue, u);
u->in_load_queue = true;
}
if (u->in_cleanup_queue)
return;
- LIST_PREPEND(Unit, cleanup_queue, u->manager->cleanup_queue, u);
+ LIST_PREPEND(cleanup_queue, u->manager->cleanup_queue, u);
u->in_cleanup_queue = true;
}
if (unit_check_gc(u))
return;
- LIST_PREPEND(Unit, gc_queue, u->manager->gc_queue, u);
+ LIST_PREPEND(gc_queue, u->manager->gc_queue, u);
u->in_gc_queue = true;
u->manager->n_in_gc_queue ++;
return;
}
- LIST_PREPEND(Unit, dbus_queue, u->manager->dbus_unit_queue, u);
+ LIST_PREPEND(dbus_queue, u->manager->dbus_unit_queue, u);
u->in_dbus_queue = true;
}
bidi_set_free(u, u->dependencies[d]);
if (u->type != _UNIT_TYPE_INVALID)
- LIST_REMOVE(Unit, units_by_type, u->manager->units_by_type[u->type], u);
+ LIST_REMOVE(units_by_type, u->manager->units_by_type[u->type], u);
if (u->in_load_queue)
- LIST_REMOVE(Unit, load_queue, u->manager->load_queue, u);
+ LIST_REMOVE(load_queue, u->manager->load_queue, u);
if (u->in_dbus_queue)
- LIST_REMOVE(Unit, dbus_queue, u->manager->dbus_unit_queue, u);
+ LIST_REMOVE(dbus_queue, u->manager->dbus_unit_queue, u);
if (u->in_cleanup_queue)
- LIST_REMOVE(Unit, cleanup_queue, u->manager->cleanup_queue, u);
+ LIST_REMOVE(cleanup_queue, u->manager->cleanup_queue, u);
if (u->in_gc_queue) {
- LIST_REMOVE(Unit, gc_queue, u->manager->gc_queue, u);
+ LIST_REMOVE(gc_queue, u->manager->gc_queue, u);
u->manager->n_in_gc_queue--;
}
if (u->in_cgroup_queue)
- LIST_REMOVE(Unit, cgroup_queue, u->manager->cgroup_queue, u);
+ LIST_REMOVE(cgroup_queue, u->manager->cgroup_queue, u);
if (u->cgroup_path) {
hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);
assert(u);
if (u->in_load_queue) {
- LIST_REMOVE(Unit, load_queue, u->manager->load_queue, u);
+ LIST_REMOVE(load_queue, u->manager->load_queue, u);
u->in_load_queue = false;
}
unit_ref_unset(ref);
ref->unit = u;
- LIST_PREPEND(UnitRef, refs, u->refs, ref);
+ LIST_PREPEND(refs, u->refs, ref);
return u;
}
if (!ref->unit)
return;
- LIST_REMOVE(UnitRef, refs, ref->unit->refs, ref);
+ LIST_REMOVE(refs, ref->unit->refs, ref);
ref->unit = NULL;
}
if (f->server) {
assert(f->server->n_fifos > 0);
f->server->n_fifos--;
- LIST_REMOVE(Fifo, fifo, f->server->fifos, f);
+ LIST_REMOVE(fifo, f->server->fifos, f);
}
if (f->fd >= 0) {
}
f->fd = fd;
- LIST_PREPEND(Fifo, fifo, s->fifos, f);
+ LIST_PREPEND(fifo, s->fifos, f);
f->server = s;
s->n_fifos ++;
}
if (g->parent->lru_tail == g)
g->parent->lru_tail = g->lru_prev;
- LIST_REMOVE(JournalRateLimitGroup, lru, g->parent->lru, g);
- LIST_REMOVE(JournalRateLimitGroup, bucket, g->parent->buckets[g->hash % BUCKETS_MAX], g);
+ LIST_REMOVE(lru, g->parent->lru, g);
+ LIST_REMOVE(bucket, g->parent->buckets[g->hash % BUCKETS_MAX], g);
g->parent->n_groups --;
}
journal_rate_limit_vacuum(r, ts);
- LIST_PREPEND(JournalRateLimitGroup, bucket, r->buckets[g->hash % BUCKETS_MAX], g);
- LIST_PREPEND(JournalRateLimitGroup, lru, r->lru, g);
+ LIST_PREPEND(bucket, r->buckets[g->hash % BUCKETS_MAX], g);
+ LIST_PREPEND(lru, r->lru, g);
if (!g->lru_next)
r->lru_tail = g;
r->n_groups ++;
if (s->server) {
assert(s->server->n_stdout_streams > 0);
s->server->n_stdout_streams --;
- LIST_REMOVE(StdoutStream, stdout_stream, s->server->stdout_streams, s);
+ LIST_REMOVE(stdout_stream, s->server->stdout_streams, s);
}
if (s->fd >= 0) {
}
stream->server = s;
- LIST_PREPEND(StdoutStream, stdout_stream, s->stdout_streams, stream);
+ LIST_PREPEND(stdout_stream, s->stdout_streams, stream);
s->n_stdout_streams ++;
return 0;
munmap(w->ptr, w->size);
if (w->fd)
- LIST_REMOVE(Window, by_fd, w->fd->windows, w);
+ LIST_REMOVE(by_fd, w->fd->windows, w);
if (w->in_unused) {
if (w->cache->last_unused == w)
w->cache->last_unused = w->unused_prev;
- LIST_REMOVE(Window, unused, w->cache->unused, w);
+ LIST_REMOVE(unused, w->cache->unused, w);
}
LIST_FOREACH(by_window, c, w->contexts) {
w = c->window;
c->window = NULL;
- LIST_REMOVE(Context, by_window, w->contexts, c);
+ LIST_REMOVE(by_window, w->contexts, c);
if (!w->contexts && !w->keep_always) {
/* Not used anymore? */
- LIST_PREPEND(Window, unused, c->cache->unused, w);
+ LIST_PREPEND(unused, c->cache->unused, w);
if (!c->cache->last_unused)
c->cache->last_unused = w;
if (w->in_unused) {
/* Used again? */
- LIST_REMOVE(Window, unused, c->cache->unused, w);
+ LIST_REMOVE(unused, c->cache->unused, w);
if (c->cache->last_unused == w)
c->cache->last_unused = w->unused_prev;
}
c->window = w;
- LIST_PREPEND(Context, by_window, w->contexts, c);
+ LIST_PREPEND(by_window, w->contexts, c);
}
static Context *context_add(MMapCache *m, unsigned id) {
w->size = wsize;
w->fd = f;
- LIST_PREPEND(Window, by_fd, f->windows, w);
+ LIST_PREPEND(by_fd, f->windows, w);
context_detach_window(c);
c->window = w;
- LIST_PREPEND(Context, by_window, w->contexts, c);
+ LIST_PREPEND(by_window, w->contexts, c);
*ret = (uint8_t*) w->ptr + (offset - w->offset);
return 1;
if (p) {
m->parent = p;
- LIST_PREPEND(Match, matches, p->matches, m);
+ LIST_PREPEND(matches, p->matches, m);
}
return m;
match_free(m->matches);
if (m->parent)
- LIST_REMOVE(Match, matches, m->parent->matches, m);
+ LIST_REMOVE(matches, m->parent->matches, m);
free(m->data);
free(m);
}
if (parent)
- LIST_PREPEND(struct node, siblings, parent->child, n);
+ LIST_PREPEND(siblings, parent->child, n);
return n;
}
assert(hashmap_remove(b->nodes, n->path) == n);
if (n->parent)
- LIST_REMOVE(struct node, siblings, n->parent->child, n);
+ LIST_REMOVE(siblings, n->parent->child, n);
free(n->path);
bus_node_gc(b, n->parent);
c->userdata = userdata;
c->is_fallback = fallback;
- LIST_PREPEND(struct node_callback, callbacks, n->callbacks, c);
+ LIST_PREPEND(callbacks, n->callbacks, c);
return 0;
fail:
if (!c)
return 0;
- LIST_REMOVE(struct node_callback, callbacks, n->callbacks, c);
+ LIST_REMOVE(callbacks, n->callbacks, c);
free(c);
bus_node_gc(bus, n);
}
}
- LIST_PREPEND(struct node_vtable, vtables, n->vtables, c);
+ LIST_PREPEND(vtables, n->vtables, c);
return 0;
fail:
if (!c)
return 0;
- LIST_REMOVE(struct node_vtable, vtables, n->vtables, c);
+ LIST_REMOVE(vtables, n->vtables, c);
free_node_vtable(bus, c);
bus_node_gc(bus, n);
c->callback = callback;
c->userdata = userdata;
- LIST_PREPEND(struct node_enumerator, enumerators, n->enumerators, c);
+ LIST_PREPEND(enumerators, n->enumerators, c);
return 0;
fail:
if (!c)
return 0;
- LIST_REMOVE(struct node_enumerator, enumerators, n->enumerators, c);
+ LIST_REMOVE(enumerators, n->enumerators, c);
free(c);
bus_node_gc(bus, n);
bus_node_destroy(b, n->child);
while ((c = n->callbacks)) {
- LIST_REMOVE(struct node_callback, callbacks, n->callbacks, c);
+ LIST_REMOVE(callbacks, n->callbacks, c);
free(c);
}
while ((v = n->vtables)) {
- LIST_REMOVE(struct node_vtable, vtables, n->vtables, v);
+ LIST_REMOVE(vtables, n->vtables, v);
free(v->interface);
free(v);
}
while ((e = n->enumerators)) {
- LIST_REMOVE(struct node_enumerator, enumerators, n->enumerators, e);
+ LIST_REMOVE(enumerators, n->enumerators, e);
free(e);
}
if (n->parent)
- LIST_REMOVE(struct node, siblings, n->parent->child, n);
+ LIST_REMOVE(siblings, n->parent->child, n);
assert_se(hashmap_remove(b->nodes, n->path) == n);
free(n->path);
prioq_free(b->reply_callbacks_prioq);
while ((f = b->filter_callbacks)) {
- LIST_REMOVE(struct filter_callback, callbacks, b->filter_callbacks, f);
+ LIST_REMOVE(callbacks, b->filter_callbacks, f);
free(f);
}
f->userdata = userdata;
bus->filter_callbacks_modified = true;
- LIST_PREPEND(struct filter_callback, callbacks, bus->filter_callbacks, f);
+ LIST_PREPEND(callbacks, bus->filter_callbacks, f);
return 0;
}
LIST_FOREACH(callbacks, f, bus->filter_callbacks) {
if (f->callback == callback && f->userdata == userdata) {
bus->filter_callbacks_modified = true;
- LIST_REMOVE(struct filter_callback, callbacks, bus->filter_callbacks, f);
+ LIST_REMOVE(callbacks, bus->filter_callbacks, f);
free(f);
return 1;
}
session_device_free(sd);
s = d->seat;
- LIST_REMOVE(Device, devices, d->seat->devices, d);
+ LIST_REMOVE(devices, d->seat->devices, d);
d->seat = NULL;
if (!seat_has_master_device(s)) {
* per seat, so we iterate only a few times. */
if (d->master || !s->devices)
- LIST_PREPEND(Device, devices, s->devices, d);
+ LIST_PREPEND(devices, s->devices, d);
else {
LIST_FOREACH(devices, i, s->devices) {
if (!i->devices_next || !i->master) {
- LIST_INSERT_AFTER(Device, devices, s->devices, i, d);
+ LIST_INSERT_AFTER(devices, s->devices, i, d);
break;
}
}
assert(s);
if (s->in_gc_queue)
- LIST_REMOVE(Seat, gc_queue, s->manager->seat_gc_queue, s);
+ LIST_REMOVE(gc_queue, s->manager->seat_gc_queue, s);
while (s->sessions)
session_free(s->sessions);
assert(!session->seat);
session->seat = s;
- LIST_PREPEND(Session, sessions_by_seat, s->sessions, session);
+ LIST_PREPEND(sessions_by_seat, s->sessions, session);
seat_send_changed(s, "Sessions\0");
if (s->in_gc_queue)
return;
- LIST_PREPEND(Seat, gc_queue, s->manager->seat_gc_queue, s);
+ LIST_PREPEND(gc_queue, s->manager->seat_gc_queue, s);
s->in_gc_queue = true;
}
}
sd->fd = r;
- LIST_PREPEND(SessionDevice, sd_by_device, sd->device->session_devices, sd);
+ LIST_PREPEND(sd_by_device, sd->device->session_devices, sd);
*out = sd;
return 0;
session_device_notify(sd, SESSION_DEVICE_RELEASE);
close_nointr_nofail(sd->fd);
- LIST_REMOVE(SessionDevice, sd_by_device, sd->device->session_devices, sd);
+ LIST_REMOVE(sd_by_device, sd->device->session_devices, sd);
hashmap_remove(sd->session->devices, &sd->dev);
assert(s);
if (s->in_gc_queue)
- LIST_REMOVE(Session, gc_queue, s->manager->session_gc_queue, s);
+ LIST_REMOVE(gc_queue, s->manager->session_gc_queue, s);
session_drop_controller(s);
hashmap_free(s->devices);
if (s->user) {
- LIST_REMOVE(Session, sessions_by_user, s->user->sessions, s);
+ LIST_REMOVE(sessions_by_user, s->user->sessions, s);
if (s->user->display == s)
s->user->display = NULL;
if (s->seat->pending_switch == s)
s->seat->pending_switch = NULL;
- LIST_REMOVE(Session, sessions_by_seat, s->seat->sessions, s);
+ LIST_REMOVE(sessions_by_seat, s->seat->sessions, s);
}
if (s->scope) {
assert(!s->user);
s->user = u;
- LIST_PREPEND(Session, sessions_by_user, u->sessions, s);
+ LIST_PREPEND(sessions_by_user, u->sessions, s);
}
int session_save(Session *s) {
if (s->in_gc_queue)
return;
- LIST_PREPEND(Session, gc_queue, s->manager->session_gc_queue, s);
+ LIST_PREPEND(gc_queue, s->manager->session_gc_queue, s);
s->in_gc_queue = true;
}
assert(u);
if (u->in_gc_queue)
- LIST_REMOVE(User, gc_queue, u->manager->user_gc_queue, u);
+ LIST_REMOVE(gc_queue, u->manager->user_gc_queue, u);
while (u->sessions)
session_free(u->sessions);
if (u->in_gc_queue)
return;
- LIST_PREPEND(User, gc_queue, u->manager->user_gc_queue, u);
+ LIST_PREPEND(gc_queue, u->manager->user_gc_queue, u);
u->in_gc_queue = true;
}
assert(m);
while ((seat = m->seat_gc_queue)) {
- LIST_REMOVE(Seat, gc_queue, m->seat_gc_queue, seat);
+ LIST_REMOVE(gc_queue, m->seat_gc_queue, seat);
seat->in_gc_queue = false;
if (seat_check_gc(seat, drop_not_started) == 0) {
}
while ((session = m->session_gc_queue)) {
- LIST_REMOVE(Session, gc_queue, m->session_gc_queue, session);
+ LIST_REMOVE(gc_queue, m->session_gc_queue, session);
session->in_gc_queue = false;
if (session_check_gc(session, drop_not_started) == 0) {
}
while ((user = m->user_gc_queue)) {
- LIST_REMOVE(User, gc_queue, m->user_gc_queue, user);
+ LIST_REMOVE(gc_queue, m->user_gc_queue, user);
user->in_gc_queue = false;
if (user_check_gc(user, drop_not_started) == 0) {
assert(m);
if (m->in_gc_queue)
- LIST_REMOVE(Machine, gc_queue, m->manager->machine_gc_queue, m);
+ LIST_REMOVE(gc_queue, m->manager->machine_gc_queue, m);
if (m->scope) {
hashmap_remove(m->manager->machine_units, m->scope);
if (m->in_gc_queue)
return;
- LIST_PREPEND(Machine, gc_queue, m->manager->machine_gc_queue, m);
+ LIST_PREPEND(gc_queue, m->manager->machine_gc_queue, m);
m->in_gc_queue = true;
}
assert(m);
while ((machine = m->machine_gc_queue)) {
- LIST_REMOVE(Machine, gc_queue, m->machine_gc_queue, machine);
+ LIST_REMOVE(gc_queue, m->machine_gc_queue, machine);
machine->in_gc_queue = false;
if (machine_check_gc(machine, drop_not_started) == 0) {
t *name##_next, *name##_prev
/* Initialize the list's head */
-#define LIST_HEAD_INIT(t,head) \
+#define LIST_HEAD_INIT(head) \
do { \
(head) = NULL; } \
while(false)
/* Initialize a list item */
-#define LIST_INIT(t,name,item) \
+#define LIST_INIT(name,item) \
do { \
- t *_item = (item); \
+ typeof(*(item)) *_item = (item); \
assert(_item); \
_item->name##_prev = _item->name##_next = NULL; \
} while(false)
/* Prepend an item to the list */
-#define LIST_PREPEND(t,name,head,item) \
+#define LIST_PREPEND(name,head,item) \
do { \
- t **_head = &(head), *_item = (item); \
+ typeof(*(head)) **_head = &(head), *_item = (item); \
assert(_item); \
if ((_item->name##_next = *_head)) \
_item->name##_next->name##_prev = _item; \
} while(false)
/* Remove an item from the list */
-#define LIST_REMOVE(t,name,head,item) \
+#define LIST_REMOVE(name,head,item) \
do { \
- t **_head = &(head), *_item = (item); \
+ typeof(*(head)) **_head = &(head), *_item = (item); \
assert(_item); \
if (_item->name##_next) \
_item->name##_next->name##_prev = _item->name##_prev; \
} while(false)
/* Find the head of the list */
-#define LIST_FIND_HEAD(t,name,item,head) \
+#define LIST_FIND_HEAD(name,item,head) \
do { \
- t *_item = (item); \
+ typeof(*(item)) *_item = (item); \
assert(_item); \
while (_item->name##_prev) \
_item = _item->name##_prev; \
} while (false)
/* Find the tail of the list */
-#define LIST_FIND_TAIL(t,name,item,tail) \
+#define LIST_FIND_TAIL(name,item,tail) \
do { \
- t *_item = (item); \
+ typeof(*(item)) *_item = (item); \
assert(_item); \
while (_item->name##_next) \
_item = _item->name##_next; \
} while (false)
/* Insert an item after another one (a = where, b = what) */
-#define LIST_INSERT_AFTER(t,name,head,a,b) \
+#define LIST_INSERT_AFTER(name,head,a,b) \
do { \
- t **_head = &(head), *_a = (a), *_b = (b); \
+ typeof(*(head)) **_head = &(head), *_a = (a), *_b = (b); \
assert(_b); \
if (!_a) { \
if ((_b->name##_next = *_head)) \
return r;
}
- LIST_PREPEND(ExecStatusInfo, exec, i->exec, info);
+ LIST_PREPEND(exec, i->exec, info);
dbus_message_iter_next(&sub);
}
}
while ((p = info.exec)) {
- LIST_REMOVE(ExecStatusInfo, exec, info.exec, p);
+ LIST_REMOVE(exec, info.exec, p);
exec_status_info_free(p);
}
list_item items[4];
list_item *cursor;
- LIST_HEAD_INIT(list_item, head);
+ LIST_HEAD_INIT(head);
assert_se(head == NULL);
for (i = 0; i < ELEMENTSOF(items); i++) {
- LIST_INIT(list_item, item, &items[i]);
+ LIST_INIT(item, &items[i]);
assert_se(LIST_JUST_US(item, &items[i]));
- LIST_PREPEND(list_item, item, head, &items[i]);
+ LIST_PREPEND(item, head, &items[i]);
}
assert_se(!LIST_JUST_US(item, head));
assert_se(items[2].item_prev == &items[3]);
assert_se(items[3].item_prev == NULL);
- LIST_FIND_HEAD(list_item, item, &items[0], cursor);
+ LIST_FIND_HEAD(item, &items[0], cursor);
assert_se(cursor == &items[3]);
- LIST_FIND_TAIL(list_item, item, &items[3], cursor);
+ LIST_FIND_TAIL(item, &items[3], cursor);
assert_se(cursor == &items[0]);
- LIST_REMOVE(list_item, item, head, &items[1]);
+ LIST_REMOVE(item, head, &items[1]);
assert_se(LIST_JUST_US(item, &items[1]));
assert_se(items[0].item_next == NULL);
assert_se(items[2].item_prev == &items[3]);
assert_se(items[3].item_prev == NULL);
- LIST_INSERT_AFTER(list_item, item, head, &items[3], &items[1]);
+ LIST_INSERT_AFTER(item, head, &items[3], &items[1]);
assert_se(items[0].item_next == NULL);
assert_se(items[2].item_next == &items[0]);
assert_se(items[1].item_next == &items[2]);
assert_se(items[1].item_prev == &items[3]);
assert_se(items[3].item_prev == NULL);
- LIST_REMOVE(list_item, item, head, &items[0]);
+ LIST_REMOVE(item, head, &items[0]);
assert_se(LIST_JUST_US(item, &items[0]));
assert_se(items[2].item_next == NULL);
assert_se(items[1].item_prev == &items[3]);
assert_se(items[3].item_prev == NULL);
- LIST_REMOVE(list_item, item, head, &items[1]);
+ LIST_REMOVE(item, head, &items[1]);
assert_se(LIST_JUST_US(item, &items[1]));
assert_se(items[2].item_next == NULL);
assert_se(items[2].item_prev == &items[3]);
assert_se(items[3].item_prev == NULL);
- LIST_REMOVE(list_item, item, head, &items[2]);
+ LIST_REMOVE(item, head, &items[2]);
assert_se(LIST_JUST_US(item, &items[2]));
assert_se(LIST_JUST_US(item, head));
- LIST_REMOVE(list_item, item, head, &items[3]);
+ LIST_REMOVE(item, head, &items[3]);
assert_se(LIST_JUST_US(item, &items[3]));
return 0;