Skip to content

Commit 107d6a3

Browse files
committed
dir: cargo clippy --fix -- -W clippy::pedantic
Signed-off-by: Daniel Maslowski <[email protected]>
1 parent 7dc8f23 commit 107d6a3

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/dir/gen2.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ impl Directory {
315315
/// Calculate a new minimum possible offset for relocation to save space.
316316
///
317317
/// As taken from `me_cleaner`:
318-
/// The two bytes in the middle of addr_base are added to spi_base to
319-
/// compute the final start of the LUT. However, addr_base is not
320-
/// modifiable, so act only on spi_base.
318+
/// The two bytes in the middle of `addr_base` are added to `spi_base` to
319+
/// compute the final start of the LUT. However, `addr_base` is not
320+
/// modifiable, so act only on `spi_base`.
321321
pub fn calc_new_offset(&self, min_offset: u32) -> Result<u32, String> {
322322
if let Some((offset, m)) = self.get_huffman_mod() {
323323
let b = (m.header.addr_base & 0x00ff_ffff) >> 8;
@@ -410,7 +410,7 @@ impl Directory {
410410
//
411411
} else {
412412
*c -= offset_diff;
413-
};
413+
}
414414
}
415415
return Ok(());
416416
}
@@ -473,7 +473,7 @@ impl Removables for Directory {
473473
let last_chunk = first_chunk + c;
474474
info!("Huffman compressed {n} @ {o:08x} ({s} bytes)");
475475
let a = if retention_list.contains(&n) {
476-
for o in &all_chunks[first_chunk..last_chunk + 1] {
476+
for o in &all_chunks[first_chunk..=last_chunk] {
477477
if o.start != 0 {
478478
unremovable_chunks.push(o.clone());
479479
}

src/dir/gen3.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl CPDHeader {
4141
match std::str::from_utf8(&n) {
4242
// some names are shorter than 4 bytes and padded with 0x0
4343
Ok(n) => n.trim_end_matches('\0').to_string(),
44-
Err(_) => format!("{:02x?}", n),
44+
Err(_) => format!("{n:02x?}"),
4545
}
4646
}
4747
}
@@ -112,10 +112,7 @@ pub struct CodePartitionDirectory {
112112
}
113113

114114
fn stringify_vec(v: Vec<u8>) -> String {
115-
v.iter()
116-
.map(|b| format!("{b:02x}"))
117-
.collect::<Vec<String>>()
118-
.join("")
115+
v.iter().map(|b| format!("{b:02x}")).collect::<String>()
119116
}
120117

121118
impl Display for CodePartitionDirectory {
@@ -135,7 +132,7 @@ impl Display for CodePartitionDirectory {
135132
};
136133
format!("{m}\n{kh}{me}")
137134
}
138-
Err(e) => e.to_string(),
135+
Err(e) => e.clone(),
139136
};
140137
let l3 = " file name offset end size kind".to_string();
141138
write!(f, "{l1}\n{l2}\n{l3}\n")?;
@@ -187,7 +184,7 @@ impl CodePartitionDirectory {
187184
entries,
188185
offset,
189186
size,
190-
name: name.to_string(),
187+
name: name.clone(),
191188
};
192189

193190
Ok(cpd)

0 commit comments

Comments
 (0)