1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00

cgroup-util: FOREACH_LINE() excorcism

This commit is contained in:
Lennart Poettering 2018-10-18 16:08:13 +02:00
parent 51a85e5ec2
commit d2b39cb606

View File

@ -985,10 +985,9 @@ int cg_get_xattr(const char *controller, const char *path, const char *name, voi
int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
_cleanup_fclose_ FILE *f = NULL;
char line[LINE_MAX];
const char *fs, *controller_str;
int unified, r;
size_t cs = 0;
int unified;
assert(path);
assert(pid >= 0);
@ -1018,10 +1017,15 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
FOREACH_LINE(line, f, return -errno) {
for (;;) {
_cleanup_free_ char *line = NULL;
char *e, *p;
truncate_nl(line);
r = read_line(f, LONG_LINE_MAX, &line);
if (r < 0)
return r;
if (r == 0)
break;
if (unified) {
e = startswith(line, "0:");