From fbc7d57134af1937ca21b51e140b40562522ebec Mon Sep 17 00:00:00 2001 From: James Waples Date: Tue, 19 Sep 2023 11:46:19 +0100 Subject: [PATCH] Fix a few clippy warnings --- src/command.rs | 4 ++-- src/dc.rs | 4 ++-- src/pdu_data.rs | 2 +- src/slave/eeprom.rs | 1 - src/slave/mod.rs | 6 +++--- src/slave/slave_client.rs | 12 ++++++------ 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/command.rs b/src/command.rs index f4cca45f..bdfd9217 100644 --- a/src/command.rs +++ b/src/command.rs @@ -126,7 +126,7 @@ impl Writes { .write_service(self, value.as_slice()) .await .and_then(|(data, working_counter)| { - let res = T::try_from_slice(&*data).map_err(|e| { + let res = T::try_from_slice(&data).map_err(|e| { fmt::error!( "PDU data decode: {:?}, T: {} data {:?}", e, @@ -220,7 +220,7 @@ impl Reads { .read_service(self, T::LEN) .await .and_then(|(data, working_counter)| { - let res = T::try_from_slice(&*data).map_err(|e| { + let res = T::try_from_slice(&data).map_err(|e| { fmt::error!( "PDU data decode: {:?}, T: {} data {:?}", e, diff --git a/src/dc.rs b/src/dc.rs index 05092068..401ddab2 100644 --- a/src/dc.rs +++ b/src/dc.rs @@ -19,7 +19,7 @@ async fn latch_dc_times(client: &Client<'_>, slaves: &mut [Slave]) -> Result<(), // Latch receive times into all ports of all slaves. Command::bwr(RegisterAddress::DcTimePort0.into()) - .send_receive(&client, 0u32) + .send_receive(client, 0u32) .await? .wkc(num_slaves_with_dc as u16, "Broadcast time")?; @@ -432,7 +432,7 @@ pub(crate) async fn run_dc_static_sync( dc_reference_slave.configured_address, RegisterAddress::DcSystemTime.into(), ) - .receive::(&client) + .receive::(client) .await?; } diff --git a/src/pdu_data.rs b/src/pdu_data.rs index c681ed47..4bbe2227 100644 --- a/src/pdu_data.rs +++ b/src/pdu_data.rs @@ -40,7 +40,7 @@ macro_rules! impl_pdudata { #[allow(trivial_casts)] core::slice::from_raw_parts( self as *const _ as *const u8, - core::mem::size_of::<$ty>(), + (<$ty>::BITS / 8) as usize, ) } diff --git a/src/slave/eeprom.rs b/src/slave/eeprom.rs index 4e2ce404..6280c929 100644 --- a/src/slave/eeprom.rs +++ b/src/slave/eeprom.rs @@ -53,7 +53,6 @@ impl<'a, S> SlaveRef<'a, S> { DefaultMailbox::parse(&buf) } - #[allow(unused)] pub(crate) async fn eeprom_general(&self) -> Result { let mut reader = EepromSectionReader::new(&self.client, CategoryType::General) .await? diff --git a/src/slave/mod.rs b/src/slave/mod.rs index 075f847a..5cc6476a 100644 --- a/src/slave/mod.rs +++ b/src/slave/mod.rs @@ -267,7 +267,7 @@ where // If flag is set, read entire mailbox to clear it if sm.status.mailbox_full { Command::fprd(self.state.configured_address, read_mailbox.address) - .receive_slice(&self.client.client, read_mailbox.len) + .receive_slice(self.client.client, read_mailbox.len) .await?; } } @@ -333,7 +333,7 @@ where // Read acknowledgement from slave OUT mailbox let response = Command::fprd(self.state.configured_address, read_mailbox.address) - .receive_slice(&self.client.client, read_mailbox.len) + .receive_slice(self.client.client, read_mailbox.len) .await? .wkc(1, "read OUT mailbox after write")?; @@ -359,7 +359,7 @@ where // Send data to slave IN mailbox Command::fpwr(self.state.configured_address, write_mailbox.address) .send_receive_slice_len( - &self.client.client, + self.client.client, fmt::unwrap!(request .pack() .map_err(crate::error::WrappedPackingError::from)) diff --git a/src/slave/slave_client.rs b/src/slave/slave_client.rs index 486e9b52..d1b86c1c 100644 --- a/src/slave/slave_client.rs +++ b/src/slave/slave_client.rs @@ -31,7 +31,7 @@ impl<'client> SlaveClient<'client> { T: PduRead, { Command::fprd(self.configured_address, register) - .receive(&self.client) + .receive(self.client) .await } @@ -46,7 +46,7 @@ impl<'client> SlaveClient<'client> { T: PduData, { Command::fpwr(self.configured_address, register) - .send_receive(&self.client, value) + .send_receive(self.client, value) .await } @@ -56,7 +56,7 @@ impl<'client> SlaveClient<'client> { T: PduRead, { Command::fprd(self.configured_address, register) - .receive(&self.client) + .receive(self.client) .await? .wkc(1, context) } @@ -69,7 +69,7 @@ impl<'client> SlaveClient<'client> { context: &'static str, ) -> Result, Error> { Command::fprd(self.configured_address, register) - .receive_slice(&self.client, len) + .receive_slice(self.client, len) .await? .wkc(1, context) } @@ -82,7 +82,7 @@ impl<'client> SlaveClient<'client> { context: &'static str, ) -> Result, Error> { Command::fpwr(self.configured_address, register) - .send_receive_slice(&self.client, value) + .send_receive_slice(self.client, value) .await? .wkc(1, context) } @@ -99,7 +99,7 @@ impl<'client> SlaveClient<'client> { T: PduData, { Command::fpwr(self.configured_address, register) - .send(&self.client, value) + .send(self.client, value) .await? .wkc(1, context) }