]> git.baikalelectronics.ru Git - kernel.git/commit
of: base: remove unnecessary for loop
author권오훈 <ohoono.kwon@samsung.com>
Thu, 1 Jul 2021 14:03:28 +0000 (23:03 +0900)
committerRob Herring <robh@kernel.org>
Thu, 15 Jul 2021 13:35:49 +0000 (07:35 -0600)
commit8d1c0c7c6daaacc8545a8b832554a0a7b76d3767
tree949ced11d449edd863814689053c6a84195a472b
parent8aa333c76dd58f6d2877024f48f03dc30ff3f488
of: base: remove unnecessary for loop

In __of_get_next_child function, loop iteration for getting next node is
unnecessary.

for loop is already checking if next is NULL or not, and
of_node_get(next) always returns next itself.

Therefore checking return value in the if clause always evaluates to
true, and thus it always breaks out from for loop in the first iteration.

Remove the unnecessary for loop for readability.

I tested the code as below, and it showed that BUG was never called.

-       for (; next; next = next->sibling)
+       for (; next; next = next->sibling) {
                if (of_node_get(next))
                        break;
+               BUG();
+       }

Signed-off-by: Ohhoon Kwon <ohoono.kwon@samsung.com>
Link: https://lore.kernel.org/r/20210701140328epcms1p85149318b6c18fa18b3c7c8e966c14db0@epcms1p8
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/base.c