follow-up eliminating more as casts

This commit is contained in:
auronandace
2026-07-15 10:54:26 +01:00
parent 6671339ec3
commit ce28b8786a
4 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ pub fn split(line: &mut [u8]) -> Option<passwd> {
let mut parts = line.split_mut(|&c| c == b'\0');
Some(passwd {
pw_name: parts.next()?.as_mut_ptr().cast::<c_char>(),
pw_passwd: c"x".as_ptr().cast::<c_char>() as *mut c_char,
pw_passwd: c"x".as_ptr().cast::<c_char>().cast_mut(),
pw_uid: parsed(parts.next())?,
pw_gid: parsed(parts.next())?,
pw_gecos: parts.next()?.as_mut_ptr().cast::<c_char>(),
+4 -3
View File
@@ -22,8 +22,9 @@ fn dup_read<T>(fd: c_int, name: &str, t: &mut T) -> syscall::Result<usize> {
let size = mem::size_of::<T>();
let bytes = dup
.read(unsafe { slice::from_raw_parts_mut(core::ptr::from_mut::<T>(t) as *mut u8, size) })?;
let bytes = dup.read(unsafe {
slice::from_raw_parts_mut(core::ptr::from_mut::<T>(t).cast::<u8>(), size)
})?;
Ok(bytes / size)
}
@@ -35,7 +36,7 @@ fn dup_write<T>(fd: c_int, name: &str, t: &T) -> Result<usize> {
let size = mem::size_of::<T>();
let bytes = dup
.write(unsafe { slice::from_raw_parts(core::ptr::from_ref::<T>(t) as *const u8, size) })?;
.write(unsafe { slice::from_raw_parts(core::ptr::from_ref::<T>(t).cast::<u8>(), size) })?;
Ok(bytes / size)
}
+2 -2
View File
@@ -665,7 +665,7 @@ impl Linker {
// Unmap just the TCB page.
Sys::munmap(
core::ptr::from_mut::<Tcb>(new_tcb) as *mut c_void,
core::ptr::from_mut::<Tcb>(new_tcb).cast::<c_void>(),
syscall::PAGE_SIZE,
)
.unwrap();
@@ -698,7 +698,7 @@ impl Linker {
drop(_guard);
(
new_tcb,
core::ptr::from_mut::<Tcb>(old_tcb) as *mut c_void,
core::ptr::from_mut::<Tcb>(old_tcb).cast::<c_void>(),
thr_fd,
)
};
+1 -1
View File
@@ -1,7 +1,7 @@
use crate::{c_str::CStr, header::stdlib::getenv, platform::types::c_char};
use syscall::{EIO, ENOENT, Error, Result, flag::*};
pub const LIBC_SCHEME: &'static str = "libc:";
pub const LIBC_SCHEME: &str = "libc:";
const ENV_MAX_LEN: i32 = i32::MAX;