Re: [PATCH] base: soc: Make soc_device_match() simpler and easier to read

From: Arnd Bergmann
Date: Tue Mar 01 2022 - 08:16:50 EST


On Tue, Mar 1, 2022 at 12:10 PM Geert Uytterhoeven
<geert+renesas@xxxxxxxxx> wrote:
>
> The function soc_device_match() is difficult to read for various
> reasons:
> - There are two loop conditions using different styles: "while (...)"
> (which is BTW always true) vs. "if ... break",
> - The are two return condition using different logic: "if ... return
> foo" vs. "if ... else return bar".
>
> Make the code easier to read by:
> 1. Removing the always-true "!ret" loop condition, and dropping the
> now unneeded pre-initialization of "ret",
> 2. Converting "if ... break" to a proper "while (...)" loop condition,
> 3. Inverting the logic of the second return condition.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> ---

Reviewed-by: Arnd Bergmann <arnd@xxxxxxxx>