summaryrefslogtreecommitdiff
path: root/src/sys/socket
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-09 01:05:23 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-09 01:05:23 +0000
commitf1b12d6b1b8bf6d8ad41e7b2967b95c6f876745c (patch)
treedbbf94ee5189b13ea4d448ba63512b43f85b4ba8 /src/sys/socket
parent5a3ac8df3fa2de86477d961d8b5720b1d283b2d5 (diff)
parentca035734df2e3dfeb866cbfee51de7b582be83f5 (diff)
downloadnix-f1b12d6b1b8bf6d8ad41e7b2967b95c6f876745c.zip
Merge #995
995: Replace try! with ? r=asomers a=asomers try! is not available in Rust 2018. It would be premature to convert the entire project to Rust 2018, since that would bump the minimum compiler to 1.31.0. But his change will help us when we do convert it eventually. Co-authored-by: Alan Somers <asomers@gmail.com>
Diffstat (limited to 'src/sys/socket')
-rw-r--r--src/sys/socket/addr.rs8
-rw-r--r--src/sys/socket/mod.rs10
-rw-r--r--src/sys/socket/sockopt.rs2
3 files changed, 10 insertions, 10 deletions
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index ebd32c1f..b2cafe3c 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -600,7 +600,7 @@ pub struct UnixAddr(pub libc::sockaddr_un, pub usize);
impl UnixAddr {
/// Create a new sockaddr_un representing a filesystem path.
pub fn new<P: ?Sized + NixPath>(path: &P) -> Result<UnixAddr> {
- try!(path.with_nix_path(|cstr| {
+ path.with_nix_path(|cstr| {
unsafe {
let mut ret = libc::sockaddr_un {
sun_family: AddressFamily::Unix as sa_family_t,
@@ -619,7 +619,7 @@ impl UnixAddr {
Ok(UnixAddr(ret, bytes.len()))
}
- }))
+ })?
}
/// Create a new `sockaddr_un` representing an address in the "abstract namespace".
@@ -759,7 +759,7 @@ impl SockAddr {
}
pub fn new_unix<P: ?Sized + NixPath>(path: &P) -> Result<SockAddr> {
- Ok(SockAddr::Unix(try!(UnixAddr::new(path))))
+ Ok(SockAddr::Unix(UnixAddr::new(path)?))
}
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -1079,7 +1079,7 @@ pub mod sys_control {
ctl_name[..name.len()].clone_from_slice(name.as_bytes());
let mut info = ctl_ioc_info { ctl_id: 0, ctl_name: ctl_name };
- unsafe { try!(ctl_info(sockfd, &mut info)); }
+ unsafe { ctl_info(sockfd, &mut info)?; }
Ok(SysControlAddr::new(info.ctl_id, unit))
}
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index 85acaf4c..2ac0e24a 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -750,7 +750,7 @@ pub fn recvmsg<'a, T>(fd: RawFd, iov: &[IoVec<&mut [u8]>], cmsg_buffer: Option<&
};
Ok(unsafe { RecvMsg {
- bytes: try!(Errno::result(ret)) as usize,
+ bytes: Errno::result(ret)? as usize,
cmsg_buffer,
address: sockaddr_storage_to_addr(&address,
mhdr.msg_namelen as usize).ok(),
@@ -890,13 +890,13 @@ pub fn recvfrom(sockfd: RawFd, buf: &mut [u8]) -> Result<(usize, SockAddr)> {
let addr: sockaddr_storage = mem::zeroed();
let mut len = mem::size_of::<sockaddr_storage>() as socklen_t;
- let ret = try!(Errno::result(libc::recvfrom(
+ let ret = Errno::result(libc::recvfrom(
sockfd,
buf.as_ptr() as *mut c_void,
buf.len() as size_t,
0,
mem::transmute(&addr),
- &mut len as *mut socklen_t)));
+ &mut len as *mut socklen_t))?;
sockaddr_storage_to_addr(&addr, len as usize)
.map(|addr| (ret as usize, addr))
@@ -1004,7 +1004,7 @@ pub fn getpeername(fd: RawFd) -> Result<SockAddr> {
let ret = libc::getpeername(fd, mem::transmute(&addr), &mut len);
- try!(Errno::result(ret));
+ Errno::result(ret)?;
sockaddr_storage_to_addr(&addr, len as usize)
}
@@ -1020,7 +1020,7 @@ pub fn getsockname(fd: RawFd) -> Result<SockAddr> {
let ret = libc::getsockname(fd, mem::transmute(&addr), &mut len);
- try!(Errno::result(ret));
+ Errno::result(ret)?;
sockaddr_storage_to_addr(&addr, len as usize)
}
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index 17119384..f166d997 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -89,7 +89,7 @@ macro_rules! getsockopt_impl {
let res = libc::getsockopt(fd, $level, $flag,
getter.ffi_ptr(),
getter.ffi_len());
- try!(Errno::result(res));
+ Errno::result(res)?;
Ok(getter.unwrap())
}