]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup-util: use string_hash_ops_free
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 11 Sep 2021 11:29:34 +0000 (20:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 11 Sep 2021 11:29:34 +0000 (20:29 +0900)
src/basic/cgroup-util.c
src/nspawn/nspawn-cgroup.c
src/shared/mount-setup.c

index 7dd8e4e0fc6796f222f3319d69e8c476af01635d..9ba9f375b05a3c18e6b7bcd5b7e4d4967fe6d8a1 100644 (file)
@@ -2001,7 +2001,7 @@ int cg_mask_supported(CGroupMask *ret) {
 }
 
 int cg_kernel_controllers(Set **ret) {
-        _cleanup_set_free_free_ Set *controllers = NULL;
+        _cleanup_set_free_ Set *controllers = NULL;
         _cleanup_fclose_ FILE *f = NULL;
         int r;
 
@@ -2011,10 +2011,6 @@ int cg_kernel_controllers(Set **ret) {
          * and controllers that aren't currently accessible (because not mounted). This does not include "name="
          * pseudo-controllers. */
 
-        controllers = set_new(&string_hash_ops);
-        if (!controllers)
-                return -ENOMEM;
-
         r = fopen_unlocked("/proc/cgroups", "re", &f);
         if (r == -ENOENT) {
                 *ret = NULL;
@@ -2048,7 +2044,7 @@ int cg_kernel_controllers(Set **ret) {
                 if (!cg_controller_is_valid(controller))
                         return -EBADMSG;
 
-                r = set_consume(controllers, TAKE_PTR(controller));
+                r = set_ensure_consume(&controllers, &string_hash_ops_free, TAKE_PTR(controller));
                 if (r < 0)
                         return r;
         }
index cb01b25bc6705b972710e11eae63abefcb8c6533..d472e80c035eb6beaaeb7fdca2a3425a2dce497e 100644 (file)
@@ -406,7 +406,7 @@ static int mount_legacy_cgns_unsupported(
                 uid_t uid_range,
                 const char *selinux_apifs_context) {
 
-        _cleanup_set_free_free_ Set *controllers = NULL;
+        _cleanup_set_free_ Set *controllers = NULL;
         const char *cgroup_root;
         int r;
 
index 3b309828351c5ab541d766b1cbb0de6bff544676..0f2fb5d098a4592253e7d0abb5fc9f4cb4e70b4d 100644 (file)
@@ -292,7 +292,7 @@ static int symlink_controller(const char *target, const char *alias) {
 }
 
 int mount_cgroup_controllers(void) {
-        _cleanup_set_free_free_ Set *controllers = NULL;
+        _cleanup_set_free_ Set *controllers = NULL;
         int r;
 
         if (!cg_is_legacy_wanted())