diff --git a/src/core/automount.c b/src/core/automount.c index 38284f60a65..8c5a57588da 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -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; } diff --git a/src/core/mount.c b/src/core/mount.c index bdac53cc248..0d346c985f7 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -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; diff --git a/src/core/swap.c b/src/core/swap.c index 01537df8fe2..e2019587ff4 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -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; }