[CRIU] [PATCH 3/3] proc_parse: handle a return code of fopen_proc

Andrey Vagin avagin at openvz.org
Tue Apr 21 06:54:39 PDT 2015


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 proc_parse.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index c4365c1..14ef589 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1822,15 +1822,15 @@ int parse_threads(int pid, struct pid **_t, int *_n)
 
 int parse_task_cgroup(int pid, struct list_head *retl, unsigned int *n)
 {
-	int ret = 0;
 	FILE *f;
 
 	f = fopen_proc(pid, "cgroup");
+	if (f == NULL)
+		return -1;
 	while (fgets(buf, BUF_SIZE, f)) {
 		struct cg_ctl *ncc, *cc;
 		char *name, *path = NULL, *e;
 
-		ret = -1;
 		ncc = xmalloc(sizeof(*cc));
 		if (!ncc)
 			goto err;
@@ -1878,7 +1878,7 @@ int parse_task_cgroup(int pid, struct list_head *retl, unsigned int *n)
 err:
 	put_ctls(retl);
 	fclose(f);
-	return ret;
+	return -1;
 }
 
 void put_ctls(struct list_head *l)
-- 
2.1.0



More information about the CRIU mailing list