Skip to content

Commit 523eedc

Browse files
ivmarkovSergioGasquez
andauthoredDec 19, 2024
Make clippy happy (#710)
* 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]>
1 parent 4f8a526 commit 523eedc

File tree

11 files changed

+16
-13
lines changed

11 files changed

+16
-13
lines changed
 

‎.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
fail-fast: false
2828
matrix:
2929
platform:
30-
- os: "macos-12"
30+
- os: "macos-13"
3131
target: "x86_64-apple-darwin"
3232
arch: "x86_64"
3333
- os: "ubuntu-22.04"

‎.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ jobs:
3232
target: "x86_64-pc-windows-msvc"
3333
arch: "x86_64"
3434
# macOs
35-
- os: "macos-12"
35+
- os: "macos-13"
3636
target: "aarch64-apple-darwin"
3737
# This is not true, but simplifies the logic of the action.
3838
arch: "x86_64"
39-
- os: "macos-12"
39+
- os: "macos-13"
4040
target: "x86_64-apple-darwin"
4141
arch: "x86_64"
4242
runs-on: ${{ matrix.platform.os }}

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Allow `partition_table_offset` to be specified in the config file. (for #699)
1313
- Support external log-processors (#705)
14+
- Address Clippy lints (#710)
1415

1516
### Changed
1617

‎espflash/src/command.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub enum Command<'a> {
192192
FlashDetect,
193193
}
194194

195-
impl<'a> Command<'a> {
195+
impl Command<'_> {
196196
/// Return the command type
197197
pub fn command_type(&self) -> CommandType {
198198
match self {

‎espflash/src/connection/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ mod encoder {
515515
}
516516
}
517517

518-
impl<'a, W: Write> Write for SlipEncoder<'a, W> {
518+
impl<W: Write> Write for SlipEncoder<'_, W> {
519519
/// Writes the given buffer replacing the END and ESC bytes
520520
///
521521
/// See https://docs.espressif.com/projects/esptool/en/latest/esp32c3/advanced-topics/serial-protocol.html#low-level-protocol

‎espflash/src/connection/reset.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub fn soft_reset(
253253
connection.with_timeout(CommandType::FlashBegin.timeout(), |connection| {
254254
let size: u32 = 0;
255255
let offset: u32 = 0;
256-
let blocks: u32 = (size + FLASH_WRITE_SIZE as u32 - 1) / FLASH_WRITE_SIZE as u32;
256+
let blocks: u32 = size.div_ceil(FLASH_WRITE_SIZE as u32);
257257
connection.command(Command::FlashBegin {
258258
size,
259259
blocks,
@@ -271,7 +271,7 @@ pub fn soft_reset(
271271
connection.with_timeout(CommandType::FlashBegin.timeout(), |connection| {
272272
let size: u32 = 0;
273273
let offset: u32 = 0;
274-
let blocks: u32 = (size + FLASH_WRITE_SIZE as u32 - 1) / FLASH_WRITE_SIZE as u32;
274+
let blocks: u32 = size.div_ceil(FLASH_WRITE_SIZE as u32);
275275
connection.command(Command::FlashBegin {
276276
size,
277277
blocks,

‎espflash/src/elf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ impl<'a> CodeSegment<'a> {
184184
}
185185
}
186186

187-
impl<'a> AddAssign<&'_ [u8]> for CodeSegment<'a> {
187+
impl AddAssign<&'_ [u8]> for CodeSegment<'_> {
188188
fn add_assign(&mut self, rhs: &'_ [u8]) {
189189
let mut data = take(&mut self.data).into_owned();
190190
data.extend_from_slice(rhs);
191191
self.data = Cow::Owned(data);
192192
}
193193
}
194194

195-
impl<'a> AddAssign<&'_ CodeSegment<'_>> for CodeSegment<'a> {
195+
impl AddAssign<&'_ CodeSegment<'_>> for CodeSegment<'_> {
196196
fn add_assign(&mut self, rhs: &'_ CodeSegment<'_>) {
197197
let mut data = take(&mut self.data).into_owned();
198198
// pad or truncate

‎espflash/src/flasher/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ pub struct FlashDataBuilder<'a> {
302302
min_chip_rev: u16,
303303
}
304304

305-
impl<'a> Default for FlashDataBuilder<'a> {
305+
impl Default for FlashDataBuilder<'_> {
306306
fn default() -> Self {
307307
Self {
308308
bootloader_path: Default::default(),
@@ -567,6 +567,7 @@ pub struct Flasher {
567567

568568
#[cfg(feature = "serialport")]
569569
impl Flasher {
570+
#[allow(clippy::too_many_arguments)]
570571
pub fn connect(
571572
serial: Port,
572573
port_info: UsbPortInfo,

‎espflash/src/image_format.rs

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub struct IdfBootloaderFormat<'a> {
113113
}
114114

115115
impl<'a> IdfBootloaderFormat<'a> {
116+
#[allow(clippy::too_many_arguments)]
116117
pub fn new(
117118
image: &'a dyn FirmwareImage<'a>,
118119
chip: Chip,

‎espflash/src/targets/flash_target/esp32.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ impl FlashTarget for Esp32Target {
170170

171171
let target = self.chip.into_target();
172172
let flash_write_size = target.flash_write_size(connection)?;
173-
let block_count = (compressed.len() + flash_write_size - 1) / flash_write_size;
174-
let erase_count = (segment.data.len() + FLASH_SECTOR_SIZE - 1) / FLASH_SECTOR_SIZE;
173+
let block_count = compressed.len().div_ceil(flash_write_size);
174+
let erase_count = segment.data.len().div_ceil(FLASH_SECTOR_SIZE);
175175

176176
// round up to sector size
177177
let erase_size = (erase_count * FLASH_SECTOR_SIZE) as u32;

‎espflash/src/targets/flash_target/ram.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl FlashTarget for RamTarget {
4242
let addr = segment.addr;
4343

4444
let padding = 4 - segment.data.len() % 4;
45-
let block_count = (segment.data.len() + padding + self.block_size - 1) / self.block_size;
45+
let block_count = (segment.data.len() + padding).div_ceil(self.block_size);
4646

4747
connection.command(Command::MemBegin {
4848
size: segment.data.len() as u32,

0 commit comments

Comments
 (0)