diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-09-11 13:26:58 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-09-11 13:26:58 +0200 |
commit | dccdbf9b35f6ab536b19685d7b194cb0d636da6e (patch) | |
tree | f2b663306ec3d0038c78ff723f7b41defcd7de40 /src/basic/cgroup-util.c | |
parent | Merge pull request #20699 from yuwata/network-drop-foreign (diff) | |
download | systemd-dccdbf9b35f6ab536b19685d7b194cb0d636da6e.tar.xz systemd-dccdbf9b35f6ab536b19685d7b194cb0d636da6e.zip |
cgroup-util: use _cleanup_free_ attribute
Diffstat (limited to 'src/basic/cgroup-util.c')
-rw-r--r-- | src/basic/cgroup-util.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 95891f68aa..7dd8e4e0fc 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -2027,7 +2027,7 @@ int cg_kernel_controllers(Set **ret) { (void) read_line(f, SIZE_MAX, NULL); for (;;) { - char *controller; + _cleanup_free_ char *controller = NULL; int enabled = 0; errno = 0; @@ -2042,17 +2042,13 @@ int cg_kernel_controllers(Set **ret) { return -EBADMSG; } - if (!enabled) { - free(controller); + if (!enabled) continue; - } - if (!cg_controller_is_valid(controller)) { - free(controller); + if (!cg_controller_is_valid(controller)) return -EBADMSG; - } - r = set_consume(controllers, controller); + r = set_consume(controllers, TAKE_PTR(controller)); if (r < 0) return r; } |