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:
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;
......@@ -813,6 +813,7 @@ static struct pstree_item *find_pstree_entry(pid_t pid)
goto err_free;
item->pid = pid;
list_add_tail(&item->list, list);
return item;
err_free:
......@@ -829,12 +830,10 @@ static int collect_pstree(pid_t pid, struct list_head *pstree_list)
unsigned long i;
int ret = -1;
item = find_pstree_entry(pid);
item = add_pstree_entry(pid, pstree_list);
if (!item)
goto err;
list_add_tail(&item->list, pstree_list);
for (i = 0; i < item->nr_children; i++) {
ret = collect_pstree(item->children[i], pstree_list);
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