From a3b42af5b65dc4a3709fa1e77968dcb578497ffa Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Sun, 17 Jan 2021 10:28:15 +0100 Subject: [PATCH] udev-rules: Use hashmap_ensure_put --- src/udev/udev-rules.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 06a97d86713..c5c2f8cfeac 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -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; -- 2.47.3