[PATCH V2] kho: Convert error handling to immediate return pattern
longwei (I)
longwei27 at huawei.com
Sun Aug 23 23:34:12 PDT 2026
Hi Matthew,
Thanks for the review.
I chose the explicit `if (err) return err` pattern for clarity and
"fail fast" behavior. However, I'm happy to adopt the chained pattern
if the maintainer prefers it.
Thanks,
Long Wei
在 2026/8/24 10:54, Matthew Wilcox 写道:
> On Mon, Aug 24, 2026 at 10:44:48AM +0800, LongWei27 wrote:
>> +++ b/kernel/liveupdate/kexec_handover.c
>> @@ -1438,20 +1438,34 @@ static __init int kho_out_fdt_setup(void)
>> int err;
>>
>> err = fdt_create(root, PAGE_SIZE);
>> - err |= fdt_finish_reservemap(root);
>> - err |= fdt_begin_node(root, "");
>> - err |= fdt_property_string(root, "compatible", KHO_FDT_COMPATIBLE);
>> + if (err)
>> + return err;
>> + err = fdt_finish_reservemap(root);
>> + if (err)
>> + return err;
>> + err = fdt_begin_node(root, "");
>> + if (err)
>> + return err;
>> + err = fdt_property_string(root, "compatible", KHO_FDT_COMPATIBLE);
>> + if (err)
>> + return err;
>
> Less verbose:
>
> err = fdt_create(root, PAGE_SIZE);
> - err |= fdt_finish_reservemap(root);
> - err |= fdt_begin_node(root, "");
> - err |= fdt_property_string(root, "compatible", KHO_FDT_COMPATIBLE);
> + if (!err)
> + err = fdt_finish_reservemap(root);
> + if (!err)
> + err = fdt_begin_node(root, "");
> + if (!err)
> + err = fdt_property_string(root, "compatible",
> + KHO_FDT_COMPATIBLE);
>
> up to the maintainer which one they prefer ...
More information about the kexec
mailing list