From 64f9283b6763200351860e2329fa3b0f68061db6 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Thu, 9 Feb 2017 01:32:18 +0000 Subject: [PATCH] Fix Clippy warnings --- src/apresolve.rs | 2 +- src/authentication/discovery.rs | 9 ++++----- src/authentication/mod.rs | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/apresolve.rs b/src/apresolve.rs index 80d1f4a5..9814a5b5 100644 --- a/src/apresolve.rs +++ b/src/apresolve.rs @@ -16,7 +16,7 @@ pub struct APResolveData { pub fn apresolve(handle: &Handle) -> Box> { let url = Url::parse(APRESOLVE_ENDPOINT).expect("invalid AP resolve URL"); - let client = Client::new(&handle); + let client = Client::new(handle); let response = client.get(url); let body = response.and_then(|response| { diff --git a/src/authentication/discovery.rs b/src/authentication/discovery.rs index 4e38a43f..e2c74df9 100644 --- a/src/authentication/discovery.rs +++ b/src/authentication/discovery.rs @@ -128,13 +128,13 @@ impl Discovery { let checksum_key = { let mut h = crypto::hmac::Hmac::new(crypto::sha1::Sha1::new(), &base_key); - h.input("checksum".as_bytes()); + h.input(b"checksum"); h.result().code().to_owned() }; let encryption_key = { let mut h = crypto::hmac::Hmac::new(crypto::sha1::Sha1::new(), &base_key); - h.input("encryption".as_bytes()); + h.input(b"encryption"); h.result().code().to_owned() }; @@ -149,9 +149,8 @@ impl Discovery { let decrypted = { let mut data = vec![0u8; encrypted.len()]; let mut cipher = crypto::aes::ctr(crypto::aes::KeySize::KeySize128, - &encryption_key[0..16], - &iv); - cipher.process(&encrypted, &mut data); + &encryption_key[0..16], iv); + cipher.process(encrypted, &mut data); String::from_utf8(data).unwrap() }; diff --git a/src/authentication/mod.rs b/src/authentication/mod.rs index c48227d3..17f99874 100644 --- a/src/authentication/mod.rs +++ b/src/authentication/mod.rs @@ -153,7 +153,7 @@ fn deserialize_protobuf_enum(de: D) -> Result where T: ProtobufEnum, D: serde::Deserializer { let v : i32 = try!(serde::Deserialize::deserialize(de)); - T::from_i32(v).ok_or(serde::de::Error::custom("Invalid enum value")) + T::from_i32(v).ok_or_else(|| serde::de::Error::custom("Invalid enum value")) } fn serialize_base64(v: &T, ser: S) -> Result @@ -197,7 +197,7 @@ pub fn get_credentials(device_name: &str, device_id: &str, (None, _, None) => { info!("No username provided and no stored credentials, starting discovery ..."); - discovery_login(device_name.clone(), device_id.clone()).unwrap() + discovery_login(device_name, device_id).unwrap() } } }