Always use the macros for downcasting.
Remove a few obviously pointless casts.
assert(a);
LIST_FOREACH(units_by_type, other, UNIT(a)->manager->units_by_type[UNIT_MOUNT])
- if ((r = automount_add_one_mount_link(a, (Mount*) other)) < 0)
+ if ((r = automount_add_one_mount_link(a, MOUNT(other))) < 0)
return r;
return 0;
assert(rvalue);
assert(data);
- s = (Socket*) data;
+ s = SOCKET(data);
if (!(p = new0(SocketPort, 1)))
return -ENOMEM;
assert(rvalue);
assert(data);
- s = (Socket*) data;
+ s = SOCKET(data);
if ((b = socket_address_bind_ipv6_only_from_string(rvalue)) < 0) {
int r;
}
static unsigned manager_dispatch_cleanup_queue(Manager *m) {
- Unit *meta;
+ Unit *u;
unsigned n = 0;
assert(m);
- while ((meta = m->cleanup_queue)) {
- assert(meta->in_cleanup_queue);
+ while ((u = m->cleanup_queue)) {
+ assert(u->in_cleanup_queue);
- unit_free((Unit*) meta);
+ unit_free(u);
n++;
}
}
static unsigned manager_dispatch_gc_queue(Manager *m) {
- Unit *meta;
+ Unit *u;
unsigned n = 0;
unsigned gc_marker;
gc_marker = m->gc_marker;
- while ((meta = m->gc_queue)) {
- assert(meta->in_gc_queue);
+ while ((u = m->gc_queue)) {
+ assert(u->in_gc_queue);
- unit_gc_sweep((Unit*) meta, gc_marker);
+ unit_gc_sweep(u, gc_marker);
- LIST_REMOVE(Unit, gc_queue, m->gc_queue, meta);
- meta->in_gc_queue = false;
+ LIST_REMOVE(Unit, gc_queue, m->gc_queue, u);
+ u->in_gc_queue = false;
n++;
- if (meta->gc_marker == gc_marker + GC_OFFSET_BAD ||
- meta->gc_marker == gc_marker + GC_OFFSET_UNSURE) {
- log_debug("Collecting %s", meta->id);
- meta->gc_marker = gc_marker + GC_OFFSET_BAD;
- unit_add_to_cleanup_queue((Unit*) meta);
+ if (u->gc_marker == gc_marker + GC_OFFSET_BAD ||
+ u->gc_marker == gc_marker + GC_OFFSET_UNSURE) {
+ log_debug("Collecting %s", u->id);
+ u->gc_marker = gc_marker + GC_OFFSET_BAD;
+ unit_add_to_cleanup_queue(u);
}
}
}
unsigned manager_dispatch_load_queue(Manager *m) {
- Unit *meta;
+ Unit *u;
unsigned n = 0;
assert(m);
/* Dispatches the load queue. Takes a unit from the queue and
* tries to load its data until the queue is empty */
- while ((meta = m->load_queue)) {
- assert(meta->in_load_queue);
+ while ((u = m->load_queue)) {
+ assert(u->in_load_queue);
- unit_load((Unit*) meta);
+ unit_load(u);
n++;
}
unsigned manager_dispatch_dbus_queue(Manager *m) {
Job *j;
- Unit *meta;
+ Unit *u;
unsigned n = 0;
assert(m);
m->dispatching_dbus_queue = true;
- while ((meta = m->dbus_unit_queue)) {
- assert(meta->in_dbus_queue);
+ while ((u = m->dbus_unit_queue)) {
+ assert(u->in_dbus_queue);
- bus_unit_send_change_signal((Unit*) meta);
+ bus_unit_send_change_signal(u);
n++;
}
* above us in the hierarchy */
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_MOUNT]) {
- Mount *n = (Mount*) other;
+ Mount *n = MOUNT(other);
MountParameters *pn;
if (n == m)
assert(m);
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_SWAP])
- if ((r = swap_add_one_mount_link((Swap*) other, m)) < 0)
+ if ((r = swap_add_one_mount_link(SWAP(other), m)) < 0)
return r;
return 0;
assert(m);
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_PATH])
- if ((r = path_add_one_mount_link((Path*) other, m)) < 0)
+ if ((r = path_add_one_mount_link(PATH(other), m)) < 0)
return r;
return 0;
assert(m);
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_AUTOMOUNT])
- if ((r = automount_add_one_mount_link((Automount*) other, m)) < 0)
+ if ((r = automount_add_one_mount_link(AUTOMOUNT(other), m)) < 0)
return r;
return 0;
assert(m);
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_SOCKET])
- if ((r = socket_add_one_mount_link((Socket*) other, m)) < 0)
+ if ((r = socket_add_one_mount_link(SOCKET(other), m)) < 0)
return r;
return 0;
}
void mount_fd_event(Manager *m, int events) {
- Unit *meta;
+ Unit *u;
int r;
assert(m);
log_error("Failed to reread /proc/self/mountinfo: %s", strerror(-r));
/* Reset flags, just in case, for later calls */
- LIST_FOREACH(units_by_type, meta, m->units_by_type[UNIT_MOUNT]) {
- Mount *mount = (Mount*) meta;
+ LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
+ Mount *mount = MOUNT(u);
mount->is_mounted = mount->just_mounted = mount->just_changed = false;
}
manager_dispatch_load_queue(m);
- LIST_FOREACH(units_by_type, meta, m->units_by_type[UNIT_MOUNT]) {
- Mount *mount = (Mount*) meta;
+ LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
+ Mount *mount = MOUNT(u);
if (!mount->is_mounted) {
/* This has just been unmounted. */
assert(p);
LIST_FOREACH(units_by_type, other, UNIT(p)->manager->units_by_type[UNIT_MOUNT])
- if ((r = path_add_one_mount_link(p, (Mount*) other)) < 0)
+ if ((r = path_add_one_mount_link(p, MOUNT(other))) < 0)
return r;
return 0;
UnitDependency d;
bool special_s, special_t;
- t = (Service*) other;
+ t = SERVICE(other);
if (s == t)
continue;
Service *t;
UnitDependency d;
- t = (Service*) other;
+ t = SERVICE(other);
if (s == t)
continue;
assert(s);
LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_MOUNT])
- if ((r = socket_add_one_mount_link(s, (Mount*) other)) < 0)
+ if ((r = socket_add_one_mount_link(s, MOUNT(other))) < 0)
return r;
return 0;
assert(s);
LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_MOUNT])
- if ((r = swap_add_one_mount_link(s, (Mount*) other)) < 0)
+ if ((r = swap_add_one_mount_link(s, MOUNT(other))) < 0)
return r;
return 0;
}
int swap_fd_event(Manager *m, int events) {
- Unit *meta;
+ Unit *u;
int r;
assert(m);
log_error("Failed to reread /proc/swaps: %s", strerror(-r));
/* Reset flags, just in case, for late calls */
- LIST_FOREACH(units_by_type, meta, m->units_by_type[UNIT_SWAP]) {
- Swap *swap = (Swap*) meta;
+ LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_SWAP]) {
+ Swap *swap = SWAP(u);
swap->is_active = swap->just_activated = false;
}
manager_dispatch_load_queue(m);
- LIST_FOREACH(units_by_type, meta, m->units_by_type[UNIT_SWAP]) {
- Swap *swap = (Swap*) meta;
+ LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_SWAP]) {
+ Swap *swap = SWAP(u);
if (!swap->is_active) {
/* This has just been deactivated */