diff --git a/filedescriptor/src/unix.rs b/filedescriptor/src/unix.rs index 58bdeaaf4..6d48d602a 100644 --- a/filedescriptor/src/unix.rs +++ b/filedescriptor/src/unix.rs @@ -321,10 +321,7 @@ impl Pipe { let mut fds = [-1i32; 2]; let res = unsafe { libc::pipe(fds.as_mut_ptr()) }; if res == -1 { - bail!( - "failed to create a pipe: {:?}", - std::io::Error::last_os_error() - ) + Err(Error::Pipe(std::io::Error::last_os_error())) } else { let mut read = FileDescriptor { handle: OwnedHandle { @@ -382,10 +379,7 @@ pub fn socketpair_impl() -> Result<(FileDescriptor, FileDescriptor)> { let mut fds = [-1i32; 2]; let res = unsafe { libc::socketpair(libc::PF_LOCAL, libc::SOCK_STREAM, 0, fds.as_mut_ptr()) }; if res == -1 { - bail!( - "failed to create a socketpair: {:?}", - std::io::Error::last_os_error() - ) + Err(Error::Socketpair(std::io::Error::last_os_error())) } else { let mut read = FileDescriptor { handle: OwnedHandle { @@ -443,7 +437,7 @@ mod macos { if fd < 0 { return Err(Error::IllegalFdValue(fd.into())); } - if fd >= FD_SETSIZE { + if fd as usize >= FD_SETSIZE { return Err(Error::FdValueOutsideFdSetSize(fd.into())); } Ok(())