Re: [PATCH v10 5/8] rust: clist: Add support to interface with C linked lists

From: Alice Ryhl

Date: Mon Feb 23 2026 - 04:39:07 EST


On Sun, Feb 22, 2026 at 07:41:44PM -0500, Joel Fernandes wrote:
> Hi Alice,
>
> On 2/21/2026 3:59 AM, Alice Ryhl wrote:
> > On Wed, Feb 18, 2026 at 03:55:03PM -0500, Joel Fernandes wrote:
> >> +impl CListHead {
> >> + /// Create a `&CListHead` reference from a raw `list_head` pointer.
> >> + ///
> >> + /// # Safety
> >> + ///
> >> + /// - `ptr` must be a valid pointer to an allocated and initialized `list_head` structure.
> >> + /// - `ptr` must remain valid and unmodified for the lifetime `'a`.
> >> + /// - The list and all linked `list_head` nodes must not be modified by non-Rust code
> >> + /// for the lifetime `'a`.
> >
> > I don't think C vs Rust is useful here. What you want is that the list
> > is not modified by random other code in ways you didn't expect. It
> > doesn't matter if it's C or Rust code that carries out the illegal
> > modification.
>
> Yeah, this is true. I will change it to the following then:
>
> "The list and all linked `list_head` nodes must not be modified from
> anywhere for the lifetime `'a`."

Ok. Perhaps you should say that it must not be modified except through
this CListHead? I guess it depends on whether you want to add methods
for changing the list via this API.

Alice