Re: [PATCH v5 4/6] virt: tdx-guest: Add a helper for the Quote buffer size
From: Edgecombe, Rick P
Date: Mon Sep 28 2026 - 14:29:35 EST
On Mon, 2026-09-28 at 03:08 -0700, Peter Fang wrote:
> +static size_t get_quote_buf_size(void)
> +{
> + static size_t quote_buf_size;
> +
> + if (quote_buf_size)
> + return quote_buf_size;
> +
> + quote_buf_size = PAGE_ALIGN(TDX_DEFAULT_QUOTE_SIZE);
> +
> + return quote_buf_size;
> +}
> +
This makes no sense, at the point of this patch. It lazily sets a global to a
constant value. Function scoped static is also weird.
I think you are doing it this way so that later you can plug in the dynamic
read. But later it still doesn't make sense why to lazily fetch it. Why not just
read it in the tdx_guest_init() to a global? If the read fails, set to
TDX_DEFAULT_QUOTE_SIZE. Then you are done. All callers of tdx_guest_init() just
refer to the global. Why not?