[Devel] Re: [PATCH] cgroups: skip processes from other namespaces when listing a cgroup
Andrew Morton
akpm at linux-foundation.org
Mon Dec 8 16:19:46 PST 2008
On Mon, 08 Dec 2008 12:52:16 +0530
gowrishankar <gomuthuk at linux.vnet.ibm.com> wrote:
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 35eebd5..25fdd2c 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -2011,14 +2011,15 @@ int cgroup_scan_tasks(struct cgroup_scanner *scan)
> */
> static int pid_array_load(pid_t *pidarray, int npids, struct cgroup *cgrp)
> {
> - int n = 0;
> + int n = 0, pid;
Your email client is replacing tabs with spaces.
> struct cgroup_iter it;
> struct task_struct *tsk;
> cgroup_iter_start(cgrp, &it);
> while ((tsk = cgroup_iter_next(cgrp, &it))) {
> if (unlikely(n == npids))
> break;
> - pidarray[n++] = task_pid_vnr(tsk);
> + if ((pid = task_pid_vnr(tsk)) > 0)
> + pidarray[n++] = pid;
Please avoid the assignment-in-an-if shorthand. We prefer to avoid
tricky C idioms like this keep the code super-simple:
pid = task_pid_vnr(tsk);
if (pid > 0)
scripts/checkpatch.pl can/should be used to detect this, and many
other little things.
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list