]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-rules: Use hashmap_ensure_put
authorSusant Sahani <ssahani@vmware.com>
Sun, 17 Jan 2021 09:28:15 +0000 (10:28 +0100)
committerSusant Sahani <ssahani@vmware.com>
Sun, 17 Jan 2021 13:25:15 +0000 (14:25 +0100)
src/udev/udev-rules.c

index 06a97d86713ee8781ab2c25cb7cd62bcda87dd21..c5c2f8cfeacd72e6ab087baf69b3c34344bc5ef1 100644 (file)
@@ -336,11 +336,7 @@ static int rule_resolve_user(UdevRules *rules, const char *name, uid_t *ret) {
         if (!n)
                 return -ENOMEM;
 
-        r = hashmap_ensure_allocated(&rules->known_users, &string_hash_ops);
-        if (r < 0)
-                return r;
-
-        r = hashmap_put(rules->known_users, n, UID_TO_PTR(uid));
+        r = hashmap_ensure_put(&rules->known_users, &string_hash_ops, n, UID_TO_PTR(uid));
         if (r < 0)
                 return r;
 
@@ -375,11 +371,7 @@ static int rule_resolve_group(UdevRules *rules, const char *name, gid_t *ret) {
         if (!n)
                 return -ENOMEM;
 
-        r = hashmap_ensure_allocated(&rules->known_groups, &string_hash_ops);
-        if (r < 0)
-                return r;
-
-        r = hashmap_put(rules->known_groups, n, GID_TO_PTR(gid));
+        r = hashmap_ensure_put(&rules->known_groups, &string_hash_ops, n, GID_TO_PTR(gid));
         if (r < 0)
                 return r;