2019-12-30 19:19:07

by Mateusz Nosek

[permalink] [raw]
Subject: [PATCH] fs/kernfs/dir.c: Clean code by removing always true condition

From: Mateusz Nosek <[email protected]>

Previously there was an additional check if variable pos is not null.
However, this check happens after entering while loop and only then,
which can happen only if pos is not null.
Therefore the additional check is redundant and can be removed.

Signed-off-by: Mateusz Nosek <[email protected]>
---
fs/kernfs/dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 9d96e6871e1a..9aec80b9d7c6 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1266,7 +1266,7 @@ void kernfs_activate(struct kernfs_node *kn)

pos = NULL;
while ((pos = kernfs_next_descendant_post(pos, kn))) {
- if (!pos || (pos->flags & KERNFS_ACTIVATED))
+ if (pos->flags & KERNFS_ACTIVATED)
continue;

WARN_ON_ONCE(pos->parent && RB_EMPTY_NODE(&pos->rb));
--
2.17.1


2020-01-07 15:52:29

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH] fs/kernfs/dir.c: Clean code by removing always true condition

On Mon, Dec 30, 2019 at 08:16:28PM +0100, [email protected] wrote:
> From: Mateusz Nosek <[email protected]>
>
> Previously there was an additional check if variable pos is not null.
> However, this check happens after entering while loop and only then,
> which can happen only if pos is not null.
> Therefore the additional check is redundant and can be removed.
>
> Signed-off-by: Mateusz Nosek <[email protected]>

Acked-by: Tejun Heo <[email protected]>

Greg, can you please route this one?

Thanks.

--
tejun

2020-01-07 21:12:42

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] fs/kernfs/dir.c: Clean code by removing always true condition

On Tue, Jan 07, 2020 at 07:51:10AM -0800, Tejun Heo wrote:
> On Mon, Dec 30, 2019 at 08:16:28PM +0100, [email protected] wrote:
> > From: Mateusz Nosek <[email protected]>
> >
> > Previously there was an additional check if variable pos is not null.
> > However, this check happens after entering while loop and only then,
> > which can happen only if pos is not null.
> > Therefore the additional check is redundant and can be removed.
> >
> > Signed-off-by: Mateusz Nosek <[email protected]>
>
> Acked-by: Tejun Heo <[email protected]>
>
> Greg, can you please route this one?

Sure, will do, thanks.

greg k-h