Re: [PATCH v3 09/10] x86/virt/tdx: Use early returns in get_tdx_sys_info()
From: Chao Gao
Date: Thu Oct 01 2026 - 09:18:33 EST
On Thu, Oct 01, 2026 at 08:30:05AM +0800, Edgecombe, Rick P wrote:
>On Tue, 2026-09-29 at 22:38 -0700, Chao Gao wrote:
>> get_tdx_sys_info() was generated by a script. It chains its metadata reads
>> with:
>>
>> ret = ret ?: get_tdx_sys_info_foo(...);
>>
>> The function is maintained by hand now. Use conventional early returns
>> instead.
>>
>> Print the module version only after its metadata has been read
>> successfully. The "ret ?:" chain had no early exit, so the pr_info()
>> between the reads ran even when the version read itself failed, printing a
>> partially read or all-zero version. That isn't considered a big problem,
>> but early returns make it easy to avoid.
>
>Nit: The reason it is good to change it in this patch is because not doing the
>early exit looks very obviously wrong now, where it didn't before.
Good point. I was struggling with how to justify this change, and your
reasoning is better. I will add it to the changelog.