2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

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: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
Pavel Emelyanov
2012-01-12 21:56:22 +04:00
committed by Cyrill Gorcunov
parent a9e2321c38
commit 02dbadb46f

View File

@@ -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)