Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make clippy happy #710

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
ivmarkov marked this conversation as resolved.
Show resolved Hide resolved

### 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
Loading