summaryrefslogtreecommitdiff
path: root/test/sys
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2017-08-17 21:31:29 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2017-08-17 21:31:29 +0000
commite09225759e4118cd0fc7ba2f1cdd6e8d2e3a8742 (patch)
treede41045e952784777e9abef7f597db0b6ffd4db3 /test/sys
parentc48d48b69efdebdd73cab30f42ff2ef337b3a414 (diff)
parent9c9af2c6638c9a2c91fb18ff3cb79c4bac626965 (diff)
downloadnix-e09225759e4118cd0fc7ba2f1cdd6e8d2e3a8742.zip
Merge #700
700: Get rid of a lot of transmutes r=asomers Most could be replaced by simple raw pointer casts (or even perfectly safe coercions!). cc #373
Diffstat (limited to 'test/sys')
-rw-r--r--test/sys/test_socket.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs
index 31b153dd..b8dc662e 100644
--- a/test/sys/test_socket.rs
+++ b/test/sys/test_socket.rs
@@ -1,5 +1,5 @@
use nix::sys::socket::{InetAddr, UnixAddr, getsockname};
-use std::mem;
+use std::{mem, slice};
use std::net::{self, Ipv6Addr, SocketAddr, SocketAddrV6};
use std::path::Path;
use std::str::FromStr;
@@ -52,10 +52,13 @@ pub fn test_inetv6_addr_to_sock_addr() {
#[test]
pub fn test_path_to_sock_addr() {
- let actual = Path::new("/foo/bar");
+ let path = "/foo/bar";
+ let actual = Path::new(path);
let addr = UnixAddr::new(actual).unwrap();
- let expect: &'static [c_char] = unsafe { mem::transmute(&b"/foo/bar"[..]) };
+ let expect: &[c_char] = unsafe {
+ slice::from_raw_parts(path.as_bytes().as_ptr() as *const c_char, path.len())
+ };
assert_eq!(&addr.0.sun_path[..8], expect);
assert_eq!(addr.path(), Some(actual));