Re: [PATCH v2] rust: list: Add unsafe for container_of

From: Miguel Ojeda
Date: Tue Nov 18 2025 - 03:23:53 EST


On Tue, Nov 18, 2025 at 8:29 AM Philipp Stanner <phasta@xxxxxxxxxx> wrote:
>
> For unknown reasons, that problem was so far not visible and only gets
> visible once one utilizes the list implementation from within the core
> crate:

What do you mean by "unknown reasons"? The reason is known -- please
refer to my message in the other thread. It should be mentioned in the
log, including the link to the compiler issue.

Also, I assume you meant `kernel` crate, not `core`.

> Cc: stable@xxxxxxxxxxxxxxx # v6.17+

No need to mention the kernel version if the Fixes tags implies it. In
fact, it is more confusing, since it looks like there is a version
where it should not be applied to.

> - let container = $crate::container_of!(
> + let container = unsafe { $crate::container_of!(
> links_field, $crate::list::ListLinksSelfPtr<Self, $num>, inner
> - );
> + ) };

Unsafe blocks require `// SAFETY: ...` comments.

Also, please double-check if this is the formatting that `rustfmt` would use.

Thanks!

Cheers,
Miguel