1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

basic: shorten the code a bit in two places

gcc complains that len might be used unitialized, but afaict, this is not true.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-02-25 17:26:22 +01:00
parent f2e3f36950
commit 00d4b1e684
2 changed files with 8 additions and 18 deletions

View File

@ -1062,13 +1062,11 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
continue;
*e = 0;
FOREACH_WORD_SEPARATOR(word, k, l, ",", state) {
FOREACH_WORD_SEPARATOR(word, k, l, ",", state)
if (k == cs && memcmp(word, controller_str, cs) == 0) {
found = true;
break;
}
}
if (!found)
continue;
}

View File

@ -539,8 +539,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
assert(format);
for (e = format, i = 0; *e && i < n; e ++, i ++) {
for (e = format, i = 0; *e && i < n; e ++, i ++)
switch (state) {
case WORD:
@ -554,8 +553,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
if (!k)
return NULL;
free(r);
r = k;
free_and_replace(r, k);
word = e-1;
state = VARIABLE;
@ -565,8 +563,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
if (!k)
return NULL;
free(r);
r = k;
free_and_replace(r, k);
word = e+1;
state = WORD;
@ -576,8 +573,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
if (!k)
return NULL;
free(r);
r = k;
free_and_replace(r, k);
word = e-1;
state = VARIABLE_RAW;
@ -596,8 +592,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
if (!k)
return NULL;
free(r);
r = k;
free_and_replace(r, k);
word = e+1;
state = WORD;
@ -653,8 +648,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
if (!k)
return NULL;
free(r);
r = k;
free_and_replace(r, k);
word = e+1;
state = WORD;
@ -673,8 +667,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
if (!k)
return NULL;
free(r);
r = k;
free_and_replace(r, k);
word = e--;
i--;
@ -682,7 +675,6 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
}
break;
}
}
if (state == VARIABLE_RAW) {
const char *t;