Commit ec8cdcd7 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

crtools: Cleanup pstree entry code

After all the child/threads stuff is moved to helpers it is
possible to remove some unneeded code paths and local variables.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 8340bff8
......@@ -687,7 +687,7 @@ err:
return ret;
}
static int parse_threads(pid_t pid, int *nr_threads, u32 **threads)
static int parse_threads(pid_t pid, u32 *nr_threads, u32 **threads)
{
struct dirent *de;
DIR *dir;
......@@ -717,7 +717,7 @@ static int parse_threads(pid_t pid, int *nr_threads, u32 **threads)
return 0;
}
static int parse_children(pid_t pid, int *nr_children, u32 **children)
static int parse_children(pid_t pid, u32 *nr_children, u32 **children)
{
FILE *file;
char *tok;
......@@ -757,39 +757,28 @@ err:
static struct pstree_item *find_pstree_entry(pid_t pid)
{
struct pstree_item *item = NULL;
u32 *children = NULL;
u32 *threads = NULL;
u32 nr_allocated = 0;
int nr_children = 0;
int nr_threads = 0;
struct pstree_item *item;
pr_debug("pid: %d\n", pid);
item = xzalloc(sizeof(*item));
if (!item)
goto out;
goto err;
if (parse_threads(pid, &nr_threads, &threads))
if (parse_threads(pid, &item->nr_threads, &item->threads))
goto err_free;
if (parse_children(pid, &nr_children, &children))
if (parse_children(pid, &item->nr_children, &item->children))
goto err_free;
item->pid = pid;
item->nr_children = nr_children;
item->nr_threads = nr_threads;
item->children = children;
item->threads = threads;
out:
return item;
err_free:
xfree(threads);
xfree(children);
xfree(item->threads);
xfree(item->children);
xfree(item);
item = NULL;
goto out;
err:
return NULL;
}
static int collect_pstree(pid_t pid, struct list_head *pstree_list)
......
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