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: ...@@ -687,7 +687,7 @@ err:
return ret; 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; struct dirent *de;
DIR *dir; DIR *dir;
...@@ -717,7 +717,7 @@ static int parse_threads(pid_t pid, int *nr_threads, u32 **threads) ...@@ -717,7 +717,7 @@ static int parse_threads(pid_t pid, int *nr_threads, u32 **threads)
return 0; 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; FILE *file;
char *tok; char *tok;
...@@ -757,39 +757,28 @@ err: ...@@ -757,39 +757,28 @@ err:
static struct pstree_item *find_pstree_entry(pid_t pid) static struct pstree_item *find_pstree_entry(pid_t pid)
{ {
struct pstree_item *item = NULL; struct pstree_item *item;
u32 *children = NULL;
u32 *threads = NULL;
u32 nr_allocated = 0;
int nr_children = 0;
int nr_threads = 0;
pr_debug("pid: %d\n", pid); pr_debug("pid: %d\n", pid);
item = xzalloc(sizeof(*item)); item = xzalloc(sizeof(*item));
if (!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; goto err_free;
if (parse_children(pid, &nr_children, &children)) if (parse_children(pid, &item->nr_children, &item->children))
goto err_free; goto err_free;
item->pid = pid; item->pid = pid;
item->nr_children = nr_children;
item->nr_threads = nr_threads;
item->children = children;
item->threads = threads;
out:
return item; return item;
err_free: err_free:
xfree(threads); xfree(item->threads);
xfree(children); xfree(item->children);
xfree(item); xfree(item);
item = NULL; err:
goto out; return NULL;
} }
static int collect_pstree(pid_t pid, struct list_head *pstree_list) 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