static int device_following_set(Unit *u, Set **_set) {
Device *d = DEVICE(u), *other;
- Set *set;
+ _cleanup_(set_freep) Set *set = NULL;
int r;
assert(d);
LIST_FOREACH_AFTER(same_sysfs, other, d) {
r = set_put(set, other);
if (r < 0)
- goto fail;
+ return r;
}
LIST_FOREACH_BEFORE(same_sysfs, other, d) {
r = set_put(set, other);
if (r < 0)
- goto fail;
+ return r;
}
- *_set = set;
+ *_set = TAKE_PTR(set);
return 1;
-
-fail:
- set_free(set);
- return r;
}
static void device_shutdown(Manager *m) {
static int swap_following_set(Unit *u, Set **_set) {
Swap *s = SWAP(u), *other;
- Set *set;
+ _cleanup_(set_freep) Set *set = NULL;
int r;
assert(s);
LIST_FOREACH_OTHERS(same_devnode, other, s) {
r = set_put(set, other);
if (r < 0)
- goto fail;
+ return r;
}
- *_set = set;
+ *_set = TAKE_PTR(set);
return 1;
-
-fail:
- set_free(set);
- return r;
}
static void swap_shutdown(Manager *m) {
}
static Set *unit_pid_set(pid_t main_pid, pid_t control_pid) {
- Set *pid_set;
+ _cleanup_(set_freep) Set *pid_set = NULL;
int r;
pid_set = set_new(NULL);
if (main_pid > 0) {
r = set_put(pid_set, PID_TO_PTR(main_pid));
if (r < 0)
- goto fail;
+ return NULL;
}
if (control_pid > 0) {
r = set_put(pid_set, PID_TO_PTR(control_pid));
if (r < 0)
- goto fail;
+ return NULL;
}
- return pid_set;
-
-fail:
- set_free(pid_set);
- return NULL;
+ return TAKE_PTR(pid_set);
}
int unit_kill_common(