diff --git a/Cargo.toml b/Cargo.toml index 7df7e12f3..2a7364644 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -668,7 +668,6 @@ doc_markdown = "allow" unused_self = "allow" enum_glob_use = "allow" ptr_cast_constness = "allow" -ptr_as_ptr = "allow" needless_raw_string_hashes = "allow" unreadable_literal = "allow" unnested_or_patterns = "allow" diff --git a/fuzz/uufuzz/src/lib.rs b/fuzz/uufuzz/src/lib.rs index 4a7b2ea72..e94ffd8b1 100644 --- a/fuzz/uufuzz/src/lib.rs +++ b/fuzz/uufuzz/src/lib.rs @@ -193,13 +193,8 @@ fn read_from_fd(fd: RawFd) -> String { let mut captured_output = Vec::new(); let mut read_buffer = [0; 1024]; loop { - let bytes_read = unsafe { - libc::read( - fd, - read_buffer.as_mut_ptr() as *mut libc::c_void, - read_buffer.len(), - ) - }; + let bytes_read = + unsafe { libc::read(fd, read_buffer.as_mut_ptr().cast(), read_buffer.len()) }; if bytes_read == -1 { eprintln!("Failed to read from the pipe"); diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 0ac59df17..6f6158850 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -439,7 +439,7 @@ fn enter_chroot(root: &Path, skip_chdir: bool) -> UResult<()> { .map_err(|e| ChrootError::CannotEnter("root".to_string(), e.into()))? .as_bytes_with_nul() .as_ptr() - .cast::(), + .cast(), ) }; diff --git a/src/uucore/src/lib/features/fsext.rs b/src/uucore/src/lib/features/fsext.rs index 65021990a..8051b2f43 100644 --- a/src/uucore/src/lib/features/fsext.rs +++ b/src/uucore/src/lib/features/fsext.rs @@ -881,7 +881,7 @@ impl FsMeta for StatFs { fn fsid(&self) -> u64 { // Use type inference to determine the type of f_fsid // (libc::__fsid_t on Android, libc::fsid_t on other platforms) - let f_fsid: &[u32; 2] = unsafe { &*(&raw const self.f_fsid as *const [u32; 2]) }; + let f_fsid: &[u32; 2] = unsafe { &*(&raw const self.f_fsid).cast() }; ((u64::from(f_fsid[0])) << 32) | u64::from(f_fsid[1]) } #[cfg(not(any( diff --git a/src/uucore/src/lib/features/systemd_logind.rs b/src/uucore/src/lib/features/systemd_logind.rs index 961b0f292..d34e8cc17 100644 --- a/src/uucore/src/lib/features/systemd_logind.rs +++ b/src/uucore/src/lib/features/systemd_logind.rs @@ -71,11 +71,11 @@ mod login { let session_cstr = unsafe { CStr::from_ptr(session_ptr) }; sessions.push(session_cstr.to_string_lossy().into_owned()); - unsafe { libc::free(session_ptr as *mut libc::c_void) }; + unsafe { libc::free(session_ptr.cast()) }; i += 1; } - unsafe { libc::free(sessions_ptr as *mut libc::c_void) }; + unsafe { libc::free(sessions_ptr.cast()) }; } Ok(sessions) @@ -135,7 +135,7 @@ mod login { let tty_cstr = unsafe { CStr::from_ptr(tty_ptr) }; let tty_string = tty_cstr.to_string_lossy().into_owned(); - unsafe { libc::free(tty_ptr as *mut libc::c_void) }; + unsafe { libc::free(tty_ptr.cast()) }; Ok(Some(tty_string)) } @@ -164,7 +164,7 @@ mod login { let host_cstr = unsafe { CStr::from_ptr(host_ptr) }; let host_string = host_cstr.to_string_lossy().into_owned(); - unsafe { libc::free(host_ptr as *mut libc::c_void) }; + unsafe { libc::free(host_ptr.cast()) }; Ok(Some(host_string)) } @@ -193,7 +193,7 @@ mod login { let display_cstr = unsafe { CStr::from_ptr(display_ptr) }; let display_string = display_cstr.to_string_lossy().into_owned(); - unsafe { libc::free(display_ptr as *mut libc::c_void) }; + unsafe { libc::free(display_ptr.cast()) }; Ok(Some(display_string)) } @@ -221,7 +221,7 @@ mod login { let type_cstr = unsafe { CStr::from_ptr(type_ptr) }; let type_string = type_cstr.to_string_lossy().into_owned(); - unsafe { libc::free(type_ptr as *mut libc::c_void) }; + unsafe { libc::free(type_ptr.cast()) }; Ok(Some(type_string)) } @@ -249,7 +249,7 @@ mod login { let seat_cstr = unsafe { CStr::from_ptr(seat_ptr) }; let seat_string = seat_cstr.to_string_lossy().into_owned(); - unsafe { libc::free(seat_ptr as *mut libc::c_void) }; + unsafe { libc::free(seat_ptr.cast()) }; Ok(Some(seat_string)) } @@ -376,7 +376,7 @@ pub fn read_login_records() -> UResult> { let ret = libc::getpwuid_r( uid, passwd.as_mut_ptr(), - buf.as_mut_ptr() as *mut libc::c_char, + buf.as_mut_ptr().cast(), buf.len(), &raw mut result, );