From 1dbd0bdb3a8e80501b0c47a62f83ed28fd8311f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 31 Mar 2021 18:13:00 +0200 Subject: [PATCH] basic/env-util: silence two gcc warnings --- src/basic/env-util.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/basic/env-util.c b/src/basic/env-util.c index c110a750a55..0e8c2878d61 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -515,10 +515,10 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) { ALTERNATE_VALUE, } state = WORD; - const char *e, *word = format, *test_value; + const char *e, *word = format, *test_value = NULL; /* test_value is initialized to appease gcc */ char *k; _cleanup_free_ char *r = NULL; - size_t i, len; + size_t i, len = 0; /* len is initialized to appease gcc */ int nest = 0; assert(format); @@ -581,13 +581,12 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) { word = e+1; state = WORD; } else if (*e == ':') { - if (!(flags & REPLACE_ENV_ALLOW_EXTENDED)) + if (flags & REPLACE_ENV_ALLOW_EXTENDED) { + len = e - word - 2; + state = TEST; + } else /* Treat this as unsupported syntax, i.e. do no replacement */ state = WORD; - else { - len = e-word-2; - state = TEST; - } } break; -- 2.47.3