Re: [PATCH] cgroups: skip processes from other namespaces when listing a cgroup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 08 Dec 2008 12:52:16 +0530
gowrishankar <gomuthuk@xxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/containers

[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux