]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
devnode-acl: use set_put_strdup_full() and set_ensure_consume()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 3 Jun 2022 09:01:35 +0000 (18:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 10 Jun 2022 01:47:25 +0000 (10:47 +0900)
src/shared/devnode-acl.c

index 357efc19302d6bec78038d2ff4505c6e0e173cab..a87a34850942c6831ab8824272db0768add334cf 100644 (file)
@@ -141,16 +141,12 @@ int devnode_acl_all(const char *seat,
                     bool add, uid_t new_uid) {
 
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-        _cleanup_set_free_free_ Set *nodes = NULL;
+        _cleanup_set_free_ Set *nodes = NULL;
         _cleanup_closedir_ DIR *dir = NULL;
         sd_device *d;
         char *n;
         int r;
 
-        nodes = set_new(&path_hash_ops);
-        if (!nodes)
-                return -ENOMEM;
-
         r = sd_device_enumerator_new(&e);
         if (r < 0)
                 return r;
@@ -185,7 +181,7 @@ int devnode_acl_all(const char *seat,
                         continue;
 
                 log_device_debug(d, "Found udev node %s for seat %s", node, seat);
-                r = set_put_strdup(&nodes, node);
+                r = set_put_strdup_full(&nodes, &path_hash_ops_free, node);
                 if (r < 0)
                         return r;
         }
@@ -206,7 +202,7 @@ int devnode_acl_all(const char *seat,
                         }
 
                         log_debug("Found static node %s for seat %s", n, seat);
-                        r = set_consume(nodes, n);
+                        r = set_ensure_consume(&nodes, &path_hash_ops_free, n);
                         if (r < 0)
                                 return r;
                 }