Convert a bunch of c_int to Result<(), Errno>.

This commit is contained in:
4lDO2
2024-09-22 18:40:32 +02:00
parent 509c4520a5
commit 6e5959b3fa
12 changed files with 219 additions and 222 deletions
+7 -5
View File
@@ -10,7 +10,7 @@ use rand_xorshift::XorShiftRng;
use crate::{
c_str::CStr,
error::ResultExt,
error::{Errno, ResultExt},
fs::File,
header::{
ctype,
@@ -649,7 +649,7 @@ where
pub unsafe extern "C" fn mktemp(name: *mut c_char) -> *mut c_char {
if inner_mktemp(name, 0, || {
let name = CStr::from_ptr(name);
if Sys::access(name, 0) != 0 && platform::ERRNO.get() == ENOENT {
if Sys::access(name, 0) == Err(Errno(ENOENT)) {
Some(())
} else {
None
@@ -663,9 +663,11 @@ pub unsafe extern "C" fn mktemp(name: *mut c_char) -> *mut c_char {
}
fn get_nstime() -> u64 {
let mut ts = mem::MaybeUninit::uninit();
Sys::clock_gettime(CLOCK_MONOTONIC, ts.as_mut_ptr());
unsafe { ts.assume_init() }.tv_nsec as u64
unsafe {
let mut ts = mem::MaybeUninit::uninit();
Sys::clock_gettime(CLOCK_MONOTONIC, ts.as_mut_ptr());
ts.assume_init().tv_nsec as u64
}
}
#[no_mangle]