From: Dave Hansen <dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: gowrishankar
<gomuthuk-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Sukadev Bhattiprolu
<sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
Balbir <balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Subject: Re: [PATCH] cgroups: not to iterate other namespace process inside container
Date: Mon, 08 Dec 2008 08:18:26 -0800 [thread overview]
Message-ID: <1228753106.9737.7.camel@nimitz> (raw)
In-Reply-To: <493CC423.5060601-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
On Mon, 2008-12-08 at 12:22 +0530, gowrishankar wrote:
> static int pid_array_load(pid_t *pidarray, int npids, struct cgroup *cgrp)
> {
> - int n = 0;
> + int n = 0, ret;
Please declare these separately unless there's a really good reason not
to.
> 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 ((ret = task_pid_vnr(tsk)) > 0)
> + pidarray[n++] = ret;
We almost never write things this way in the kernel. Too many people
mistake this if() form for a coding mistake. Please separate out the
assignment and condition:
ret = task_pid_vnr(tsk);
if (ret > 0)
...
Also, 'ret' is generally used to indicate that the variable is going to
be returned from the function. This one is not.
> }
> cgroup_iter_end(cgrp, &it);
> return n;
I'm not sure this is a good patch, but it needs some CodingStyle love
either way.
I could have sworn we had some function like
task_is_in_current_active_pid_ns(), but I looked and couldn't find it.
Maybe we should add one instead of open-coding this everywhere.
-- Dave
next prev parent reply other threads:[~2008-12-08 16:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-08 6:52 [PATCH] cgroups: not to iterate other namespace process inside container gowrishankar
[not found] ` <493CC423.5060601-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-12-08 6:31 ` [Devel] " Paul Menage
[not found] ` <6599ad830812072231l25aadbd8u6653cda3a22ddc2d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-12-08 6:56 ` Balbir Singh
2008-12-08 16:18 ` Dave Hansen [this message]
2008-12-09 23:37 ` Sukadev Bhattiprolu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1228753106.9737.7.camel@nimitz \
--to=dave-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
--cc=balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=gomuthuk-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.