1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-21 22:04:01 +03:00

core: use RET_GATHER more

This commit is contained in:
Mike Yuan 2024-03-22 01:23:07 +08:00
parent e9fa1bf704
commit 4ecb673e6f
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3
3 changed files with 19 additions and 32 deletions

View File

@ -471,21 +471,14 @@ static int automount_send_ready(Automount *a, Set *tokens, int status) {
r = 0;
/* Autofs thankfully does not hand out 0 as a token */
while ((token = PTR_TO_UINT(set_steal_first(tokens)))) {
int k;
while ((token = PTR_TO_UINT(set_steal_first(tokens))))
/* Autofs fun fact:
*
* if you pass a positive status code here, kernels
* prior to 4.12 will freeze! Yay! */
k = autofs_send_ready(UNIT(a)->manager->dev_autofs_fd,
ioctl_fd,
token,
status);
if (k < 0)
r = k;
}
* if you pass a positive status code here, kernels prior to 4.12 will freeze! Yay! */
RET_GATHER(r, autofs_send_ready(UNIT(a)->manager->dev_autofs_fd,
ioctl_fd,
token,
status));
return r;
}

View File

@ -697,20 +697,20 @@ static int mount_load(Unit *u) {
mount_load_root_mount(u);
bool fragment_optional = m->from_proc_self_mountinfo || u->perpetual;
r = unit_load_fragment_and_dropin(u, !fragment_optional);
bool from_kernel = m->from_proc_self_mountinfo || u->perpetual;
r = unit_load_fragment_and_dropin(u, /* fragment_required = */ !from_kernel);
/* Add in some extras. Note we do this in all cases (even if we failed to load the unit) when announced by the
* kernel, because we need some things to be set up no matter what when the kernel establishes a mount and thus
* we need to update the state in our unit to track it. After all, consider that we don't allow changing the
* 'slice' field for a unit once it is active. */
if (u->load_state == UNIT_LOADED || m->from_proc_self_mountinfo || u->perpetual)
q = mount_add_extras(m);
if (u->load_state == UNIT_LOADED || from_kernel)
RET_GATHER(r, mount_add_extras(m));
if (r < 0)
return r;
if (q < 0)
return q;
if (u->load_state != UNIT_LOADED)
return 0;

View File

@ -351,18 +351,16 @@ static int swap_load(Unit *u) {
assert(u->load_state == UNIT_STUB);
/* Load a .swap file */
bool fragment_optional = s->from_proc_swaps;
r = unit_load_fragment_and_dropin(u, !fragment_optional);
r = unit_load_fragment_and_dropin(u, /* fragment_required = */ !s->from_proc_swaps);
/* Add in some extras, and do so either when we successfully loaded something or when /proc/swaps is
* already active. */
if (u->load_state == UNIT_LOADED || s->from_proc_swaps)
q = swap_add_extras(s);
RET_GATHER(r, swap_add_extras(s));
if (r < 0)
return r;
if (q < 0)
return q;
if (u->load_state != UNIT_LOADED)
return 0;
@ -1399,20 +1397,16 @@ int swap_process_device_new(Manager *m, sd_device *dev) {
int swap_process_device_remove(Manager *m, sd_device *dev) {
const char *dn;
int r;
Swap *s;
int r;
r = sd_device_get_devname(dev, &dn);
if (r < 0)
return 0;
while ((s = hashmap_get(m->swaps_by_devnode, dn))) {
int q;
q = swap_set_devnode(s, NULL);
if (q < 0)
r = q;
}
r = 0;
while ((s = hashmap_get(m->swaps_by_devnode, dn)))
RET_GATHER(r, swap_set_devnode(s, NULL));
return r;
}