Skip to content

Conversation

@wks
Copy link
Collaborator

@wks wks commented May 27, 2025

Clippy gives teh not_unsafe_ptr_arg_deref lint warning if a function dereferences a raw pointer but is not labelled as unsafe. We used to suppress this warning was because labelling a function unsafe automatically grants it rights to use any unsafe operation inside the function. I deemed that a greater danger because we then won't be able to identify real unsafe sections within an unsafe function.

We now set #![warn(unsafe_op_in_unsafe_fn)] for the whole lib. It makes it necessary to use the unsafe { ... } block even within unsafe functions. We now explicitly label functions as unsafe if they deference raw pointers. But we set
#![allow(clippy::missing_safety_doc)] on the api.rs module because the reason for functions to be unsafe in that module is clearly because they are used by C with raw pointers.

Clippy gives teh `not_unsafe_ptr_arg_deref` lint warning if a function
dereferences a raw pointer but is not labelled as `unsafe`.  We used to
suppress this warning was because labelling a function `unsafe`
automatically grants it rights to use any unsafe operation inside the
function.  I deemed that a greater danger because we then won't be able
to identify real unsafe sections within an `unsafe` function.

We now set `#![warn(unsafe_op_in_unsafe_fn)]` for the whole lib.  It
makes it necessary to use the `unsafe { ... }` block even within
`unsafe` functions.  We now explicitly label functions as `unsafe` if
they deference raw pointers.  But we set
`#![allow(clippy::missing_safety_doc)]` on the `api.rs` module because
the reason for functions to be unsafe in that module is clearly because
they are used by C with raw pointers.
@wks wks merged commit 99ec77f into mmtk:master May 27, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant