Skip to content

Commit f68de5d

Browse files
committed
fix: clippy errors
Signed-off-by: addrian-77 <lunguadrian30@gmail.com>
1 parent 6e0fcb9 commit f68de5d

5 files changed

Lines changed: 19 additions & 35 deletions

File tree

tockloader-cli/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ use tockloader_lib::connection::{
1818
use tockloader_lib::known_boards::KnownBoard;
1919
use tockloader_lib::tabs::tab::Tab;
2020
use tockloader_lib::{
21-
list_debug_probes, list_serial_ports, CommandInfo, CommandInstall, CommandList, CommandEraseApps,
21+
list_debug_probes, list_serial_ports, CommandEraseApps, CommandInfo, CommandInstall,
22+
CommandList,
2223
};
2324

2425
fn get_serial_target_info(user_options: &ArgMatches) -> SerialTargetInfo {
@@ -235,7 +236,7 @@ async fn main() -> Result<()> {
235236

236237
conn.erase_apps(&settings)
237238
.await
238-
.context("Failed to erase apps.")?;
239+
.context("Failed to erase apps.")?;
239240
}
240241
_ => {
241242
println!("Could not run the provided subcommand.");

tockloader-lib/src/command_impl/generalized.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::board_settings::BoardSettings;
66
use crate::connection::TockloaderConnection;
77
use crate::errors::TockloaderError;
88
use crate::tabs::tab::Tab;
9-
use crate::{CommandInfo, CommandInstall, CommandList, CommandEraseApps};
9+
use crate::{CommandEraseApps, CommandInfo, CommandInstall, CommandList};
1010

1111
#[async_trait]
1212
impl CommandList for TockloaderConnection {
@@ -50,13 +50,10 @@ impl CommandInstall for TockloaderConnection {
5050

5151
#[async_trait]
5252
impl CommandEraseApps for TockloaderConnection {
53-
async fn erase_apps(
54-
&mut self,
55-
settings: &BoardSettings,
56-
) -> Result<(), TockloaderError> {
53+
async fn erase_apps(&mut self, settings: &BoardSettings) -> Result<(), TockloaderError> {
5754
match self {
5855
TockloaderConnection::ProbeRS(conn) => conn.erase_apps(settings).await,
5956
TockloaderConnection::Serial(_conn) => todo!(),
6057
}
6158
}
62-
}
59+
}
Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use async_trait::async_trait;
22
use probe_rs::flashing::DownloadOptions;
3-
use probe_rs::{MemoryInterface};
4-
use tbf_parser::parse::{parse_tbf_header_lengths};
3+
use probe_rs::MemoryInterface;
4+
use tbf_parser::parse::parse_tbf_header_lengths;
55

66
use crate::board_settings::BoardSettings;
77
use crate::connection::{Connection, ProbeRSConnection};
@@ -10,10 +10,7 @@ use crate::CommandEraseApps;
1010

1111
#[async_trait]
1212
impl CommandEraseApps for ProbeRSConnection {
13-
async fn erase_apps(
14-
&mut self,
15-
settings: &BoardSettings,
16-
) -> Result<(), TockloaderError> {
13+
async fn erase_apps(&mut self, settings: &BoardSettings) -> Result<(), TockloaderError> {
1714
if !self.is_open() {
1815
return Err(InternalError::ConnectionNotOpen.into());
1916
}
@@ -29,22 +26,17 @@ impl CommandEraseApps for ProbeRSConnection {
2926

3027
board_core.read(appaddr, &mut appdata)?;
3128

32-
let app_size: u32;
33-
3429
// The first 8 bytes of the application data contain the TBF header
3530
// lengths and version.
3631
//
3732
// Note on expect: `read` always fills up the entire buffer, which
3833
// was previously declared as 8 bytes.
39-
log::info!("app data? {:?}", appdata);
40-
match parse_tbf_header_lengths(
34+
let app_size: u32 = match parse_tbf_header_lengths(
4135
&appdata
4236
.try_into()
4337
.expect("Buffer length must be at least 8 bytes long."),
4438
) {
45-
Ok(data) => {
46-
app_size = data.2;
47-
}
39+
Ok(data) => data.2,
4840
_ => break,
4941
};
5042

@@ -55,18 +47,15 @@ impl CommandEraseApps for ProbeRSConnection {
5547
let mut loader = session.target().flash_loader();
5648

5749
let address = settings.start_address;
58-
// (adi): fill the memory with total_size values of 0xFF
50+
// (adi): fill the memory with total_size values of 0x0
5951
let buffer = [0x0].repeat(total_size as usize);
60-
loader.add_data(
61-
(address as u32).into(),
62-
&buffer
63-
)?;
64-
52+
loader.add_data((address as u32).into(), &buffer)?;
53+
6554
let mut options = DownloadOptions::default();
6655
options.keep_unwritten_bytes = true;
67-
56+
6857
// Finally, the data can be programmed
6958
loader.commit(session, options)?;
7059
Ok(())
7160
}
72-
}
61+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pub mod erase_apps;
22
pub mod info;
33
pub mod install;
4-
pub mod list;
4+
pub mod list;

tockloader-lib/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,5 @@ pub trait CommandInstall {
6262

6363
#[async_trait]
6464
pub trait CommandEraseApps {
65-
async fn erase_apps(
66-
&mut self,
67-
settings: &BoardSettings,
68-
) -> Result<(), TockloaderError>;
69-
}
65+
async fn erase_apps(&mut self, settings: &BoardSettings) -> Result<(), TockloaderError>;
66+
}

0 commit comments

Comments
 (0)