summaryrefslogtreecommitdiff
path: root/test/sys/test_socket.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2019-07-02 13:39:25 -0600
committerAlan Somers <asomers@gmail.com>2019-07-13 15:05:08 -0600
commitc156af5a90e89291d4c540610549c3132d884661 (patch)
tree9c4d25b5b9888f1d8993f979a5d0ed5a06270335 /test/sys/test_socket.rs
parent5e463aa51f0e644d54c21f0db2effa4b757f982a (diff)
downloadnix-c156af5a90e89291d4c540610549c3132d884661.zip
Fix warnings on Rust 1.37.0
* Replace obsolete range syntax "..." with inclusive range "..=" * Use dyn Trait syntax instead of Box<Trait> * Raise MSRV to 1.27.0 (for dyn Trait syntax) * Raise MSRV to 1.31.0 (because of rand) tempfile pulls in rand, and rand pulls in fuchsia-cprng, which requires 1.31.0. Why rand pulls in fuchsia-cprng I don't know. It's specified as a target-specific dependency, but Cargo tries to build it anyway (only on Linux, not on FreeBSD or OSX). A bug in Cargo 1.27.0?
Diffstat (limited to 'test/sys/test_socket.rs')
-rw-r--r--test/sys/test_socket.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs
index 12afc84c..a71d2767 100644
--- a/test/sys/test_socket.rs
+++ b/test/sys/test_socket.rs
@@ -1,4 +1,5 @@
-use nix::sys::socket::{InetAddr, UnixAddr, getsockname};
+use nix::ifaddrs::InterfaceAddress;
+use nix::sys::socket::{AddressFamily, InetAddr, UnixAddr, getsockname};
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::net::{self, Ipv6Addr, SocketAddr, SocketAddrV6};
@@ -302,7 +303,7 @@ pub fn test_af_alg_cipher() {
#[cfg(any(target_os = "linux", target_os= "android"))]
#[test]
pub fn test_af_alg_aead() {
- use libc;
+ use libc::{ALG_OP_DECRYPT, ALG_OP_ENCRYPT};
use nix::sys::uio::IoVec;
use nix::unistd::{read, close};
use nix::sys::socket::{socket, sendmsg, bind, accept, setsockopt,
@@ -345,7 +346,7 @@ pub fn test_af_alg_aead() {
let session_socket = accept(sock).expect("accept failed");
let msgs = [
- ControlMessage::AlgSetOp(&libc::ALG_OP_ENCRYPT),
+ ControlMessage::AlgSetOp(&ALG_OP_ENCRYPT),
ControlMessage::AlgSetIv(iv.as_slice()),
ControlMessage::AlgSetAeadAssoclen(&assoc_size)];
let iov = IoVec::from_slice(&payload);
@@ -368,7 +369,7 @@ pub fn test_af_alg_aead() {
let session_socket = accept(sock).expect("accept failed");
let msgs = [
- ControlMessage::AlgSetOp(&libc::ALG_OP_DECRYPT),
+ ControlMessage::AlgSetOp(&ALG_OP_DECRYPT),
ControlMessage::AlgSetIv(iv.as_slice()),
ControlMessage::AlgSetAeadAssoclen(&assoc_size),
];
@@ -547,11 +548,11 @@ fn test_too_large_cmsgspace() {
#[cfg(any(target_os = "android", target_os = "linux"))]
fn test_impl_scm_credentials_and_rights(mut space: Vec<u8>) {
- use libc;
+ use libc::ucred;
use nix::sys::uio::IoVec;
use nix::unistd::{pipe, read, write, close, getpid, getuid, getgid};
use nix::sys::socket::{socketpair, sendmsg, recvmsg, setsockopt,
- AddressFamily, SockType, SockFlag,
+ SockType, SockFlag,
ControlMessage, ControlMessageOwned, MsgFlags};
use nix::sys::socket::sockopt::PassCred;
@@ -564,7 +565,7 @@ fn test_impl_scm_credentials_and_rights(mut space: Vec<u8>) {
{
let iov = [IoVec::from_slice(b"hello")];
- let cred = libc::ucred {
+ let cred = ucred {
pid: getpid().as_raw(),
uid: getuid().as_raw(),
gid: getgid().as_raw(),
@@ -623,7 +624,7 @@ fn test_impl_scm_credentials_and_rights(mut space: Vec<u8>) {
// Test creating and using named unix domain sockets
#[test]
pub fn test_unixdomain() {
- use nix::sys::socket::{AddressFamily, SockType, SockFlag};
+ use nix::sys::socket::{SockType, SockFlag};
use nix::sys::socket::{bind, socket, connect, listen, accept, SockAddr};
use nix::unistd::{read, write, close};
use std::thread;
@@ -661,7 +662,7 @@ pub fn test_unixdomain() {
pub fn test_syscontrol() {
use nix::Error;
use nix::errno::Errno;
- use nix::sys::socket::{AddressFamily, socket, SockAddr, SockType, SockFlag, SockProtocol};
+ use nix::sys::socket::{socket, SockAddr, SockType, SockFlag, SockProtocol};
let fd = socket(AddressFamily::System, SockType::Datagram,
SockFlag::empty(), SockProtocol::KextControl)
@@ -673,8 +674,6 @@ pub fn test_syscontrol() {
// connect(fd, &sockaddr).expect("connect failed");
}
-use nix::ifaddrs::InterfaceAddress;
-use nix::sys::socket::AddressFamily;
#[cfg(any(
target_os = "android",
target_os = "freebsd",
@@ -942,7 +941,7 @@ pub fn test_recv_ipv6pktinfo() {
use libc;
use nix::net::if_::*;
use nix::sys::socket::sockopt::Ipv6RecvPacketInfo;
- use nix::sys::socket::{bind, AddressFamily, SockFlag, SockType};
+ use nix::sys::socket::{bind, SockFlag, SockType};
use nix::sys::socket::{getsockname, setsockopt, socket};
use nix::sys::socket::{recvmsg, sendmsg, ControlMessageOwned, MsgFlags};
use nix::sys::uio::IoVec;