Skip to content

Commit

Permalink
use addr_of!
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigorenkoPV committed Feb 24, 2024
1 parent 6145fe6 commit 0286b2c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/backtrace/dbghelp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
context.ip(),
fn_entry,
&mut context.0,
&mut handler_data as *mut usize as *mut PVOID,
core::ptr::addr_of_mut!(handler_data) as *mut PVOID,
&mut establisher_frame,
ptr::null_mut(),
);
Expand Down Expand Up @@ -215,7 +215,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
process,
thread,
&mut stack_frame_ex,
&mut context.0 as *mut CONTEXT as PVOID,
core::ptr::addr_of_mut!(context.0) as PVOID,
None,
Some(function_table_access),
Some(get_module_base),
Expand Down Expand Up @@ -253,7 +253,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
process,
thread,
&mut stack_frame64,
&mut context.0 as *mut CONTEXT as PVOID,
core::ptr::addr_of_mut!(context.0) as PVOID,
None,
Some(function_table_access),
Some(get_module_base),
Expand Down
6 changes: 3 additions & 3 deletions src/backtrace/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Clone for Frame {

#[inline(always)]
pub unsafe fn trace(mut cb: &mut dyn FnMut(&super::Frame) -> bool) {
uw::_Unwind_Backtrace(trace_fn, &mut cb as *mut _ as *mut _);
uw::_Unwind_Backtrace(trace_fn, core::ptr::addr_of_mut!(cb) as *mut _);

extern "C" fn trace_fn(
ctx: *mut uw::_Unwind_Context,
Expand Down Expand Up @@ -242,7 +242,7 @@ mod uw {

pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t {
let mut val: _Unwind_Word = 0;
let ptr = &mut val as *mut _Unwind_Word;
let ptr = core::ptr::addr_of_mut!(val);
let _ = _Unwind_VRS_Get(
ctx,
_Unwind_VRS_RegClass::_UVRSC_CORE,
Expand All @@ -258,7 +258,7 @@ mod uw {

pub unsafe fn get_sp(ctx: *mut _Unwind_Context) -> libc::uintptr_t {
let mut val: _Unwind_Word = 0;
let ptr = &mut val as *mut _Unwind_Word;
let ptr = core::ptr::addr_of_mut!(val);
let _ = _Unwind_VRS_Get(
ctx,
_Unwind_VRS_RegClass::_UVRSC_CORE,
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/dbghelp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ unsafe fn do_resolve(
}
}
}
let name = &name_buffer[..name_len] as *const [u8];
let name = core::ptr::addr_of!(name_buffer[..name_len]);

let mut line = mem::zeroed::<IMAGEHLP_LINEW64>();
line.SizeOfStruct = mem::size_of::<IMAGEHLP_LINEW64>() as DWORD;
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli/libs_dl_iterate_phdr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use core::slice;
pub(super) fn native_libraries() -> Vec<Library> {
let mut ret = Vec::new();
unsafe {
libc::dl_iterate_phdr(Some(callback), &mut ret as *mut Vec<_> as *mut _);
libc::dl_iterate_phdr(Some(callback), core::ptr::addr_of_mut!(ret) as *mut _);
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli/libs_illumos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(super) fn native_libraries() -> Vec<Library> {
if dlinfo(
RTLD_SELF,
RTLD_DI_LINKMAP,
(&mut map) as *mut *const LinkMap as *mut libc::c_void,
core::ptr::addr_of_mut!(map) as *mut libc::c_void,
) != 0
{
return libs;
Expand Down

0 comments on commit 0286b2c

Please sign in to comment.