From: Lennart Poettering Date: Thu, 19 Jan 2023 19:27:26 +0000 (+0100) Subject: journal: modernize match_make_string() X-Git-Tag: v253-rc1~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6320409c56163c03a21b966e58f55d50517dbaf9;p=thirdparty%2Fsystemd.git journal: modernize match_make_string() --- diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c index 204886b1e43..ac8ca0f54b4 100644 --- a/src/libsystemd/sd-journal/sd-journal.c +++ b/src/libsystemd/sd-journal/sd-journal.c @@ -367,7 +367,7 @@ _public_ int sd_journal_add_disjunction(sd_journal *j) { } static char *match_make_string(Match *m) { - char *p = NULL, *r; + _cleanup_free_ char *p = NULL; bool enclose = false; if (!m) @@ -377,34 +377,25 @@ static char *match_make_string(Match *m) { return cescape_length(m->data, m->size); LIST_FOREACH(matches, i, m->matches) { - char *t, *k; + _cleanup_free_ char *t = NULL; t = match_make_string(i); if (!t) - return mfree(p); + return NULL; if (p) { - k = strjoin(p, m->type == MATCH_OR_TERM ? " OR " : " AND ", t); - free(p); - free(t); - - if (!k) + if (!strextend(&p, m->type == MATCH_OR_TERM ? " OR " : " AND ", t)) return NULL; - p = k; - enclose = true; } else - p = t; + p = TAKE_PTR(t); } - if (enclose) { - r = strjoin("(", p, ")"); - free(p); - return r; - } + if (enclose) + return strjoin("(", p, ")"); - return p; + return TAKE_PTR(p); } char *journal_make_match_string(sd_journal *j) {