summaryrefslogtreecommitdiff
path: root/rust/kernel/fs/file.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/kernel/fs/file.rs')
-rw-r--r--rust/kernel/fs/file.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/rust/kernel/fs/file.rs b/rust/kernel/fs/file.rs
index 18cf579d3312..f1a3fa698745 100644
--- a/rust/kernel/fs/file.rs
+++ b/rust/kernel/fs/file.rs
@@ -10,7 +10,7 @@
use crate::{
bindings,
cred::Credential,
- error::{code::*, Error, Result},
+ error::{code::*, to_result, Error, Result},
sync::aref::{ARef, AlwaysRefCounted},
types::{NotThreadSafe, Opaque},
};
@@ -399,9 +399,8 @@ impl FileDescriptorReservation {
pub fn get_unused_fd_flags(flags: u32) -> Result<Self> {
// SAFETY: FFI call, there are no safety requirements on `flags`.
let fd: i32 = unsafe { bindings::get_unused_fd_flags(flags) };
- if fd < 0 {
- return Err(Error::from_errno(fd));
- }
+ to_result(fd)?;
+
Ok(Self {
fd: fd as u32,
_not_send: NotThreadSafe,