Re: [PATCH] pidfd: add NSpid entries to fdinfo
flat view
From: Christian Kellner <hidden>
Date: 2019-10-14 15:21:11
Also in:
lkml
On Mon, 2019-10-14 at 17:10 +0200, Jann Horn wrote:
On Mon, Oct 14, 2019 at 12:32 PM Christian Brauner wrote:quoted
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); #endifPersonally, 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