Skip to content

Commit ba89b1a

Browse files
committed
Format pointer types without cast
Signed-off-by: Martin Kröning <[email protected]>
1 parent dd85c9b commit ba89b1a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ pub(crate) extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 {
136136
let ptr = unsafe { ALLOCATOR.alloc(layout) };
137137

138138
trace!(
139-
"__sys_malloc: allocate memory at {:#x} (size {:#x}, align {:#x})",
140-
ptr as usize,
139+
"__sys_malloc: allocate memory at {:p} (size {:#x}, align {:#x})",
140+
ptr,
141141
size,
142142
align
143143
);
@@ -175,8 +175,8 @@ pub(crate) extern "C" fn __sys_realloc(
175175
let layout_res = Layout::from_size_align(size, align);
176176
if layout_res.is_err() || size == 0 || new_size == 0 {
177177
warn!(
178-
"__sys_realloc called with ptr {:#x}, size {:#x}, align {:#x}, new_size {:#x} is an invalid layout!",
179-
ptr as usize, size, align, new_size
178+
"__sys_realloc called with ptr {:p}, size {:#x}, align {:#x}, new_size {:#x} is an invalid layout!",
179+
ptr, size, align, new_size
180180
);
181181
return core::ptr::null::<*mut u8>() as *mut u8;
182182
}
@@ -185,14 +185,14 @@ pub(crate) extern "C" fn __sys_realloc(
185185

186186
if new_ptr.is_null() {
187187
debug!(
188-
"__sys_realloc failed to resize ptr {:#x} with size {:#x}, align {:#x}, new_size {:#x} !",
189-
ptr as usize, size, align, new_size
188+
"__sys_realloc failed to resize ptr {:p} with size {:#x}, align {:#x}, new_size {:#x} !",
189+
ptr, size, align, new_size
190190
);
191191
} else {
192192
trace!(
193-
"__sys_realloc: resized memory at {:#x}, new address {:#x}",
194-
ptr as usize,
195-
new_ptr as usize
193+
"__sys_realloc: resized memory at {:p}, new address {:p}",
194+
ptr,
195+
new_ptr
196196
);
197197
}
198198
new_ptr
@@ -222,8 +222,8 @@ pub(crate) extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) {
222222
debug_assert_ne!(size, 0, "__sys_free error: size cannot be 0");
223223
} else {
224224
trace!(
225-
"sys_free: deallocate memory at {:#x} (size {:#x})",
226-
ptr as usize,
225+
"sys_free: deallocate memory at {:p} (size {:#x})",
226+
ptr,
227227
size
228228
);
229229
}

0 commit comments

Comments
 (0)