Making clippy happy

pull/29/head
Dennis Schwerdel 2017-05-04 07:26:21 +02:00
parent 21837abf68
commit 2d11454316
8 changed files with 14 additions and 13 deletions

View File

@ -5,7 +5,7 @@ This project follows [semantic versioning](http://semver.org).
### UNRELEASED
- [added] Added more tests
- [changed] Updated dependencies
- [changed] Updated dependencies and libsodium
### v0.8.0 (2016-11-25)

View File

@ -78,7 +78,7 @@ impl PeerList {
#[inline]
fn is_connected<Addr: ToSocketAddrs+fmt::Debug>(&self, addr: Addr) -> Result<bool, Error> {
for addr in try!(resolve(addr)) {
for addr in try!(resolve(&addr)) {
if self.contains_addr(&addr) {
return Ok(true);
}
@ -319,7 +319,7 @@ impl<P: Protocol> GenericCloud<P> {
/// Returns an `Error::SocketError` if the given address is a name that failed to resolve to
/// actual addresses.
fn is_blacklisted<Addr: ToSocketAddrs+fmt::Debug>(&self, addr: Addr) -> Result<bool, Error> {
for addr in try!(resolve(addr)) {
for addr in try!(resolve(&addr)) {
if self.blacklist_peers.contains(&addr) {
return Ok(true);
}
@ -343,7 +343,7 @@ impl<P: Protocol> GenericCloud<P> {
let subnets = self.addresses.clone();
let node_id = self.node_id;
// Send a message to each resolved address
for a in try!(resolve(addr)) {
for a in try!(resolve(&addr)) {
// Ignore error this time
let mut msg = Message::Init(0, node_id, subnets.clone());
self.send_msg(a, &mut msg).ok();

View File

@ -171,7 +171,7 @@ impl Config {
Encoder::write_u32((s.finish() & 0xffffffff) as u32, &mut data);
data
} else {
let num = try_fail!(u32::from_str_radix(&name, 16), "Failed to parse header magic: {}");
let num = try_fail!(u32::from_str_radix(name, 16), "Failed to parse header magic: {}");
let mut data = [0; 4];
Encoder::write_u32(num, &mut data);
data

View File

@ -289,7 +289,7 @@ impl Crypto {
Crypto::ChaCha20Poly1305{ref key, ref mut nonce} => {
inc_nonce_12(nonce);
let mut clen: u64 = buf.len() as u64;
assert!(nonce_bytes.len() == nonce.len());
assert_eq!(nonce_bytes.len(), nonce.len());
assert!(clen as usize >= mlen + crypto_aead_chacha20poly1305_ietf_ABYTES);
let res = unsafe { crypto_aead_chacha20poly1305_ietf_encrypt(
buf.as_mut_ptr(), // Base pointer to buffer
@ -311,7 +311,7 @@ impl Crypto {
Crypto::AES256GCM{ref state, ref mut nonce} => {
inc_nonce_12(nonce);
let mut clen: u64 = buf.len() as u64;
assert!(nonce_bytes.len() == nonce.len());
assert_eq!(nonce_bytes.len(), nonce.len());
assert!(clen as usize >= mlen + crypto_aead_aes256gcm_ABYTES);
let res = unsafe { crypto_aead_aes256gcm_encrypt_afternm(
buf.as_mut_ptr(), // Base pointer to buffer

View File

@ -47,8 +47,8 @@ impl Protocol for Frame {
dst[2..8].copy_from_slice(dst_data);
Ok((Address{data: src, len: 8}, Address{data: dst, len: 8}))
} else {
let src = try!(Address::read_from_fixed(&src_data, 6));
let dst = try!(Address::read_from_fixed(&dst_data, 6));
let src = try!(Address::read_from_fixed(src_data, 6));
let dst = try!(Address::read_from_fixed(dst_data, 6));
Ok((src, dst))
}
}

View File

@ -124,7 +124,7 @@ impl log::Log for DualLogger {
}
}
fn run_script(script: String, ifname: &str) {
fn run_script(script: &str, ifname: &str) {
let mut cmd = Command::new("sh");
cmd.arg("-c").arg(&script).env("IFNAME", ifname);
debug!("Running script: {:?}", cmd);
@ -170,7 +170,7 @@ fn run<T: Protocol> (config: Config) {
};
let mut cloud = GenericCloud::<T>::new(magic, device, config.port, table, peer_timeout, learning, broadcasting, ranges, crypto, port_forwarding);
if let Some(script) = config.ifup {
run_script(script, cloud.ifname());
run_script(&script, cloud.ifname());
}
for addr in config.peers {
try_fail!(cloud.connect(&addr as &str), "Failed to send message to {}: {}", &addr);
@ -192,7 +192,7 @@ fn run<T: Protocol> (config: Config) {
}
cloud.run();
if let Some(script) = config.ifdown {
run_script(script, cloud.ifname());
run_script(&script, cloud.ifname());
}
}

View File

@ -122,7 +122,7 @@ impl FromStr for Address {
if parts.len() == 6 {
let mut bytes = [0; 16];
for i in 0..6 {
bytes[i] = try!(u8::from_str_radix(&parts[i], 16).map_err(|_| Error::Parse("Failed to parse mac")));
bytes[i] = try!(u8::from_str_radix(parts[i], 16).map_err(|_| Error::Parse("Failed to parse mac")));
}
return Ok(Address{data: bytes, len: 6});
}

View File

@ -123,6 +123,7 @@ macro_rules! try_fail {
}
#[allow(unknown_lints,needless_pass_by_value)]
pub fn resolve<Addr: ToSocketAddrs+fmt::Debug>(addr: Addr) -> Result<Vec<SocketAddr>, Error> {
let addrs = try!(addr.to_socket_addrs().map_err(|_| Error::Name(format!("{:?}", addr))));
// Remove duplicates in addrs (why are there duplicates???)