Skip to content
Snippets Groups Projects
Commit b389e483 authored by stratact's avatar stratact
Browse files

Have `open()` and `dup()` match `-1` for `Err` instead of `0`

parent 9daae71c
No related branches found
No related tags found
No related merge requests found
...@@ -6,14 +6,14 @@ pub struct RawFile(usize); ...@@ -6,14 +6,14 @@ pub struct RawFile(usize);
impl RawFile { impl RawFile {
pub fn open<T: AsRef<[u8]>>(path: T, flags: usize, mode: usize) -> Result<RawFile, ()> { pub fn open<T: AsRef<[u8]>>(path: T, flags: usize, mode: usize) -> Result<RawFile, ()> {
match open(path.as_ref()[0] as *const i8, flags as i32, mode as u16) { match open(path.as_ref()[0] as *const i8, flags as i32, mode as u16) {
0 => Err(()), -1 => Err(()),
n => Ok(RawFile(n as usize)) n => Ok(RawFile(n as usize))
} }
} }
pub fn dup(&self, _buf: &[u8]) -> Result<RawFile, ()> { pub fn dup(&self, _buf: &[u8]) -> Result<RawFile, ()> {
match dup(self.0 as i32) { match dup(self.0 as i32) {
0 => Err(()), -1 => Err(()),
n => Ok(RawFile(n as usize)) n => Ok(RawFile(n as usize))
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment