]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Journal: Use hashmap_ensure_put
authorSusant Sahani <ssahani@vmware.com>
Wed, 20 Jan 2021 11:29:08 +0000 (12:29 +0100)
committerSusant Sahani <ssahani@vmware.com>
Wed, 20 Jan 2021 14:08:30 +0000 (15:08 +0100)
src/libsystemd/sd-journal/sd-journal.c

index 27251a25970df17c00afb20e331531817eefb4ea..46b1cba1452d0991e4c53cc3cde35eb44f723ff3 100644 (file)
@@ -80,10 +80,6 @@ static int journal_put_error(sd_journal *j, int r, const char *path) {
         if (r >= 0)
                 return r;
 
-        k = hashmap_ensure_allocated(&j->errors, NULL);
-        if (k < 0)
-                return k;
-
         if (path) {
                 copy = strdup(path);
                 if (!copy)
@@ -91,7 +87,7 @@ static int journal_put_error(sd_journal *j, int r, const char *path) {
         } else
                 copy = NULL;
 
-        k = hashmap_put(j->errors, INT_TO_PTR(r), copy);
+        k = hashmap_ensure_put(&j->errors, NULL, INT_TO_PTR(r), copy);
         if (k < 0) {
                 free(copy);