]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup-util: FOREACH_LINE() excorcism
authorLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 14:08:13 +0000 (16:08 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 14:23:45 +0000 (16:23 +0200)
src/basic/cgroup-util.c

index b725a1776138909465208804bd1372267627279f..e010fc7b5ac4122213b9f56b07ce2a0baac8f68e 100644 (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:");