Skip to content

Commit cc8e7c0

Browse files
committed
Fix types
2 parents 8a85c39 + 067f937 commit cc8e7c0

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/sys/ptrace.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,31 +191,37 @@ type Word = usize;
191191

192192
/// Makes the `PTRACE_SYSCALL` request to ptrace
193193
pub fn syscall(pid: Pid) -> Result<()> {
194-
ptrace(ptrace::PTRACE_SYSCALL, pid, ptr::null_mut(), ptr::null_mut()).map(|_| ()) // ignore the useless return value
194+
unsafe {
195+
ptrace(ptrace::PTRACE_SYSCALL, pid, ptr::null_mut(), ptr::null_mut()).map(|_| ()) // ignore the useless return value
196+
}
195197
}
196198

197199
/// Makes the `PTRACE_PEEKUSER` request to ptrace
198200
pub fn peekuser(pid: Pid, reg: Register) -> Result<Word> {
199201
let reg_arg = (reg as i32) as *mut c_void;
200-
ptrace(ptrace::PTRACE_PEEKUSER, pid, reg_arg, ptr::null_mut())
201-
}
202+
unsafe {
203+
ptrace(ptrace::PTRACE_PEEKUSER, pid, reg_arg, ptr::null_mut()).map(|r| r as Word)
204+
}
205+
}
202206

203207
/// Sets the process as traceable with `PTRACE_TRACEME`
204208
pub fn traceme() -> Result<()> {
205-
ptrace(
206-
ptrace::PTRACE_TRACEME,
207-
Pid::from_raw(0),
208-
ptr::null_mut(),
209-
ptr::null_mut(),
210-
).map(|_| ()) // ignore the useless return value
209+
unsafe {
210+
ptrace(
211+
ptrace::PTRACE_TRACEME,
212+
Pid::from_raw(0),
213+
ptr::null_mut(),
214+
ptr::null_mut(),
215+
).map(|_| ()) // ignore the useless return value
216+
}
211217
}
212218

213219
/// Makes the `PTRACE_PEEKDATA` request to ptrace
214220
///
215221
/// This function allows to access arbitrary data in the traced process
216222
/// and may crash the inferior if used incorrectly and is thus marked `unsafe`.
217223
pub unsafe fn peekdata(pid: Pid, addr: usize) -> Result<Word> {
218-
ptrace(ptrace::PTRACE_PEEKDATA, pid, addr as *mut c_void, ptr::null_mut())
224+
ptrace(ptrace::PTRACE_PEEKDATA, pid, addr as *mut c_void, ptr::null_mut()).map(|r| r as Word)
219225
}
220226

221227
/// Makes the `PTRACE_PEEKDATA` request to ptrace

0 commit comments

Comments
 (0)