Merge branch 'ptr-as-ptr' into 'master'

add clippy lint ptr_as_ptr

See merge request redox-os/relibc!965
This commit is contained in:
Jeremy Soller
2026-02-06 10:32:15 -07:00
3 changed files with 10 additions and 8 deletions
+2
View File
@@ -20,9 +20,11 @@ members = [
exclude = ["tests", "dlmalloc-rs"]
[workspace.lints.clippy]
ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
[lints.clippy]
ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
[build-dependencies]
+5 -5
View File
@@ -549,11 +549,11 @@ impl DSO {
);
}
log::trace!(" = {:p}", ptr);
ptr::write_bytes(ptr as *mut u8, 0, size);
ptr::write_bytes(ptr.cast::<u8>(), 0, size);
_r_debug
.lock()
.insert(ptr as usize, path, ptr as usize + l_ld as usize);
slice::from_raw_parts_mut(ptr as *mut u8, size)
slice::from_raw_parts_mut(ptr.cast::<u8>(), size)
}
};
@@ -753,7 +753,7 @@ impl DSO {
elf::DT_FINI_ARRAY if val != 0 => fini_array_ptr = Some(ptr.cast::<InitFn>()),
elf::DT_FINI_ARRAYSZ => fini_array_len = Some(val as usize / size_of::<InitFn>()),
elf::DT_SYMTAB => symtab_ptr = Some(ptr as *const Sym),
elf::DT_SYMTAB => symtab_ptr = Some(ptr.cast::<Sym>()),
elf::DT_SYMENT => {
assert_eq!(val as usize, size_of::<Sym>());
}
@@ -922,13 +922,13 @@ impl DSO {
Some(some) => some,
None => match reloc.kind {
RelocationKind::COPY | RelocationKind::GOT | RelocationKind::PLT => 0,
_ => unsafe { *(ptr as *mut usize) },
_ => unsafe { *ptr.cast::<usize>() },
},
};
// TODO: support different sizes?
let set_usize = |value| unsafe {
*(ptr as *mut usize) = value;
*ptr.cast::<usize>() = value;
};
match reloc.kind {
+3 -3
View File
@@ -83,7 +83,7 @@ impl Tcb {
let page_size = Sys::getpagesize();
let (_abi_page, tls, tcb_page) = Self::os_new(size.next_multiple_of(page_size))?;
let tcb_ptr = tcb_page.as_mut_ptr() as *mut Self;
let tcb_ptr = tcb_page.as_mut_ptr().cast::<Self>();
ptr::write(
tcb_ptr,
Self {
@@ -278,8 +278,8 @@ impl Tcb {
)
.map_err(|_| DlError::Oom)?;
ptr::write_bytes(ptr as *mut u8, 0, size);
Ok(slice::from_raw_parts_mut(ptr as *mut u8, size))
ptr::write_bytes(ptr.cast::<u8>(), 0, size);
Ok(slice::from_raw_parts_mut(ptr.cast::<u8>(), size))
}
/// OS specific code to create a new TLS and TCB - Linux and Redox