From: Susant Sahani Date: Wed, 20 Jan 2021 11:46:42 +0000 (+0100) Subject: journal: Use cleanup_free X-Git-Tag: v248-rc1~286^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8231485bc5b2bc04cb2ec86b7841483bdc3e6b1b;p=thirdparty%2Fsystemd.git journal: Use cleanup_free --- diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c index 46b1cba1452..ff26f5d7e79 100644 --- a/src/libsystemd/sd-journal/sd-journal.c +++ b/src/libsystemd/sd-journal/sd-journal.c @@ -63,7 +63,7 @@ static bool journal_pid_changed(sd_journal *j) { } static int journal_put_error(sd_journal *j, int r, const char *path) { - char *copy; + _cleanup_free_ char *copy = NULL; int k; /* Memorize an error we encountered, and store which @@ -84,19 +84,17 @@ static int journal_put_error(sd_journal *j, int r, const char *path) { copy = strdup(path); if (!copy) return -ENOMEM; - } else - copy = NULL; + } k = hashmap_ensure_put(&j->errors, NULL, INT_TO_PTR(r), copy); if (k < 0) { - free(copy); - if (k == -EEXIST) return 0; return k; } + TAKE_PTR(copy); return 0; }