basic/env-util: silence two gcc warnings

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-03-31 18:24:54 +02:00
parent c26f7dd9f0
commit 1dbd0bdb3a
+6 -7
View File
@@ -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;