Re: [PATCH v2 1/5] maple_tree: remove lockdep_map_p typedef

From: Alice Ryhl
Date: Tue Aug 19 2025 - 08:45:23 EST


On Tue, Aug 19, 2025 at 10:34:42AM +0000, Alice Ryhl wrote:
> Having the ma_external_lock field exist when CONFIG_LOCKDEP=n isn't used
> anywhere, so just get rid of it. This also avoids generating a typedef
> called lockdep_map_p that could overlap with typedefs in other header
> files.
>
> With this change, bindgen will generate better definitions for this
> union, which makes it nicer to use from Rust. This avoids a cast in the
> Rust abstractions for the maple tree, ensuring that Rust's type checker
> will notice at build-time if ma_lock is changed from spinlock_t to
> something else.
>
> Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

Ah ... this didn't work. There's still a configuration where I get the
error:

ERROR:root:error[E0308]: mismatched types
--> ../rust/kernel/maple_tree.rs:256:18
|
254 | fn ma_lock(&self) -> *mut bindings::spinlock_t {
| ------------------------- expected `*mut bindings::spinlock` because of return type
255 | // SAFETY: This pointer offset operation stays in-bounds.
256 | unsafe { &raw mut (*self.tree.get()).__bindgen_anon_1.ma_lock }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut spinlock`, found `*mut __BindgenUnionField<spinlock>`
|
= note: expected raw pointer `*mut bindings::spinlock`
found raw pointer `*mut bindings::__BindgenUnionField<bindings::spinlock>`

Alice