Re: [RFC][PATCH v4 20/69] merging pick_link() with get_link(), part 2

From: Linus Torvalds
Date: Fri Mar 13 2020 - 20:40:37 EST


Hmm..

On Fri, Mar 13, 2020 at 4:55 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>@@ -2370,10 +2375,9 @@ static int path_lookupat(struct nameidata *nd, unsigned flags, struct path *path
> + while (!(err = link_path_walk(s, nd)) &&
> + (s = lookup_last(nd)) != NULL)
> + ;

There's two copies of that loop (the other being in path_openat()). Is
there a reason why it's written that odd way?

Why is the loop body empty, when the *natural* way to write that would
seem to be

while (!(err = link_path_walk(s, nd))) {
s = lookup_last(nd));
if (!s)
break;
}

which may be a few lines longer, but a lot more legible.

I don't think you should use assignments in tests, unless strictly
required. Yes, that "err = ..." part almost has to be written that
way, but the "s = ..." part doesn't seem to have any reason for being
in the conditional.

And I'm only reading the patches, so once again: maybe I'm messing up
by mis-reading something. And maybe you have some reason for that
pattern.

Linus