Re: [PATCH v3 09/10] x86/virt/tdx: Use early returns in get_tdx_sys_info()
From: Edgecombe, Rick P
Date: Wed Sep 30 2026 - 20:34:20 EST
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.
>
> AI was used under supervision to review code and workshop logs.
>
> Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
> ---
> v3:
> - Print the module version only after reading its metadata succeeds [Rick]
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>