From 08ff6fcffb6fdfc220ebbba5dd60843a0fc71393 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Mon, 18 Jan 2021 12:13:51 +0100 Subject: [PATCH] journal: context - Use _cleanup_free_ --- src/journal/journald-context.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c index 8736495a4b..577d5254c5 100644 --- a/src/journal/journald-context.c +++ b/src/journal/journald-context.c @@ -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; }