From 8ddc054cfb86899f1189efc5f9454fff5975f94a Mon Sep 17 00:00:00 2001 From: mamoniot Date: Thu, 23 Mar 2023 08:52:10 -0400 Subject: [PATCH] ran cargo fmt --- zssp/src/fragged.rs | 2 -- zssp/src/zssp.rs | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/zssp/src/fragged.rs b/zssp/src/fragged.rs index feadde5a1..f3f5f1eae 100644 --- a/zssp/src/fragged.rs +++ b/zssp/src/fragged.rs @@ -58,7 +58,6 @@ impl Fragged { #[inline(always)] pub fn assemble(&mut self, counter: u64, fragment: Fragment, fragment_no: u8, fragment_count: u8) -> Option> { if fragment_no < fragment_count && (fragment_count as usize) <= MAX_FRAGMENTS { - // If the counter has changed, reset the structure to receive a new packet. if counter != self.counter { if needs_drop::() { @@ -94,7 +93,6 @@ impl Fragged { return Some(Assembled(unsafe { std::mem::transmute_copy(&self.frags) }, fragment_count as usize)); } } - } return None; } diff --git a/zssp/src/zssp.rs b/zssp/src/zssp.rs index 85b66a9e5..f07260799 100644 --- a/zssp/src/zssp.rs +++ b/zssp/src/zssp.rs @@ -11,8 +11,8 @@ use std::collections::hash_map::RandomState; //use std::collections::hash_map::DefaultHasher; -use std::hash::{BuildHasher, Hash, Hasher}; use std::collections::HashMap; +use std::hash::{BuildHasher, Hash, Hasher}; use std::num::NonZeroU64; use std::sync::atomic::{AtomicI64, AtomicU64, AtomicUsize, Ordering}; use std::sync::{Arc, Mutex, MutexGuard, RwLock, Weak}; @@ -533,8 +533,8 @@ impl Context { source.hash(&mut hasher); hasher.write_u64(incoming_counter); let hashed_counter = hasher.finish(); - let idx0 = (hashed_counter as usize)%MAX_INCOMPLETE_SESSION_QUEUE_SIZE; - let idx1 = (hashed_counter as usize)/MAX_INCOMPLETE_SESSION_QUEUE_SIZE%MAX_INCOMPLETE_SESSION_QUEUE_SIZE; + let idx0 = (hashed_counter as usize) % MAX_INCOMPLETE_SESSION_QUEUE_SIZE; + let idx1 = (hashed_counter as usize) / MAX_INCOMPLETE_SESSION_QUEUE_SIZE % MAX_INCOMPLETE_SESSION_QUEUE_SIZE; // Open hash lookup of just 2 slots. // By only checking 2 slots we avoid a full table lookup while also minimizing the chance that 2 offers collide. @@ -571,7 +571,7 @@ impl Context { &mut check_allow_incoming_session, &mut check_accept_session, data_buf, - 1,// The incoming_counter on init packets is only meant for DOS resistant defragmentation, we do not want to use it for anything noise related. + 1, // The incoming_counter on init packets is only meant for DOS resistant defragmentation, we do not want to use it for anything noise related. incoming_packet, packet_type, None,