]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: context - Use _cleanup_free_
authorSusant Sahani <ssahani@vmware.com>
Mon, 18 Jan 2021 11:13:51 +0000 (12:13 +0100)
committerSusant Sahani <ssahani@vmware.com>
Mon, 18 Jan 2021 11:13:51 +0000 (12:13 +0100)
src/journal/journald-context.c

index 8736495a4bdfb1eee441826413643e9a35756960..577d5254c5c88d724bcf5d939b5db4387db67380 100644 (file)
@@ -102,7 +102,7 @@ static int client_context_compare(const void *a, const void *b) {
 }
 
 static int client_context_new(Server *s, pid_t pid, ClientContext **ret) {
-        ClientContext *c;
+        _cleanup_free_ ClientContext *c = NULL;
         int r;
 
         assert(s);
@@ -137,12 +137,10 @@ static int client_context_new(Server *s, pid_t pid, ClientContext **ret) {
         };
 
         r = hashmap_put(s->client_contexts, PID_TO_PTR(pid), c);
-        if (r < 0) {
-                free(c);
+        if (r < 0)
                 return r;
-        }
 
-        *ret = c;
+        *ret = TAKE_PTR(c);
         return 0;
 }