minor code cleanups

This commit is contained in:
auronandace
2026-04-03 14:39:56 +01:00
parent 19b0b44eb9
commit b4009544a8
4 changed files with 9 additions and 14 deletions
+1 -2
View File
@@ -578,10 +578,9 @@ pub unsafe extern "C" fn fopen(filename: *const c_char, mode: *const c_char) ->
helpers::_fdopen(fd, unsafe { CStr::from_ptr(mode) })
.map(Box::into_raw)
.map_err(|err| {
.inspect_err(|err| {
// TODO: guard type
if let Ok(()) = Sys::close(fd) {}; // TODO handle error
err
})
.or_errno_null_mut()
}
+1 -2
View File
@@ -610,9 +610,8 @@ impl<'a, T: c_str::Kind> Iterator for PrintfIter<'a, T> {
self.format = first_percent.split_first().expect("must be %").1;
let mut peekahead = self.format;
let index = pop_index(&mut peekahead).map(|i| {
let index = pop_index(&mut peekahead).inspect(|i| {
self.format = peekahead;
i
});
// Flags:
+2 -2
View File
@@ -130,11 +130,11 @@ pub unsafe extern "C" fn fgetws(ws: *mut wchar_t, n: c_int, stream: *mut FILE) -
}
// NUL-terminate result
unsafe { *ws.add(i) = 0 };
return if i == 0 || unsafe { ferror(&raw mut *stream) != 0 } {
if i == 0 || unsafe { ferror(&raw mut *stream) != 0 } {
core::ptr::null_mut()
} else {
ws
};
}
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fputwc.html>.
+5 -8
View File
@@ -1024,14 +1024,11 @@ impl Linker {
})?;
if !shm_exists {
let _ = Sys::open(shm_path, fcntl::O_CREAT | fcntl::O_RDWR, 0o600)
.map(|fd| Sys::close(fd));
} else {
if let Ok(shm_fd) = Sys::open(shm_path, fcntl::O_RDWR, 0o600) {
let _ = Sys::ftruncate(shm_fd, source_size as i64);
let _ = Sys::write(shm_fd, file.data());
let _ = Sys::close(shm_fd);
}
let _ = Sys::open(shm_path, fcntl::O_CREAT | fcntl::O_RDWR, 0o600).map(Sys::close);
} else if let Ok(shm_fd) = Sys::open(shm_path, fcntl::O_RDWR, 0o600) {
let _ = Sys::ftruncate(shm_fd, source_size as i64);
let _ = Sys::write(shm_fd, file.data());
let _ = Sys::close(shm_fd);
}
file