[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3159d545105613416961ff50572f6686cdee03ee.camel@kellner.me>
Date: Mon, 14 Oct 2019 17:20:57 +0200
From: Christian Kellner <christian@...lner.me>
To: Jann Horn <jannh@...gle.com>,
Christian Brauner <christian.brauner@...ntu.com>
Cc: Andrea Arcangeli <aarcange@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Aleksa Sarai <cyphar@...har.com>,
Elena Reshetova <elena.reshetova@...el.com>,
Roman Gushchin <guro@...com>,
"Dmitry V. Levin" <ldv@...linux.org>,
Linux API <linux-api@...r.kernel.org>,
kernel list <linux-kernel@...r.kernel.org>,
Michal Hocko <mhocko@...e.com>, Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH] pidfd: add NSpid entries to fdinfo
On Mon, 2019-10-14 at 17:10 +0200, Jann Horn wrote:
> On Mon, Oct 14, 2019 at 12:32 PM Christian Brauner wrote:
> > On Mon, Oct 14, 2019 at 11:43:01AM +0200, Christian Kellner wrote:
> > You could probably do:
> >
> > #ifdef CONFIG_PID_NS
> > seq_put_decimal_ull(m, "\nNSpid:\t", nr);
> > for (i = ns->level + 1; i <= pid->level && nr; i++)
> > seq_put_decimal_ull(m, "\t", pid->numbers[i].nr);
> > #endif
>
> Personally, I dislike hiding the precondition for running the loop in
> the loop statement like that. While it makes the code more concise,
> it somewhat obfuscates the high-level logic at a first glance.
I agree and it has the side-effect of needing another #ifdef at the end
of the variable block for "i". I think I will go with:
if (nr) {
int i;
/* If nr is non-zero it means that 'pid' is valid and that
* ns, i.e. the pid namespace associated with the procfs
* instance, is in the pid namespace hierarchy of pid.
* Start at one below the already printed level.
*/
for (i = ns->level + 1; i <= pid->level; i++)
seq_put_decimal_ull(m, "\t", pid->numbers[i].nr);
}
I will re-work the comment block and then send a new version of
the patch.
Thanks,
Christian
Powered by blists - more mailing lists