Skip to content

Commit

Permalink
fix(syscalls): clippy::unnecessary_result_map_or_else
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Feb 19, 2024
1 parent bdbc36f commit ecabc09
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub extern "C" fn sys_fstat(fd: FileDescriptor, stat: *mut FileAttr) -> i32 {

extern "C" fn __sys_opendir(name: *const u8) -> FileDescriptor {
if let Ok(name) = unsafe { CStr::from_ptr(name as _) }.to_str() {
crate::fs::opendir(name).map_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap(), |v| v)
crate::fs::opendir(name).unwrap_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap())
} else {
-crate::errno::EINVAL
}
Expand All @@ -232,7 +232,7 @@ extern "C" fn __sys_open(name: *const u8, flags: i32, mode: u32) -> FileDescript

if let Ok(name) = unsafe { CStr::from_ptr(name as _) }.to_str() {
crate::fd::open(name, flags, mode)
.map_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap(), |v| v)
.unwrap_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap())
} else {
-crate::errno::EINVAL
}
Expand Down Expand Up @@ -424,7 +424,7 @@ pub extern "C" fn sys_getdents64(fd: FileDescriptor, dirp: *mut Dirent64, count:
}

extern "C" fn __sys_dup(fd: i32) -> i32 {
dup_object(fd).map_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap(), |v| v)
dup_object(fd).unwrap_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap())
}

#[no_mangle]
Expand Down Expand Up @@ -462,7 +462,7 @@ pub extern "C" fn sys_poll(fds: *mut PollFd, nfds: usize, timeout: i32) -> i32 {
extern "C" fn __sys_eventfd(initval: u64, flags: i16) -> i32 {
if let Some(flags) = EventFlags::from_bits(flags) {
crate::fd::eventfd(initval, flags)
.map_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap(), |v| v)
.unwrap_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap())
} else {
-crate::errno::EINVAL
}
Expand Down

0 comments on commit ecabc09

Please sign in to comment.