diff options
author | Mike Yuan <me@yhndnzj.com> | 2024-03-21 18:23:07 +0100 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2024-03-21 18:36:37 +0100 |
commit | 4ecb673e6fb4898c29af0a2e20305f89a150b3ba (patch) | |
tree | dcacb008c5204aaea807bf0517f3894305222288 /src/core/swap.c | |
parent | core: use ASSERT_PTR(CAST(u)) everywhere (diff) | |
download | systemd-4ecb673e6fb4898c29af0a2e20305f89a150b3ba.tar.xz systemd-4ecb673e6fb4898c29af0a2e20305f89a150b3ba.zip |
core: use RET_GATHER more
Diffstat (limited to '')
-rw-r--r-- | src/core/swap.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/core/swap.c b/src/core/swap.c index 01537df8fe..e2019587ff 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; } |