From 87fd7d56c420674f4368ac8d67f9798f7f7ac6f8 Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Thu, 15 Dec 2022 21:53:37 +0300 Subject: [PATCH] clippy 1.66 --- CHANGELOG.md | 2 +- examples/usb-serial-irq.rs | 1 + src/dma/mod.rs | 36 +++++++++++++++++------------------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64fe6085..2ac4b3fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - - Update readme + - Update readme, clippy fixes ## [v0.14.0] - 2022-12-12 diff --git a/examples/usb-serial-irq.rs b/examples/usb-serial-irq.rs index 187a993a..0d168b4d 100644 --- a/examples/usb-serial-irq.rs +++ b/examples/usb-serial-irq.rs @@ -65,6 +65,7 @@ fn main() -> ! { cortex_m::peripheral::NVIC::unmask(Interrupt::OTG_FS); } + #[allow(clippy::empty_loop)] loop { // Do nothing. Everything is done in the IRQ handler } diff --git a/src/dma/mod.rs b/src/dma/mod.rs index 3813c093..6563c2dc 100644 --- a/src/dma/mod.rs +++ b/src/dma/mod.rs @@ -1413,7 +1413,7 @@ where let (buf_ptr, buf_len) = buf; // Set the memory address - stream.set_memory_address(buf_ptr as u32); + stream.set_memory_address(buf_ptr); let is_mem2mem = DIR::direction() == DmaDirection::MemoryToMemory; if is_mem2mem { @@ -1431,9 +1431,9 @@ where let db_len = if let Some((db_ptr, db_len)) = db { if is_mem2mem { // Double buffer is the source in mem2mem mode - stream.set_peripheral_address(db_ptr as u32); + stream.set_peripheral_address(db_ptr); } else { - stream.set_memory_double_buffer_address(db_ptr as u32); + stream.set_memory_double_buffer_address(db_ptr); } Some(db_len) } else { @@ -1445,9 +1445,9 @@ where }; let n_transfers = if let Some(db) = db_len { - buf_len.min(db) as u16 + buf_len.min(db) } else { - buf_len as u16 + buf_len }; stream.set_number_of_transfers(n_transfers); @@ -1477,10 +1477,10 @@ where if STREAM::current_buffer() == CurrentBuffer::DoubleBuffer { // "Preceding reads and writes cannot be moved past subsequent writes" compiler_fence(Ordering::Release); - self.stream.set_memory_address(new_buf_ptr as u32); + self.stream.set_memory_address(new_buf_ptr); // Check if an overrun occurred, the buffer address won't be updated in that case - if self.stream.get_memory_address() != new_buf_ptr as u32 { + if self.stream.get_memory_address() != new_buf_ptr { self.stream.clear_transfer_complete_interrupt(); return Err(DMAError::Overrun(new_buf)); } @@ -1495,11 +1495,10 @@ where } else { // "Preceding reads and writes cannot be moved past subsequent writes" compiler_fence(Ordering::Release); - self.stream - .set_memory_double_buffer_address(new_buf_ptr as u32); + self.stream.set_memory_double_buffer_address(new_buf_ptr); // Check if an overrun occurred, the buffer address won't be updated in that case - if self.stream.get_memory_double_buffer_address() != new_buf_ptr as u32 { + if self.stream.get_memory_double_buffer_address() != new_buf_ptr { self.stream.clear_transfer_complete_interrupt(); return Err(DMAError::Overrun(new_buf)); } @@ -1520,8 +1519,8 @@ where compiler_fence(Ordering::SeqCst); let (buf_ptr, buf_len) = ptr_and_len; - self.stream.set_memory_address(buf_ptr as u32); - self.stream.set_number_of_transfers(buf_len as u16); + self.stream.set_memory_address(buf_ptr); + self.stream.set_number_of_transfers(buf_len); let old_buf = self.buf.replace(new_buf); unsafe { @@ -1566,11 +1565,11 @@ where if current_buffer == CurrentBuffer::DoubleBuffer { // "Preceding reads and writes cannot be moved past subsequent writes" compiler_fence(Ordering::Release); - self.stream.set_memory_address(new_buf_ptr as u32); + self.stream.set_memory_address(new_buf_ptr); // Check again if an overrun occurred, the buffer address won't be updated in that // case - if self.stream.get_memory_address() != new_buf_ptr as u32 { + if self.stream.get_memory_address() != new_buf_ptr { panic!("Overrun"); } @@ -1581,10 +1580,9 @@ where } else { // "Preceding reads and writes cannot be moved past subsequent writes" compiler_fence(Ordering::Release); - self.stream - .set_memory_double_buffer_address(new_buf_ptr as u32); + self.stream.set_memory_double_buffer_address(new_buf_ptr); - if self.stream.get_memory_double_buffer_address() != new_buf_ptr as u32 { + if self.stream.get_memory_double_buffer_address() != new_buf_ptr { panic!("Overrun"); } @@ -1596,8 +1594,8 @@ where return; } let (buf_ptr, buf_len) = ptr_and_len; - self.stream.set_memory_address(buf_ptr as u32); - self.stream.set_number_of_transfers(buf_len as u16); + self.stream.set_memory_address(buf_ptr); + self.stream.set_number_of_transfers(buf_len); self.buf.replace(new_buf); self.stream.enable();