Skip to content

Commit

Permalink
Silence clippy::unnecessary_min_or_max
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzypixelz committed Sep 6, 2024
1 parent ea41e06 commit c224401
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
15 changes: 13 additions & 2 deletions io/zenoh-transport/src/unicast/establishment/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use zenoh_link::LinkUnicast;
use zenoh_protocol::{
core::{Field, Resolution, WhatAmI, ZenohIdProto},
transport::{
batch_size,
close::{self, Close},
BatchSize, InitAck, OpenAck, TransportBody, TransportMessage, TransportSn,
},
Expand Down Expand Up @@ -210,7 +211,14 @@ impl<'a, 'b: 'a> AcceptFsm for &'a mut AcceptLink<'b> {
};

// Compute the minimum batch size
state.transport.batch_size = state.transport.batch_size.min(init_syn.batch_size);
#[allow(clippy::unnecessary_min_or_max)]
{
state.transport.batch_size = state
.transport
.batch_size
.min(init_syn.batch_size)
.min(batch_size::UNICAST);
}

// Extension QoS
self.ext_qos
Expand Down Expand Up @@ -679,10 +687,13 @@ pub(crate) async fn accept_link(link: LinkUnicast, manager: &TransportManager) -
};
}

#[allow(clippy::unnecessary_min_or_max)]
let batch_size = manager.config.batch_size.min(batch_size::UNICAST).min(mtu);

let iack_out = {
let mut state = State {
transport: StateTransport {
batch_size: manager.config.batch_size.min(mtu),
batch_size,
resolution: manager.config.resolution,
ext_qos: ext::qos::StateAccept::new(manager.config.unicast.is_qos),
#[cfg(feature = "transport_multilink")]
Expand Down
12 changes: 10 additions & 2 deletions io/zenoh-transport/src/unicast/establishment/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use zenoh_link::LinkUnicast;
use zenoh_protocol::{
core::{Field, Resolution, WhatAmI, ZenohIdProto},
transport::{
close, BatchSize, Close, InitSyn, OpenSyn, TransportBody, TransportMessage, TransportSn,
batch_size, close, BatchSize, Close, InitSyn, OpenSyn, TransportBody, TransportMessage,
TransportSn,
},
};
use zenoh_result::ZResult;
Expand Down Expand Up @@ -568,9 +569,16 @@ pub(crate) async fn open_link(
ext_compression: ext::compression::CompressionFsm::new(),
};

#[allow(clippy::unnecessary_min_or_max)]
let batch_size = manager
.config
.batch_size
.min(link.config.batch.mtu)
.min(batch_size::UNICAST);

let mut state = State {
transport: StateTransport {
batch_size: manager.config.batch_size.min(link.config.batch.mtu),
batch_size,
resolution: manager.config.resolution,
ext_qos: ext::qos::StateOpen::new(manager.config.unicast.is_qos),
#[cfg(feature = "transport_multilink")]
Expand Down

0 comments on commit c224401

Please sign in to comment.