Commit 02dbadb4 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

crtools: Sanitize pstree construction

Rename find_pstree_entry into add_<one> (since it doesn't find it)
and move list adding into it.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent a9e2321c
...@@ -798,7 +798,7 @@ err: ...@@ -798,7 +798,7 @@ err:
return -1; return -1;
} }
static struct pstree_item *find_pstree_entry(pid_t pid) static struct pstree_item *add_pstree_entry(pid_t pid, struct list_head *list)
{ {
struct pstree_item *item; struct pstree_item *item;
...@@ -813,6 +813,7 @@ static struct pstree_item *find_pstree_entry(pid_t pid) ...@@ -813,6 +813,7 @@ static struct pstree_item *find_pstree_entry(pid_t pid)
goto err_free; goto err_free;
item->pid = pid; item->pid = pid;
list_add_tail(&item->list, list);
return item; return item;
err_free: err_free:
...@@ -829,12 +830,10 @@ static int collect_pstree(pid_t pid, struct list_head *pstree_list) ...@@ -829,12 +830,10 @@ static int collect_pstree(pid_t pid, struct list_head *pstree_list)
unsigned long i; unsigned long i;
int ret = -1; int ret = -1;
item = find_pstree_entry(pid); item = add_pstree_entry(pid, pstree_list);
if (!item) if (!item)
goto err; goto err;
list_add_tail(&item->list, pstree_list);
for (i = 0; i < item->nr_children; i++) { for (i = 0; i < item->nr_children; i++) {
ret = collect_pstree(item->children[i], pstree_list); ret = collect_pstree(item->children[i], pstree_list);
if (ret) if (ret)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment