From: Susant Sahani Date: Mon, 18 Jan 2021 11:13:51 +0000 (+0100) Subject: journal: context - Use _cleanup_free_ X-Git-Tag: v248-rc1~306^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08ff6fcffb6fdfc220ebbba5dd60843a0fc71393;p=thirdparty%2Fsystemd.git journal: context - Use _cleanup_free_ --- diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c index 8736495a4bd..577d5254c5c 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; }