Re: [PATCH V2] kho: Convert error handling to immediate return pattern

From: Mike Rapoport

Date: Mon Aug 31 2026 - 07:34:45 EST


Hi,


> Replace the chained error accumulation (err |= func()) with immediate
> per-step error checking and early return in kho_out_fdt_setup().
>
> Two problems with the current approach:
> 1. It continues executing FDT operations even after a failure, which
> is pointless and potentially unsafe on an invalid FDT context.

Did you actually see failures here or was it an LLM suggesting that they
may happen?

> 2. Bitwise OR of multiple negative error codes produces a result that
> may not represent any actual error, making debugging misleading.
>
> Early return fails fast and preserves the original error code for
> accurate diagnosis.

The caller does not care about the exact error value, so the diagnosis
statement is moot at best.
Moreover, libfdt does not return Linux error values.

--
Sincerely yours,
Mike.