diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index bb3e986..69bf1b9 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -39,7 +39,7 @@ jobs: components: clippy, rustfmt override: true - name: Cache cargo registry - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~/.cargo/registry key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} diff --git a/src/association/mod.rs b/src/association/mod.rs index fb96025..4f151f1 100644 --- a/src/association/mod.rs +++ b/src/association/mod.rs @@ -1344,7 +1344,7 @@ impl Association { } fn handle_forward_tsn(&mut self, c: &ChunkForwardTsn) -> Result> { - trace!("[{}] FwdTSN: {}", self.side, c.to_string()); + trace!("[{}] FwdTSN: {}", self.side, c); if !self.use_forward_tsn { warn!("[{}] received FwdTSN but not enabled", self.side); @@ -1981,11 +1981,7 @@ impl Association { bytes_queued += s.get_num_bytes_in_reassembly_queue() as u32; } - if bytes_queued >= self.max_receive_buffer_size { - 0 - } else { - self.max_receive_buffer_size - bytes_queued - } + self.max_receive_buffer_size.saturating_sub(bytes_queued) } /// gather_outbound gathers outgoing packets. The returned bool value set to diff --git a/src/association/timer.rs b/src/association/timer.rs index 6ee9fea..094a3af 100644 --- a/src/association/timer.rs +++ b/src/association/timer.rs @@ -90,7 +90,7 @@ impl TimerTable { } pub fn is_expired(&mut self, timer: Timer, after: Instant) -> (bool, bool, usize) { - let expired = self.data[timer as usize].map_or(false, |x| x <= after); + let expired = self.data[timer as usize].is_some_and(|x| x <= after); let mut failure = false; if expired { self.retrans[timer as usize] += 1; diff --git a/src/packet.rs b/src/packet.rs index 6a1be88..ddeb933 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -50,7 +50,6 @@ use std::fmt; ///+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ///| Checksum | ///+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - pub(crate) const PACKET_HEADER_SIZE: usize = 12; #[derive(Default, Debug)] diff --git a/src/queue/payload_queue.rs b/src/queue/payload_queue.rs index 5ee0b62..a7462c0 100644 --- a/src/queue/payload_queue.rs +++ b/src/queue/payload_queue.rs @@ -128,7 +128,7 @@ impl PayloadQueue { } pub(crate) fn mark_as_acked(&mut self, tsn: u32) -> usize { - let n_bytes_acked = if let Some(c) = self.chunk_map.get_mut(&tsn) { + if let Some(c) = self.chunk_map.get_mut(&tsn) { c.acked = true; c.retransmit = false; let n = c.user_data.len(); @@ -137,9 +137,7 @@ impl PayloadQueue { n } else { 0 - }; - - n_bytes_acked + } } pub(crate) fn get_last_tsn_received(&self) -> Option<&u32> {