Skip to content

Commit 7e96628

Browse files
authored
Fix typos in error variants names, resolve clippy warnings (#782)
* Fix typos in error variant names * Resolve clippy errors * Update `CHANGELOG.md`
1 parent b5b2e04 commit 7e96628

File tree

8 files changed

+24
-23
lines changed

8 files changed

+24
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Update the app image SHA in the correct location for padded images (#715)
2727
- Fix `-s` argument collision (#731)
2828
- `address` and `size` in `erase-region` have to be multiples of 4096 (#771)
29+
- Fixed typos in error variant names (#782)
2930

3031
### Removed
3132

espflash/src/error.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ pub enum Error {
4040
)]
4141
ChipDetectError(u32),
4242

43-
#[error("Chip provided ({0}) with `-c/--chip` does not match the detected chip ({1})")]
43+
#[error("Chip provided with `-c/--chip` ({0}) does not match the detected chip ({1})")]
4444
#[diagnostic(
45-
code(espflash::chip_missmatch),
45+
code(espflash::chip_mismatch),
4646
help("Ensure that the correct chip is selected, or remove the `-c/--chip` option to autodetect the chip")
4747
)]
4848
ChipMismatch(String, String),
@@ -59,8 +59,8 @@ pub enum Error {
5959
CorruptData(usize, usize),
6060

6161
#[error("MD5 digest missmatch: expected {0:2x?}, received: {1:2x?}")]
62-
#[diagnostic(code(espflash::read_flash::digest_missmatch))]
63-
DigestMissmatch(Vec<u8>, Vec<u8>),
62+
#[diagnostic(code(espflash::read_flash::digest_mismatch))]
63+
DigestMismatch(Vec<u8>, Vec<u8>),
6464

6565
#[error("Supplied ELF image can not be run from RAM, as it includes segments mapped to ROM addresses")]
6666
#[diagnostic(
@@ -89,7 +89,7 @@ pub enum Error {
8989

9090
#[error("Incorrect response from the sutb/ROM loader")]
9191
#[diagnostic(code(espflash::read_flash::incorrect_response))]
92-
IncorrectReposnse,
92+
IncorrectResponse,
9393

9494
#[error("The provided bootloader binary is invalid")]
9595
InvalidBootloader,

espflash/src/flasher/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl Flasher {
906906
self.connection
907907
.write_reg(spi_registers.usr(), flags, None)?;
908908
self.connection
909-
.write_reg(spi_registers.usr2(), 7 << 28 | command as u32, None)?;
909+
.write_reg(spi_registers.usr2(), (7 << 28) | command as u32, None)?;
910910

911911
if let (Some(mosi_data_length), Some(miso_data_length)) =
912912
(spi_registers.mosi_length(), spi_registers.miso_length())
@@ -928,7 +928,7 @@ impl Flasher {
928928
let miso_mask = if read_bits == 0 { 0 } else { read_bits - 1 };
929929
self.connection.write_reg(
930930
spi_registers.usr1(),
931-
miso_mask << 8 | mosi_mask << 17,
931+
(miso_mask << 8) | (mosi_mask << 17),
932932
None,
933933
)?;
934934
}
@@ -1250,7 +1250,7 @@ impl Flasher {
12501250
let chunk: Vec<u8> = if let Some(response) = response {
12511251
response.value.try_into().unwrap()
12521252
} else {
1253-
return Err(Error::IncorrectReposnse);
1253+
return Err(Error::IncorrectResponse);
12541254
};
12551255

12561256
data.extend_from_slice(&chunk);
@@ -1270,7 +1270,7 @@ impl Flasher {
12701270
let digest: Vec<u8> = if let Some(response) = response {
12711271
response.value.try_into().unwrap()
12721272
} else {
1273-
return Err(Error::IncorrectReposnse);
1273+
return Err(Error::IncorrectResponse);
12741274
};
12751275

12761276
if digest.len() != 16 {
@@ -1282,7 +1282,7 @@ impl Flasher {
12821282
let checksum_md5 = md5_hasher.finalize();
12831283

12841284
if digest != checksum_md5.as_slice() {
1285-
return Err(Error::DigestMissmatch(
1285+
return Err(Error::DigestMismatch(
12861286
digest,
12871287
checksum_md5.as_slice().to_vec(),
12881288
));

espflash/src/targets/esp32c2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ impl Target for Esp32c2 {
5959

6060
#[cfg(feature = "serialport")]
6161
fn major_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
62-
Ok(self.read_efuse(connection, 17)? >> 20 & 0x3)
62+
Ok((self.read_efuse(connection, 17)? >> 20) & 0x3)
6363
}
6464

6565
#[cfg(feature = "serialport")]
6666
fn minor_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
67-
Ok(self.read_efuse(connection, 17)? >> 16 & 0xf)
67+
Ok((self.read_efuse(connection, 17)? >> 16) & 0xf)
6868
}
6969

7070
#[cfg(feature = "serialport")]

espflash/src/targets/esp32c3.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ impl Target for Esp32c3 {
5959

6060
#[cfg(feature = "serialport")]
6161
fn major_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
62-
Ok(self.read_efuse(connection, 22)? >> 24 & 0x3)
62+
Ok((self.read_efuse(connection, 22)? >> 24) & 0x3)
6363
}
6464

6565
#[cfg(feature = "serialport")]
6666
fn minor_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
67-
let hi = self.read_efuse(connection, 22)? >> 23 & 0x1;
68-
let lo = self.read_efuse(connection, 20)? >> 18 & 0x7;
67+
let hi = (self.read_efuse(connection, 22)? >> 23) & 0x1;
68+
let lo = (self.read_efuse(connection, 20)? >> 18) & 0x7;
6969

7070
Ok((hi << 3) + lo)
7171
}

espflash/src/targets/esp32p4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Target for Esp32p4 {
5353

5454
#[cfg(feature = "serialport")]
5555
fn major_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
56-
Ok(self.read_efuse(connection, 19)? >> 4 & 0x03)
56+
Ok((self.read_efuse(connection, 19)? >> 4) & 0x03)
5757
}
5858

5959
#[cfg(feature = "serialport")]

espflash/src/targets/esp32s2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ impl Target for Esp32s2 {
119119

120120
#[cfg(feature = "serialport")]
121121
fn major_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
122-
Ok(self.read_efuse(connection, 20)? >> 18 & 0x3)
122+
Ok((self.read_efuse(connection, 20)? >> 18) & 0x3)
123123
}
124124

125125
#[cfg(feature = "serialport")]
126126
fn minor_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
127-
let hi = self.read_efuse(connection, 20)? >> 20 & 0x1;
128-
let lo = self.read_efuse(connection, 21)? >> 4 & 0x7;
127+
let hi = (self.read_efuse(connection, 20)? >> 20) & 0x1;
128+
let lo = (self.read_efuse(connection, 21)? >> 4) & 0x7;
129129

130130
Ok((hi << 3) + lo)
131131
}

espflash/src/targets/esp32s3.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Esp32s3 {
3939
#[cfg(feature = "serialport")]
4040
/// Return the minor BLK version based on eFuses
4141
fn blk_version_minor(&self, connection: &mut Connection) -> Result<u32, Error> {
42-
Ok(self.read_efuse(connection, 20)? >> 24 & 0x7)
42+
Ok((self.read_efuse(connection, 20)? >> 24) & 0x7)
4343
}
4444

4545
/// Check if the magic value contains the specified value
@@ -66,7 +66,7 @@ impl Target for Esp32s3 {
6666

6767
#[cfg(feature = "serialport")]
6868
fn major_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
69-
let major = self.read_efuse(connection, 22)? >> 24 & 0x3;
69+
let major = (self.read_efuse(connection, 22)? >> 24) & 0x3;
7070

7171
// Workaround: The major version field was allocated to other purposes when
7272
// block version is v1.1. Luckily only chip v0.0 have this kind of block version
@@ -83,8 +83,8 @@ impl Target for Esp32s3 {
8383

8484
#[cfg(feature = "serialport")]
8585
fn minor_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
86-
let hi = self.read_efuse(connection, 22)? >> 23 & 0x1;
87-
let lo = self.read_efuse(connection, 20)? >> 18 & 0x7;
86+
let hi = (self.read_efuse(connection, 22)? >> 23) & 0x1;
87+
let lo = (self.read_efuse(connection, 20)? >> 18) & 0x7;
8888

8989
Ok((hi << 3) + lo)
9090
}

0 commit comments

Comments
 (0)