Re: [PATCH 3/4] rust: devres: get rid of Devres' inner Arc
From: Danilo Krummrich
Date: Sun Jun 22 2025 - 11:45:49 EST
On Sun, Jun 22, 2025 at 09:05:51AM +0200, Benno Lossin wrote:
> On Thu Jun 12, 2025 at 4:51 PM CEST, Danilo Krummrich wrote:
> > + fn remove_action(&self) -> bool {
> > + // SAFETY:
> > + // - `self.dev` is a valid `Device`,
> > + // - the `action` and `data` pointers are the exact same ones as given to devm_add_action()
> > + // previously,
> > + // - `self` is always valid, even if the action has been released already.
> > + (unsafe {
> > + bindings::devm_remove_action_nowarn(
> > + self.dev.as_raw(),
> > + Some(self.callback),
> > + self.as_ptr().cast_mut().cast(),
> > + )
> > + } == 0)
>
> I don't think the parenthesis are required?
At least the compiler doesn't seem to be happy about removing them:
error: expected expression, found `==`
--> rust/kernel/devres.rs:199:11
|
199 | } == 0
| ^^ expected expression
error[E0308]: mismatched types
--> rust/kernel/devres.rs:194:13
|
194 | / bindings::devm_remove_action_nowarn(
195 | | self.dev.as_raw(),
196 | | Some(self.callback),
197 | | self.inner().as_ptr().cast_mut().cast(),
198 | | )
| | ^- help: consider using a semicolon here: `;`
| |_____________|
| expected `()`, found `i32`
error: aborting due to 2 previous errors