Code cleanup

This commit is contained in:
topjohnwu
2025-12-13 22:12:30 -08:00
committed by John Wu
parent 33eaa7c5eb
commit 01cb75eaef
12 changed files with 383 additions and 463 deletions
-25
View File
@@ -35,21 +35,6 @@ unsafe extern "C" fn xrealpath(path: *const c_char, buf: *mut u8, bufsz: usize)
}
}
#[unsafe(no_mangle)]
unsafe extern "C" fn xreadlink(path: *const c_char, buf: *mut u8, bufsz: usize) -> isize {
unsafe {
match Utf8CStr::from_ptr(path) {
Ok(path) => {
let mut buf = cstr::buf::wrap_ptr(buf, bufsz);
path.read_link(&mut buf)
.log()
.map_or(-1, |_| buf.len() as isize)
}
Err(_) => -1,
}
}
}
#[unsafe(no_mangle)]
unsafe extern "C" fn xreadlinkat(
dirfd: RawFd,
@@ -201,16 +186,6 @@ extern "C" fn xsetsid() -> i32 {
}
}
#[unsafe(no_mangle)]
unsafe extern "C" fn xstat(path: *const c_char, buf: *mut libc::stat) -> i32 {
unsafe {
libc::stat(path, buf)
.into_os_result("stat", ptr_to_str(path), None)
.log()
.unwrap_or(-1)
}
}
#[unsafe(no_mangle)]
unsafe extern "C" fn xfstat(fd: RawFd, buf: *mut libc::stat) -> i32 {
unsafe {