[systemd-devel] [PATCH 04/26] hashmap: hashmap_move_one should return -ENOENT when 'other' is NULL

Michal Schmidt mschmidt at redhat.com
Thu Oct 16 00:50:42 PDT 2014


-ENOENT is the same return value as if 'other' were an allocated hashmap
that does not contain the key. A NULL hashmap is a possible way of
expressing a hashmap that contains no key.
---
 src/shared/hashmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c
index 4c51705..c4fde89 100644
--- a/src/shared/hashmap.c
+++ b/src/shared/hashmap.c
@@ -886,15 +886,15 @@ int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key) {
         unsigned h_hash, other_hash;
         struct hashmap_entry *e;
 
-        if (!other)
-                return 0;
-
         assert(h);
 
         h_hash = bucket_hash(h, key);
         if (hash_scan(h, h_hash, key))
                 return -EEXIST;
 
+        if (!other)
+                return -ENOENT;
+
         other_hash = bucket_hash(other, key);
         e = hash_scan(other, other_hash, key);
         if (!e)
-- 
2.1.0



More information about the systemd-devel mailing list