From: Lennart Poettering Date: Thu, 18 Oct 2018 14:08:13 +0000 (+0200) Subject: cgroup-util: FOREACH_LINE() excorcism X-Git-Tag: v240~513^2~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d2b39cb6062d446b2542359cb31beff9eecff70c;p=thirdparty%2Fsystemd.git cgroup-util: FOREACH_LINE() excorcism --- diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index b725a177613..e010fc7b5ac 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -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:");