proc: save LOC by using while loop
authorAlexey Dobriyan <adobriyan@gmail.com>
Fri, 29 Sep 2023 16:31:41 +0000 (19:31 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 18 Oct 2023 21:43:22 +0000 (14:43 -0700)
Use while loop instead of infinite loop with "break;".

Also move some variable to the inner scope where they belong.

Link: https://lkml.kernel.org/r/82c8f8e7-8ded-46ca-8857-e60b991d6205@p183
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/proc/inode.c

index 532dc9d240f7f991015ba02ee8c55a899a4666d0..5933c78af6de19b67bb486fd4bdb7f2b8efe2b1c 100644 (file)
@@ -110,18 +110,15 @@ void __init proc_init_kmemcache(void)
 
 void proc_invalidate_siblings_dcache(struct hlist_head *inodes, spinlock_t *lock)
 {
-       struct inode *inode;
-       struct proc_inode *ei;
        struct hlist_node *node;
        struct super_block *old_sb = NULL;
 
        rcu_read_lock();
-       for (;;) {
+       while ((node = hlist_first_rcu(inodes))) {
+               struct proc_inode *ei = hlist_entry(node, struct proc_inode, sibling_inodes);
                struct super_block *sb;
-               node = hlist_first_rcu(inodes);
-               if (!node)
-                       break;
-               ei = hlist_entry(node, struct proc_inode, sibling_inodes);
+               struct inode *inode;
+
                spin_lock(lock);
                hlist_del_init_rcu(&ei->sibling_inodes);
                spin_unlock(lock);