mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
clippy: fix ptr_as_ptr lint
https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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::<libc::c_char>(),
|
||||
.cast(),
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<Vec<SystemdLoginRecord>> {
|
||||
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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user