-
Notifications
You must be signed in to change notification settings - Fork 449
rust: kernel: workqueue: deref on an immutable reference #900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rust
Are you sure you want to change the base?
Conversation
clippy error: if you would like to reborrow, try removing `&*`: `self` Signed-off-by: Alice Ferrazzi <[email protected]> Reviewed-by: Luca Barbato <[email protected]>
@@ -391,7 +391,7 @@ impl Work { | |||
// SAFETY: When the work was queued, a call to `into_raw` was made. We just canceled | |||
// the work without it having the chance to run, so we need to explicitly destroy this | |||
// reference (which would have happened in `work_func` if it did run). | |||
unsafe { Ref::from_raw(&*self) }; | |||
unsafe { Ref::from_raw(self) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-existing, but I think this is actually wrong. Work
is not the thing put in a Ref
, but the type containing Work
. As such self
should be value containing Work
. Could you please take a look @wedsonaf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, we need to do the same pointer arithmetic we do in work_func
below to get to the right ptr.
Nice catch, @bjorn3
Now we don't have the type here anymore, so we either need to make Work
generic or just store the offset is some field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option would be to change the function signature to fn cancel<A: WorkAdapter>(obj: Ref<A::Target>)
I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that would be unsafe. Users could use the wrong adapter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, sorry, I see now that it's passing the outer object.
clippy error: if you would like to reborrow, try removing
&*
:self
Signed-off-by: Alice Ferrazzi [email protected]
Reviewed-by: Luca Barbato [email protected]