Skip to content

unsafe attribute and api.rs #129

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

Merged
merged 1 commit into from
May 27, 2025
Merged

unsafe attribute and api.rs #129

merged 1 commit into from
May 27, 2025

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