mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 19:21:53 +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:
parent
f2e3f36950
commit
00d4b1e684
@ -1062,13 +1062,11 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
*e = 0;
|
*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) {
|
if (k == cs && memcmp(word, controller_str, cs) == 0) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -539,8 +539,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
|||||||
|
|
||||||
assert(format);
|
assert(format);
|
||||||
|
|
||||||
for (e = format, i = 0; *e && i < n; e ++, i ++) {
|
for (e = format, i = 0; *e && i < n; e ++, i ++)
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
|
||||||
case WORD:
|
case WORD:
|
||||||
@ -554,8 +553,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
|||||||
if (!k)
|
if (!k)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
free(r);
|
free_and_replace(r, k);
|
||||||
r = k;
|
|
||||||
|
|
||||||
word = e-1;
|
word = e-1;
|
||||||
state = VARIABLE;
|
state = VARIABLE;
|
||||||
@ -565,8 +563,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
|||||||
if (!k)
|
if (!k)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
free(r);
|
free_and_replace(r, k);
|
||||||
r = k;
|
|
||||||
|
|
||||||
word = e+1;
|
word = e+1;
|
||||||
state = WORD;
|
state = WORD;
|
||||||
@ -576,8 +573,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
|||||||
if (!k)
|
if (!k)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
free(r);
|
free_and_replace(r, k);
|
||||||
r = k;
|
|
||||||
|
|
||||||
word = e-1;
|
word = e-1;
|
||||||
state = VARIABLE_RAW;
|
state = VARIABLE_RAW;
|
||||||
@ -596,8 +592,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
|||||||
if (!k)
|
if (!k)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
free(r);
|
free_and_replace(r, k);
|
||||||
r = k;
|
|
||||||
|
|
||||||
word = e+1;
|
word = e+1;
|
||||||
state = WORD;
|
state = WORD;
|
||||||
@ -653,8 +648,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
|||||||
if (!k)
|
if (!k)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
free(r);
|
free_and_replace(r, k);
|
||||||
r = k;
|
|
||||||
|
|
||||||
word = e+1;
|
word = e+1;
|
||||||
state = WORD;
|
state = WORD;
|
||||||
@ -673,8 +667,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
|||||||
if (!k)
|
if (!k)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
free(r);
|
free_and_replace(r, k);
|
||||||
r = k;
|
|
||||||
|
|
||||||
word = e--;
|
word = e--;
|
||||||
i--;
|
i--;
|
||||||
@ -682,7 +675,6 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (state == VARIABLE_RAW) {
|
if (state == VARIABLE_RAW) {
|
||||||
const char *t;
|
const char *t;
|
||||||
|
Loading…
Reference in New Issue
Block a user