Re: [PATCH v1 08/26] x86/virt/tdx: Add tdx_enable_ext() to enable of TDX Module Extensions

dan.j.williams
2025-11-20T18:00:59Z

Dave Hansen wrote:
[..]
> Third, are you saying that the original code structure is somehow
> connected to __free()? I thought that all of these were logically
> equivalent:
>
> void *foo __free(foofree) = alloc_foo();
>
> void *foo __free(foofree) = NULL:
> foo = alloc_foo();
>
> void *foo __free(foofree) = NULL;
> populate_foo(&foo);
>
> Is there something special about doing the variable assignment at the
> variable declaration spot?

On this topic I argue in cleanup.h that the:

void *foo __free(foofree) = alloc_foo();

...form, should be preferred. The NULL initialization form potentially
destroys the first-in-last-out ordering of cleanup callbacks.

Linus mentions here [1] though that it is not a hard and fast rule. That
was part of the rationale for documenting the preference in cleanup.h,
but not in coding-style, nor in checkpatch.pl [2].

[1]: http://lore.kernel.org/CAHk-=whPZoi03ZwphxiW6cuWPtC3nyKYS8_BThgztCdgPWP1WA@mail.gmail.com
[2]: http://lore.kernel.org/769268a5035b5a711a375591c25d48d077b46faa.camel@perches.com