From ea41e06a301f73ab60724a751f8ab3c354df98ee Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Fri, 6 Sep 2024 07:43:59 +0000 Subject: [PATCH 1/6] Apply lints from Clippy 1.81.0 --- io/zenoh-links/zenoh-link-tcp/src/unicast.rs | 2 +- io/zenoh-links/zenoh-link-vsock/src/unicast.rs | 2 +- io/zenoh-transport/src/unicast/establishment/accept.rs | 9 ++------- io/zenoh-transport/src/unicast/establishment/open.rs | 9 ++------- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/io/zenoh-links/zenoh-link-tcp/src/unicast.rs b/io/zenoh-links/zenoh-link-tcp/src/unicast.rs index 7532055f8e..ec2e6e06b7 100644 --- a/io/zenoh-links/zenoh-link-tcp/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-tcp/src/unicast.rs @@ -348,7 +348,7 @@ impl LinkManagerUnicastTrait for LinkManagerUnicastTcp { // Update the endpoint locator address endpoint = EndPoint::new( endpoint.protocol(), - &format!("{local_addr}"), + format!("{local_addr}"), endpoint.metadata(), endpoint.config(), )?; diff --git a/io/zenoh-links/zenoh-link-vsock/src/unicast.rs b/io/zenoh-links/zenoh-link-vsock/src/unicast.rs index e7b261f292..979048b585 100644 --- a/io/zenoh-links/zenoh-link-vsock/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-vsock/src/unicast.rs @@ -267,7 +267,7 @@ impl LinkManagerUnicastTrait for LinkManagerUnicastVsock { // Update the endpoint locator address endpoint = EndPoint::new( endpoint.protocol(), - &format!("{local_addr}"), + format!("{local_addr}"), endpoint.metadata(), endpoint.config(), )?; diff --git a/io/zenoh-transport/src/unicast/establishment/accept.rs b/io/zenoh-transport/src/unicast/establishment/accept.rs index 64949357c6..01d38a47b8 100644 --- a/io/zenoh-transport/src/unicast/establishment/accept.rs +++ b/io/zenoh-transport/src/unicast/establishment/accept.rs @@ -24,7 +24,6 @@ use zenoh_link::LinkUnicast; use zenoh_protocol::{ core::{Field, Resolution, WhatAmI, ZenohIdProto}, transport::{ - batch_size, close::{self, Close}, BatchSize, InitAck, OpenAck, TransportBody, TransportMessage, TransportSn, }, @@ -211,11 +210,7 @@ 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) - .min(batch_size::UNICAST); + state.transport.batch_size = state.transport.batch_size.min(init_syn.batch_size); // Extension QoS self.ext_qos @@ -687,7 +682,7 @@ pub(crate) async fn accept_link(link: LinkUnicast, manager: &TransportManager) - let iack_out = { let mut state = State { transport: StateTransport { - batch_size: manager.config.batch_size.min(batch_size::UNICAST).min(mtu), + batch_size: manager.config.batch_size.min(mtu), resolution: manager.config.resolution, ext_qos: ext::qos::StateAccept::new(manager.config.unicast.is_qos), #[cfg(feature = "transport_multilink")] diff --git a/io/zenoh-transport/src/unicast/establishment/open.rs b/io/zenoh-transport/src/unicast/establishment/open.rs index a9e797228e..468b2095d9 100644 --- a/io/zenoh-transport/src/unicast/establishment/open.rs +++ b/io/zenoh-transport/src/unicast/establishment/open.rs @@ -22,8 +22,7 @@ use zenoh_link::LinkUnicast; use zenoh_protocol::{ core::{Field, Resolution, WhatAmI, ZenohIdProto}, transport::{ - batch_size, close, BatchSize, Close, InitSyn, OpenSyn, TransportBody, TransportMessage, - TransportSn, + close, BatchSize, Close, InitSyn, OpenSyn, TransportBody, TransportMessage, TransportSn, }, }; use zenoh_result::ZResult; @@ -571,11 +570,7 @@ pub(crate) async fn open_link( let mut state = State { transport: StateTransport { - batch_size: manager - .config - .batch_size - .min(batch_size::UNICAST) - .min(link.config.batch.mtu), + batch_size: manager.config.batch_size.min(link.config.batch.mtu), resolution: manager.config.resolution, ext_qos: ext::qos::StateOpen::new(manager.config.unicast.is_qos), #[cfg(feature = "transport_multilink")] From c224401814309383b39e8ee521c08992b97e3d50 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Fri, 6 Sep 2024 08:29:12 +0000 Subject: [PATCH 2/6] Silence `clippy::unnecessary_min_or_max` --- .../src/unicast/establishment/accept.rs | 15 +++++++++++++-- .../src/unicast/establishment/open.rs | 12 ++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/io/zenoh-transport/src/unicast/establishment/accept.rs b/io/zenoh-transport/src/unicast/establishment/accept.rs index 01d38a47b8..995b07230e 100644 --- a/io/zenoh-transport/src/unicast/establishment/accept.rs +++ b/io/zenoh-transport/src/unicast/establishment/accept.rs @@ -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, }, @@ -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 @@ -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")] diff --git a/io/zenoh-transport/src/unicast/establishment/open.rs b/io/zenoh-transport/src/unicast/establishment/open.rs index 468b2095d9..88e139b23d 100644 --- a/io/zenoh-transport/src/unicast/establishment/open.rs +++ b/io/zenoh-transport/src/unicast/establishment/open.rs @@ -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; @@ -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")] From c51f62910464bcf41e356366df688a9fa8a92e9b Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Fri, 6 Sep 2024 11:39:17 +0200 Subject: [PATCH 3/6] Comment `#[allow(clippy::unnecessary_min_or_max)]` Co-authored-by: Luca Cominardi --- io/zenoh-transport/src/unicast/establishment/accept.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io/zenoh-transport/src/unicast/establishment/accept.rs b/io/zenoh-transport/src/unicast/establishment/accept.rs index 995b07230e..28cd6e757b 100644 --- a/io/zenoh-transport/src/unicast/establishment/accept.rs +++ b/io/zenoh-transport/src/unicast/establishment/accept.rs @@ -687,6 +687,8 @@ pub(crate) async fn accept_link(link: LinkUnicast, manager: &TransportManager) - }; } + // Clippy raises a warning because `batch_size::UNICAST` is currently equal to `BatchSize::MAX`. + // However, the current code catches the cases where `batch_size::UNICAST` is different from `BatchSize::MAX`. #[allow(clippy::unnecessary_min_or_max)] let batch_size = manager.config.batch_size.min(batch_size::UNICAST).min(mtu); From 165ec0d15ccad849cc038dd725d5b0de787e22a8 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Fri, 6 Sep 2024 11:39:25 +0200 Subject: [PATCH 4/6] Comment `#[allow(clippy::unnecessary_min_or_max)]` Co-authored-by: Luca Cominardi --- io/zenoh-transport/src/unicast/establishment/accept.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io/zenoh-transport/src/unicast/establishment/accept.rs b/io/zenoh-transport/src/unicast/establishment/accept.rs index 28cd6e757b..9d34896d95 100644 --- a/io/zenoh-transport/src/unicast/establishment/accept.rs +++ b/io/zenoh-transport/src/unicast/establishment/accept.rs @@ -211,6 +211,8 @@ impl<'a, 'b: 'a> AcceptFsm for &'a mut AcceptLink<'b> { }; // Compute the minimum batch size + // Clippy raises a warning because `batch_size::UNICAST` is currently equal to `BatchSize::MAX`. + // However, the current code catches the cases where `batch_size::UNICAST` is different from `BatchSize::MAX`. #[allow(clippy::unnecessary_min_or_max)] { state.transport.batch_size = state From cc6cc84bbf47ae31b913044cfe81b18ea0c24500 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Fri, 6 Sep 2024 11:39:35 +0200 Subject: [PATCH 5/6] Comment `#[allow(clippy::unnecessary_min_or_max)]` Co-authored-by: Luca Cominardi --- io/zenoh-transport/src/unicast/establishment/open.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io/zenoh-transport/src/unicast/establishment/open.rs b/io/zenoh-transport/src/unicast/establishment/open.rs index 88e139b23d..b8346d49a6 100644 --- a/io/zenoh-transport/src/unicast/establishment/open.rs +++ b/io/zenoh-transport/src/unicast/establishment/open.rs @@ -569,6 +569,8 @@ pub(crate) async fn open_link( ext_compression: ext::compression::CompressionFsm::new(), }; + // Clippy raises a warning because `batch_size::UNICAST` is currently equal to `BatchSize::MAX`. + // However, the current code catches the cases where `batch_size::UNICAST` is different from `BatchSize::MAX`. #[allow(clippy::unnecessary_min_or_max)] let batch_size = manager .config From f2f4fc9d5507051e4cb74885c992a793352fbf45 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Fri, 6 Sep 2024 09:10:33 +0000 Subject: [PATCH 6/6] Fix formatting --- io/zenoh-transport/src/unicast/establishment/open.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/zenoh-transport/src/unicast/establishment/open.rs b/io/zenoh-transport/src/unicast/establishment/open.rs index b8346d49a6..ff73e213c2 100644 --- a/io/zenoh-transport/src/unicast/establishment/open.rs +++ b/io/zenoh-transport/src/unicast/establishment/open.rs @@ -569,7 +569,7 @@ pub(crate) async fn open_link( ext_compression: ext::compression::CompressionFsm::new(), }; - // Clippy raises a warning because `batch_size::UNICAST` is currently equal to `BatchSize::MAX`. + // Clippy raises a warning because `batch_size::UNICAST` is currently equal to `BatchSize::MAX`. // However, the current code catches the cases where `batch_size::UNICAST` is different from `BatchSize::MAX`. #[allow(clippy::unnecessary_min_or_max)] let batch_size = manager