cgroup-util: FOREACH_LINE() excorcism
This commit is contained in:
parent
51a85e5ec2
commit
d2b39cb606
|
@ -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) {
|
int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
|
||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
char line[LINE_MAX];
|
|
||||||
const char *fs, *controller_str;
|
const char *fs, *controller_str;
|
||||||
|
int unified, r;
|
||||||
size_t cs = 0;
|
size_t cs = 0;
|
||||||
int unified;
|
|
||||||
|
|
||||||
assert(path);
|
assert(path);
|
||||||
assert(pid >= 0);
|
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);
|
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
|
||||||
|
|
||||||
FOREACH_LINE(line, f, return -errno) {
|
for (;;) {
|
||||||
|
_cleanup_free_ char *line = NULL;
|
||||||
char *e, *p;
|
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) {
|
if (unified) {
|
||||||
e = startswith(line, "0:");
|
e = startswith(line, "0:");
|
||||||
|
|
Loading…
Reference in a new issue