]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
remount-fs: Use hashmap_ensure_put
authorSusant Sahani <ssahani@vmware.com>
Mon, 18 Jan 2021 20:38:46 +0000 (21:38 +0100)
committerSusant Sahani <ssahani@vmware.com>
Mon, 18 Jan 2021 20:53:11 +0000 (21:53 +0100)
src/remount-fs/remount-fs.c

index 19f5bd0d1197a7771b9f1a365ea1123ea89349bf..9668a49dc464c29e4721deaf350078dc3663b001 100644 (file)
@@ -31,17 +31,15 @@ static int track_pid(Hashmap **h, const char *path, pid_t pid) {
         assert(path);
         assert(pid_is_valid(pid));
 
-        r = hashmap_ensure_allocated(h, NULL);
-        if (r < 0)
-                return log_oom();
-
         c = strdup(path);
         if (!c)
                 return log_oom();
 
-        r = hashmap_put(*h, PID_TO_PTR(pid), c);
-        if (r < 0)
+        r = hashmap_ensure_put(h, NULL, PID_TO_PTR(pid), c);
+        if (r == -ENOMEM)
                 return log_oom();
+        if (r < 0)
+                return log_error_errno(r, "Failed to store pid " PID_FMT, pid);
 
         TAKE_PTR(c);
         return 0;