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

"longwei (I)" <[email protected]>
Newsgroups org.infradead.lists.kexec,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
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 ...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.