diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a414deb..b8714829 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: platform: - - os: "macos-12" + - os: "macos-13" target: "x86_64-apple-darwin" arch: "x86_64" - os: "ubuntu-22.04" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dffd72b1..c6d73bb7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,11 +32,11 @@ jobs: target: "x86_64-pc-windows-msvc" arch: "x86_64" # macOs - - os: "macos-12" + - os: "macos-13" target: "aarch64-apple-darwin" # This is not true, but simplifies the logic of the action. arch: "x86_64" - - os: "macos-12" + - os: "macos-13" target: "x86_64-apple-darwin" arch: "x86_64" runs-on: ${{ matrix.platform.os }} diff --git a/CHANGELOG.md b/CHANGELOG.md index fd0a1b93..d15d9421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Allow `partition_table_offset` to be specified in the config file. (for #699) - Support external log-processors (#705) +- Address Clippy lints (#710) ### Changed diff --git a/espflash/src/command.rs b/espflash/src/command.rs index 4d38f9a9..be91e504 100644 --- a/espflash/src/command.rs +++ b/espflash/src/command.rs @@ -192,7 +192,7 @@ pub enum Command<'a> { FlashDetect, } -impl<'a> Command<'a> { +impl Command<'_> { /// Return the command type pub fn command_type(&self) -> CommandType { match self { diff --git a/espflash/src/connection/mod.rs b/espflash/src/connection/mod.rs index a8dc4a3a..23d27230 100644 --- a/espflash/src/connection/mod.rs +++ b/espflash/src/connection/mod.rs @@ -515,7 +515,7 @@ mod encoder { } } - impl<'a, W: Write> Write for SlipEncoder<'a, W> { + impl Write for SlipEncoder<'_, W> { /// Writes the given buffer replacing the END and ESC bytes /// /// See https://docs.espressif.com/projects/esptool/en/latest/esp32c3/advanced-topics/serial-protocol.html#low-level-protocol diff --git a/espflash/src/connection/reset.rs b/espflash/src/connection/reset.rs index c2868d7c..936f232a 100644 --- a/espflash/src/connection/reset.rs +++ b/espflash/src/connection/reset.rs @@ -253,7 +253,7 @@ pub fn soft_reset( connection.with_timeout(CommandType::FlashBegin.timeout(), |connection| { let size: u32 = 0; let offset: u32 = 0; - let blocks: u32 = (size + FLASH_WRITE_SIZE as u32 - 1) / FLASH_WRITE_SIZE as u32; + let blocks: u32 = size.div_ceil(FLASH_WRITE_SIZE as u32); connection.command(Command::FlashBegin { size, blocks, @@ -271,7 +271,7 @@ pub fn soft_reset( connection.with_timeout(CommandType::FlashBegin.timeout(), |connection| { let size: u32 = 0; let offset: u32 = 0; - let blocks: u32 = (size + FLASH_WRITE_SIZE as u32 - 1) / FLASH_WRITE_SIZE as u32; + let blocks: u32 = size.div_ceil(FLASH_WRITE_SIZE as u32); connection.command(Command::FlashBegin { size, blocks, diff --git a/espflash/src/elf.rs b/espflash/src/elf.rs index 7554d1bb..3f0f3e34 100644 --- a/espflash/src/elf.rs +++ b/espflash/src/elf.rs @@ -184,7 +184,7 @@ impl<'a> CodeSegment<'a> { } } -impl<'a> AddAssign<&'_ [u8]> for CodeSegment<'a> { +impl AddAssign<&'_ [u8]> for CodeSegment<'_> { fn add_assign(&mut self, rhs: &'_ [u8]) { let mut data = take(&mut self.data).into_owned(); data.extend_from_slice(rhs); @@ -192,7 +192,7 @@ impl<'a> AddAssign<&'_ [u8]> for CodeSegment<'a> { } } -impl<'a> AddAssign<&'_ CodeSegment<'_>> for CodeSegment<'a> { +impl AddAssign<&'_ CodeSegment<'_>> for CodeSegment<'_> { fn add_assign(&mut self, rhs: &'_ CodeSegment<'_>) { let mut data = take(&mut self.data).into_owned(); // pad or truncate diff --git a/espflash/src/flasher/mod.rs b/espflash/src/flasher/mod.rs index ac2d396c..d57fdf55 100644 --- a/espflash/src/flasher/mod.rs +++ b/espflash/src/flasher/mod.rs @@ -302,7 +302,7 @@ pub struct FlashDataBuilder<'a> { min_chip_rev: u16, } -impl<'a> Default for FlashDataBuilder<'a> { +impl Default for FlashDataBuilder<'_> { fn default() -> Self { Self { bootloader_path: Default::default(), @@ -567,6 +567,7 @@ pub struct Flasher { #[cfg(feature = "serialport")] impl Flasher { + #[allow(clippy::too_many_arguments)] pub fn connect( serial: Port, port_info: UsbPortInfo, diff --git a/espflash/src/image_format.rs b/espflash/src/image_format.rs index 0b357906..2af83ece 100644 --- a/espflash/src/image_format.rs +++ b/espflash/src/image_format.rs @@ -113,6 +113,7 @@ pub struct IdfBootloaderFormat<'a> { } impl<'a> IdfBootloaderFormat<'a> { + #[allow(clippy::too_many_arguments)] pub fn new( image: &'a dyn FirmwareImage<'a>, chip: Chip, diff --git a/espflash/src/targets/flash_target/esp32.rs b/espflash/src/targets/flash_target/esp32.rs index d738d3d2..e6088d47 100644 --- a/espflash/src/targets/flash_target/esp32.rs +++ b/espflash/src/targets/flash_target/esp32.rs @@ -170,8 +170,8 @@ impl FlashTarget for Esp32Target { let target = self.chip.into_target(); let flash_write_size = target.flash_write_size(connection)?; - let block_count = (compressed.len() + flash_write_size - 1) / flash_write_size; - let erase_count = (segment.data.len() + FLASH_SECTOR_SIZE - 1) / FLASH_SECTOR_SIZE; + let block_count = compressed.len().div_ceil(flash_write_size); + let erase_count = segment.data.len().div_ceil(FLASH_SECTOR_SIZE); // round up to sector size let erase_size = (erase_count * FLASH_SECTOR_SIZE) as u32; diff --git a/espflash/src/targets/flash_target/ram.rs b/espflash/src/targets/flash_target/ram.rs index 74cd2711..362693cf 100644 --- a/espflash/src/targets/flash_target/ram.rs +++ b/espflash/src/targets/flash_target/ram.rs @@ -42,7 +42,7 @@ impl FlashTarget for RamTarget { let addr = segment.addr; let padding = 4 - segment.data.len() % 4; - let block_count = (segment.data.len() + padding + self.block_size - 1) / self.block_size; + let block_count = (segment.data.len() + padding).div_ceil(self.block_size); connection.command(Command::MemBegin { size: segment.data.len() as u32,