From 4e3221e6e2d0d06163640254e5c806b6ae6d1826 Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Tue, 27 Jul 2021 11:57:30 +0300 Subject: [PATCH] clippy --- examples/blinky-timer-irq.rs | 6 +++--- examples/delay-syst-blinky.rs | 2 +- examples/delay-timer-blinky.rs | 2 +- examples/qei.rs | 1 - examples/ssd1306-image.rs | 5 +++-- .../stopwatch-with-ssd1306-and-interrupts.rs | 16 ++++++++-------- src/spi.rs | 3 ++- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/examples/blinky-timer-irq.rs b/examples/blinky-timer-irq.rs index 7cbfa12bd..9f6c6731d 100644 --- a/examples/blinky-timer-irq.rs +++ b/examples/blinky-timer-irq.rs @@ -30,10 +30,10 @@ use embedded_hal::timer::CountDown; // A type definition for the GPIO pin to be used for our LED // For the onboard nucleo LED, use gpioa::PA5 or gpiob::PB13 depending your model -type LEDPIN = gpioa::PA5>; +type LedPin = gpioa::PA5>; // Make LED pin globally available -static G_LED: Mutex>> = Mutex::new(RefCell::new(None)); +static G_LED: Mutex>> = Mutex::new(RefCell::new(None)); // Make timer interrupt registers globally available static G_TIM: Mutex>>> = Mutex::new(RefCell::new(None)); @@ -42,7 +42,7 @@ static G_TIM: Mutex>>> = Mutex::new(RefCell: // This specific interrupt will "trip" when the timer TIM2 times out #[interrupt] fn TIM2() { - static mut LED: Option = None; + static mut LED: Option = None; static mut TIM: Option> = None; let led = LED.get_or_insert_with(|| { diff --git a/examples/delay-syst-blinky.rs b/examples/delay-syst-blinky.rs index d86ba07e2..dd3200325 100644 --- a/examples/delay-syst-blinky.rs +++ b/examples/delay-syst-blinky.rs @@ -1,13 +1,13 @@ //! Demonstrate the use of a blocking `Delay` using the SYST (sysclock) timer. #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] // Halt on panic use panic_halt as _; // panic handler -use cortex_m; use cortex_m_rt::entry; use stm32f4xx_hal as hal; diff --git a/examples/delay-timer-blinky.rs b/examples/delay-timer-blinky.rs index 6d210cca1..001681b9c 100644 --- a/examples/delay-timer-blinky.rs +++ b/examples/delay-timer-blinky.rs @@ -1,13 +1,13 @@ //! Demonstrate the use of a blocking `Delay` using TIM5 general-purpose timer. #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] // Halt on panic use panic_halt as _; // panic handler -use cortex_m; use cortex_m_rt::entry; use stm32f4xx_hal as hal; diff --git a/examples/qei.rs b/examples/qei.rs index 3ebbc3bf1..055965e78 100644 --- a/examples/qei.rs +++ b/examples/qei.rs @@ -12,7 +12,6 @@ // Halt on panic use panic_halt as _; -use cortex_m; use cortex_m_rt::entry; use embedded_hal::Direction as RotaryDirection; use stm32f4xx_hal::{delay::Delay, pac, prelude::*, qei::Qei}; diff --git a/examples/ssd1306-image.rs b/examples/ssd1306-image.rs index df3c1684e..212ca1032 100644 --- a/examples/ssd1306-image.rs +++ b/examples/ssd1306-image.rs @@ -9,6 +9,7 @@ //! //! Note that `--release` is required to fix link errors for smaller devices. +#![allow(clippy::empty_loop)] #![no_std] #![no_main] @@ -87,7 +88,7 @@ fn main() -> ! { /// Helper function - what rotation flips the screen upside down from /// the rotation we're in now? fn get_next_rotation(rotation: DisplayRotation) -> DisplayRotation { - return match rotation { + match rotation { DisplayRotation::Rotate0 => DisplayRotation::Rotate180, DisplayRotation::Rotate180 => DisplayRotation::Rotate0, @@ -95,7 +96,7 @@ fn get_next_rotation(rotation: DisplayRotation) -> DisplayRotation { // reset to 0 degrees landscape. On most SSD1306 displays, this means down is towards // the flat flex coming out of the display (and up is towards the breakout board pins). _ => DisplayRotation::Rotate0, - }; + } } #[exception] diff --git a/examples/stopwatch-with-ssd1306-and-interrupts.rs b/examples/stopwatch-with-ssd1306-and-interrupts.rs index 12c273c46..1a858e75e 100644 --- a/examples/stopwatch-with-ssd1306-and-interrupts.rs +++ b/examples/stopwatch-with-ssd1306-and-interrupts.rs @@ -14,6 +14,7 @@ //! //! Video of this example running: https://imgur.com/a/lQTQFLy +#![allow(clippy::empty_loop)] #![no_std] #![no_main] @@ -188,23 +189,22 @@ fn EXTI15_10() { } fn setup_clocks(rcc: Rcc) -> Clocks { - return rcc - .cfgr + rcc.cfgr .hclk(48.mhz()) .sysclk(48.mhz()) .pclk1(24.mhz()) .pclk2(24.mhz()) - .freeze(); + .freeze() } -fn stopwatch_start<'cs>(cs: &'cs CriticalSection) { +fn stopwatch_start(cs: &CriticalSection) { ELAPSED_MS.borrow(cs).replace(0); unsafe { pac::NVIC::unmask(hal::pac::Interrupt::TIM2); } } -fn stopwatch_stop<'cs>(_cs: &'cs CriticalSection) { +fn stopwatch_stop(_cs: &CriticalSection) { pac::NVIC::mask(hal::pac::Interrupt::TIM2); } @@ -221,13 +221,13 @@ fn format_elapsed(buf: &mut ArrayString<[u8; 10]>, elapsed: u32) { } fn elapsed_to_ms(elapsed: u32) -> u32 { - return elapsed % 1000; + elapsed % 1000 } fn elapsed_to_s(elapsed: u32) -> u32 { - return (elapsed - elapsed_to_ms(elapsed)) % 60000 / 1000; + (elapsed - elapsed_to_ms(elapsed)) % 60000 / 1000 } fn elapsed_to_m(elapsed: u32) -> u32 { - return elapsed / 60000; + elapsed / 60000 } diff --git a/src/spi.rs b/src/spi.rs index 750d89082..f03a1f67b 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -681,7 +681,8 @@ where }); Error::Crc.into() } else if sr.txe().bit_is_set() { - return Ok(self.send_u8(byte)); + self.send_u8(byte); + return Ok(()); } else { nb::Error::WouldBlock })