summaryrefslogtreecommitdiff
path: root/src/sys/socket
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/socket')
-rw-r--r--src/sys/socket/mod.rs4
-rw-r--r--src/sys/socket/sockopt.rs12
2 files changed, 8 insertions, 8 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index beaa69ad..ca4505fa 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -1245,12 +1245,12 @@ pub unsafe fn sockaddr_storage_to_addr(
match c_int::from(addr.ss_family) {
libc::AF_INET => {
- assert!(len as usize == mem::size_of::<sockaddr_in>());
+ assert_eq!(len as usize, mem::size_of::<sockaddr_in>());
let ret = *(addr as *const _ as *const sockaddr_in);
Ok(SockAddr::Inet(InetAddr::V4(ret)))
}
libc::AF_INET6 => {
- assert!(len as usize == mem::size_of::<sockaddr_in6>());
+ assert_eq!(len as usize, mem::size_of::<sockaddr_in6>());
Ok(SockAddr::Inet(InetAddr::V6(*(addr as *const _ as *const sockaddr_in6))))
}
libc::AF_UNIX => {
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index 1271f645..691f66dd 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -411,7 +411,7 @@ unsafe impl<T> Get<T> for GetStruct<T> {
}
unsafe fn unwrap(self) -> T {
- assert!(self.len as usize == mem::size_of::<T>(), "invalid getsockopt implementation");
+ assert_eq!(self.len as usize, mem::size_of::<T>(), "invalid getsockopt implementation");
self.val
}
}
@@ -458,7 +458,7 @@ unsafe impl Get<bool> for GetBool {
}
unsafe fn unwrap(self) -> bool {
- assert!(self.len as usize == mem::size_of::<c_int>(), "invalid getsockopt implementation");
+ assert_eq!(self.len as usize, mem::size_of::<c_int>(), "invalid getsockopt implementation");
self.val != 0
}
}
@@ -505,7 +505,7 @@ unsafe impl Get<u8> for GetU8 {
}
unsafe fn unwrap(self) -> u8 {
- assert!(self.len as usize == mem::size_of::<u8>(), "invalid getsockopt implementation");
+ assert_eq!(self.len as usize, mem::size_of::<u8>(), "invalid getsockopt implementation");
self.val as u8
}
}
@@ -552,7 +552,7 @@ unsafe impl Get<usize> for GetUsize {
}
unsafe fn unwrap(self) -> usize {
- assert!(self.len as usize == mem::size_of::<c_int>(), "invalid getsockopt implementation");
+ assert_eq!(self.len as usize, mem::size_of::<c_int>(), "invalid getsockopt implementation");
self.val as usize
}
}
@@ -644,7 +644,7 @@ mod test {
let (a, b) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()).unwrap();
let a_type = getsockopt(a, super::SockType).unwrap();
- assert!(a_type == SockType::Stream);
+ assert_eq!(a_type, SockType::Stream);
close(a).unwrap();
close(b).unwrap();
}
@@ -656,7 +656,7 @@ mod test {
let s = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), None).unwrap();
let s_type = getsockopt(s, super::SockType).unwrap();
- assert!(s_type == SockType::Datagram);
+ assert_eq!(s_type, SockType::Datagram);
close(s).unwrap();
}