Skip to content

Commit

Permalink
Make clippy happy (#710)
Browse files Browse the repository at this point in the history
* Make clippy happy

* Update to macos-13 to fix the crashing CI job

* Update CHANGELOG.md

Co-authored-by: Sergio Gasquez Arcos <[email protected]>

---------

Co-authored-by: Sergio Gasquez Arcos <[email protected]>
  • Loading branch information
ivmarkov and SergioGasquez authored Dec 19, 2024
1 parent 4f8a526 commit 523eedc
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion espflash/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion espflash/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ mod encoder {
}
}

impl<'a, W: Write> Write for SlipEncoder<'a, W> {
impl<W: Write> 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
Expand Down
4 changes: 2 additions & 2 deletions espflash/src/connection/reset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions espflash/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ 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);
self.data = Cow::Owned(data);
}
}

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
Expand Down
3 changes: 2 additions & 1 deletion espflash/src/flasher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions espflash/src/image_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions espflash/src/targets/flash_target/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion espflash/src/targets/flash_target/ram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 523eedc

Please sign in to comment.