From: Zbigniew Jędrzejewski-Szmek Date: Fri, 9 Jul 2021 12:38:23 +0000 (+0200) Subject: core: drop unnecessary initialization X-Git-Tag: v250-rc1~966^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1421705d9a8233a09f6bd7c25436ed48e640a368;p=thirdparty%2Fsystemd.git core: drop unnecessary initialization cunescape() sets output on success, so initialization is not necessary. There was no comment, but I think they may have been added because the compiler wasn't convinced that the return value is non-negative on success. It could have been confused by the int return type on escape*(), which was changed by the one of preceeding commits to ssize_t, or by the length calculation, so add an assert to help the compiler. For some reason coverity thinks the output can be leaked here (CID #1458111). I don't see how. --- diff --git a/src/basic/escape.c b/src/basic/escape.c index 6095ac43b55..9e75c51dfcb 100644 --- a/src/basic/escape.c +++ b/src/basic/escape.c @@ -355,6 +355,7 @@ ssize_t cunescape_length_with_prefix(const char *s, size_t length, const char *p *t = 0; + assert(t >= ans); /* Let static analyzers know that the answer is non-negative. */ *ret = TAKE_PTR(ans); return t - *ret; } diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index a3ac73f8232..6eefaaf27d7 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -4513,7 +4513,7 @@ int config_parse_set_credential( return 0; } } else { - char *unescaped = NULL; + char *unescaped; ssize_t l; /* We support escape codes here, so that users can insert trailing \n if they like */