Make clippy happy

This commit is contained in:
Dennis Schwerdel 2021-12-19 13:54:09 +01:00
parent 798964030f
commit 79916104ba
5 changed files with 16 additions and 16 deletions

View File

@ -379,7 +379,7 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
for entry in &mut self.reconnect_peers { for entry in &mut self.reconnect_peers {
// Schedule for next second if node is connected // Schedule for next second if node is connected
for addr in &entry.resolved { for addr in &entry.resolved {
if self.peers.contains_key(&addr) { if self.peers.contains_key(addr) {
entry.tries = 0; entry.tries = 0;
entry.timeout = 1; entry.timeout = 1;
entry.next = now + 1; entry.next = now + 1;
@ -424,7 +424,7 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
let now = TS::now(); let now = TS::now();
let mut buffer = MsgBuffer::new(SPACE_BEFORE); let mut buffer = MsgBuffer::new(SPACE_BEFORE);
let mut del: SmallVec<[SocketAddr; 3]> = SmallVec::new(); let mut del: SmallVec<[SocketAddr; 3]> = SmallVec::new();
for (&addr, ref data) in &self.peers { for (&addr, data) in &self.peers {
if data.timeout < now { if data.timeout < now {
del.push(addr); del.push(addr);
} }

View File

@ -354,7 +354,7 @@ impl Config {
if let Some(ref s) = self.hook { if let Some(ref s) = self.hook {
script = Some(s); script = Some(s);
} }
if let Some(ref s) = self.hooks.get(event) { if let Some(s) = self.hooks.get(event) {
script = Some(s); script = Some(s);
} }
if script.is_none() { if script.is_none() {

View File

@ -110,7 +110,7 @@ struct CryptoKey {
impl CryptoKey { impl CryptoKey {
fn new(rand: &SystemRandom, key: LessSafeKey, nonce_half: bool) -> Self { fn new(rand: &SystemRandom, key: LessSafeKey, nonce_half: bool) -> Self {
let mut send_nonce = Nonce::random(&rand); let mut send_nonce = Nonce::random(rand);
send_nonce.set_msb(if nonce_half { 0x80 } else { 0x00 }); send_nonce.set_msb(if nonce_half { 0x80 } else { 0x00 });
CryptoKey { CryptoKey {
key, key,

View File

@ -235,7 +235,7 @@ impl InitMsg {
let signed_data = &r.into_inner()[0..pos]; let signed_data = &r.into_inner()[0..pos];
let public_key = signature::UnparsedPublicKey::new(&ED25519, &public_key_data); let public_key = signature::UnparsedPublicKey::new(&ED25519, &public_key_data);
if public_key.verify(&signed_data, &signature).is_err() { if public_key.verify(signed_data, &signature).is_err() {
return Err(Error::Crypto("invalid signature")); return Err(Error::Crypto("invalid signature"));
} }
@ -319,7 +319,7 @@ impl InitMsg {
w.write_u8(Self::PART_ECDH_PUBLIC_KEY)?; w.write_u8(Self::PART_ECDH_PUBLIC_KEY)?;
let key_bytes = ecdh_public_key.bytes(); let key_bytes = ecdh_public_key.bytes();
w.write_u16::<NetworkEndian>(key_bytes.len() as u16)?; w.write_u16::<NetworkEndian>(key_bytes.len() as u16)?;
w.write_all(&key_bytes)?; w.write_all(key_bytes)?;
} }
_ => (), _ => (),
} }
@ -522,8 +522,8 @@ impl<P: Payload> InitState<P> {
}, },
_ => unreachable!(), _ => unreachable!(),
}; };
let mut bytes = out.buffer(); let bytes = out.buffer();
let len = msg.write_to(&mut bytes, &self.key_pair).expect("Buffer too small"); let len = msg.write_to(bytes, &self.key_pair).expect("Buffer too small");
self.last_message = Some(bytes[0..len].to_vec()); self.last_message = Some(bytes[0..len].to_vec());
out.set_length(len); out.set_length(len);
} }
@ -662,7 +662,7 @@ mod tests {
impl Payload for Vec<u8> { impl Payload for Vec<u8> {
fn write_to(&self, buffer: &mut MsgBuffer) { fn write_to(&self, buffer: &mut MsgBuffer) {
buffer.buffer().write_all(&self).expect("Buffer too small"); buffer.buffer().write_all(self).expect("Buffer too small");
buffer.set_length(self.len()) buffer.set_length(self.len())
} }

View File

@ -176,7 +176,7 @@ impl RotationState {
if let Some(ref private_key) = self.proposed { if let Some(ref private_key) = self.proposed {
// Still a proposed key that has not been confirmed, proposal must have been lost // Still a proposed key that has not been confirmed, proposal must have been lost
if self.timeout { if self.timeout {
let proposed_key = Self::compute_public_key(&private_key); let proposed_key = Self::compute_public_key(private_key);
if let Some((ref confirmed_key, message_id)) = self.confirmed { if let Some((ref confirmed_key, message_id)) = self.confirmed {
// Reconfirm last confirmed key // Reconfirm last confirmed key
Self::send( Self::send(
@ -271,7 +271,7 @@ mod tests {
assert!(key2.is_some()); assert!(key2.is_some());
let key2 = key2.unwrap(); let key2 = key2.unwrap();
assert_eq!(key2.id, 2); assert_eq!(key2.id, 2);
assert_eq!(key2.use_for_sending, false); assert!(!key2.use_for_sending);
assert!(!out2.is_empty()); assert!(!out2.is_empty());
let msg2 = out2.msg().unwrap(); let msg2 = out2.msg().unwrap();
assert_eq!(msg2.message_id, 2); assert_eq!(msg2.message_id, 2);
@ -281,14 +281,14 @@ mod tests {
assert!(key.is_some()); assert!(key.is_some());
let key = key.unwrap(); let key = key.unwrap();
assert_eq!(key.id, 2); assert_eq!(key.id, 2);
assert_eq!(key.use_for_sending, true); assert!(key.use_for_sending);
// Cycle 2 // Cycle 2
let key1 = node1.cycle(&mut out1); let key1 = node1.cycle(&mut out1);
let key2 = node2.cycle(&mut out2); let key2 = node2.cycle(&mut out2);
assert!(key1.is_some()); assert!(key1.is_some());
let key1 = key1.unwrap(); let key1 = key1.unwrap();
assert_eq!(key1.id, 3); assert_eq!(key1.id, 3);
assert_eq!(key1.use_for_sending, false); assert!(!key1.use_for_sending);
assert!(!out1.is_empty()); assert!(!out1.is_empty());
let msg1 = out1.msg().unwrap(); let msg1 = out1.msg().unwrap();
assert_eq!(msg1.message_id, 3); assert_eq!(msg1.message_id, 3);
@ -300,7 +300,7 @@ mod tests {
assert!(key.is_some()); assert!(key.is_some());
let key = key.unwrap(); let key = key.unwrap();
assert_eq!(key.id, 3); assert_eq!(key.id, 3);
assert_eq!(key.use_for_sending, true); assert!(key.use_for_sending);
// Cycle 3 // Cycle 3
let key1 = node1.cycle(&mut out1); let key1 = node1.cycle(&mut out1);
let key2 = node2.cycle(&mut out2); let key2 = node2.cycle(&mut out2);
@ -309,7 +309,7 @@ mod tests {
assert!(key2.is_some()); assert!(key2.is_some());
let key2 = key2.unwrap(); let key2 = key2.unwrap();
assert_eq!(key2.id, 4); assert_eq!(key2.id, 4);
assert_eq!(key2.use_for_sending, false); assert!(!key2.use_for_sending);
assert!(!out2.is_empty()); assert!(!out2.is_empty());
let msg2 = out2.msg().unwrap(); let msg2 = out2.msg().unwrap();
assert_eq!(msg2.message_id, 4); assert_eq!(msg2.message_id, 4);
@ -319,7 +319,7 @@ mod tests {
assert!(key.is_some()); assert!(key.is_some());
let key = key.unwrap(); let key = key.unwrap();
assert_eq!(key.id, 4); assert_eq!(key.id, 4);
assert_eq!(key.use_for_sending, true); assert!(key.use_for_sending);
} }
#[test] #[test]