-
Notifications
You must be signed in to change notification settings - Fork 665
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
Suppress clippy::not_unsafe_ptr_arg_deref in mqueue, ptrace #1638
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ use crate::Result; | |
pub type RequestType = c_int; | ||
|
||
cfg_if! { | ||
if #[cfg(any(target_os = "dragonfly", | ||
target_os = "freebsd", | ||
if #[cfg(any(target_os = "dragonfly", | ||
target_os = "freebsd", | ||
target_os = "macos", | ||
target_os = "openbsd"))] { | ||
#[doc(hidden)] | ||
|
@@ -120,7 +120,7 @@ pub fn cont<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> { | |
|
||
/// Issues a kill request as with `ptrace(PT_KILL, ...)` | ||
/// | ||
/// This request is equivalent to `ptrace(PT_CONTINUE, ..., SIGKILL);` | ||
/// This request is equivalent to `ptrace(PT_CONTINUE, ..., SIGKILL);` | ||
pub fn kill(pid: Pid) -> Result<()> { | ||
unsafe { | ||
ptrace_other(Request::PT_KILL, pid, 0 as AddressType, 0).map(drop) | ||
|
@@ -167,6 +167,7 @@ pub fn step<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> { | |
} | ||
|
||
/// Reads a word from a processes memory at the given address | ||
#[allow(clippy::not_unsafe_ptr_arg_deref)] | ||
pub fn read(pid: Pid, addr: AddressType) -> Result<c_int> { | ||
unsafe { | ||
// Traditionally there was a difference between reading data or | ||
|
@@ -176,6 +177,7 @@ pub fn read(pid: Pid, addr: AddressType) -> Result<c_int> { | |
} | ||
|
||
/// Writes a word into the processes memory at the given address | ||
#[allow(clippy::not_unsafe_ptr_arg_deref)] | ||
pub fn write(pid: Pid, addr: AddressType, data: c_int) -> Result<()> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ptrace::write is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think technically this doesn't violate Rust's safety rules. |
||
unsafe { ptrace_other(Request::PT_WRITE_D, pid, addr, data).map(drop) } | ||
} |
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.
Unfortunately, Clippy is right about this. Since
mqd_t
is a typedef, the user is allowed to do pretty much anything with it. As an example, this code will segfault:I think Nix should fix this by defining a Newtype around
mqd_t
.