Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions src/dir/gen2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ impl Directory {
/// Calculate a new minimum possible offset for relocation to save space.
///
/// As taken from `me_cleaner`:
/// The two bytes in the middle of addr_base are added to spi_base to
/// compute the final start of the LUT. However, addr_base is not
/// modifiable, so act only on spi_base.
/// The two bytes in the middle of `addr_base` are added to `spi_base` to
/// compute the final start of the LUT. However, `addr_base` is not
/// modifiable, so act only on `spi_base`.
pub fn calc_new_offset(&self, min_offset: u32) -> Result<u32, String> {
if let Some((offset, m)) = self.get_huffman_mod() {
let b = (m.header.addr_base & 0x00ff_ffff) >> 8;
Expand Down Expand Up @@ -410,7 +410,7 @@ impl Directory {
//
} else {
*c -= offset_diff;
};
}
}
return Ok(());
}
Expand Down Expand Up @@ -473,7 +473,7 @@ impl Removables for Directory {
let last_chunk = first_chunk + c;
info!("Huffman compressed {n} @ {o:08x} ({s} bytes)");
let a = if retention_list.contains(&n) {
for o in &all_chunks[first_chunk..last_chunk + 1] {
for o in &all_chunks[first_chunk..=last_chunk] {
if o.start != 0 {
unremovable_chunks.push(o.clone());
}
Expand Down
11 changes: 4 additions & 7 deletions src/dir/gen3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl CPDHeader {
match std::str::from_utf8(&n) {
// some names are shorter than 4 bytes and padded with 0x0
Ok(n) => n.trim_end_matches('\0').to_string(),
Err(_) => format!("{:02x?}", n),
Err(_) => format!("{n:02x?}"),
}
}
}
Expand Down Expand Up @@ -112,10 +112,7 @@ pub struct CodePartitionDirectory {
}

fn stringify_vec(v: Vec<u8>) -> String {
v.iter()
.map(|b| format!("{b:02x}"))
.collect::<Vec<String>>()
.join("")
v.iter().map(|b| format!("{b:02x}")).collect::<String>()
}

impl Display for CodePartitionDirectory {
Expand All @@ -135,7 +132,7 @@ impl Display for CodePartitionDirectory {
};
format!("{m}\n{kh}{me}")
}
Err(e) => e.to_string(),
Err(e) => e.clone(),
};
let l3 = " file name offset end size kind".to_string();
write!(f, "{l1}\n{l2}\n{l3}\n")?;
Expand Down Expand Up @@ -187,7 +184,7 @@ impl CodePartitionDirectory {
entries,
offset,
size,
name: name.to_string(),
name: name.clone(),
};

Ok(cpd)
Expand Down
4 changes: 2 additions & 2 deletions src/part/fpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl<'a> FPT {

pub fn get_sorted_entries(&self) -> Vec<FPTEntry> {
let mut entries = self.entries.clone();
entries.sort_by_key(|e| e.offset());
entries.sort_by_key(FPTEntry::offset);
entries
}

Expand Down Expand Up @@ -389,7 +389,7 @@ impl<'a> FPT {
self.entries.as_bytes(),
]
.concat();
let mut res = all.to_vec();
let mut res = all.clone();
res.resize(self.original_size, EMPTY);
res
}
Expand Down
18 changes: 9 additions & 9 deletions src/part/partitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Partitions {

pub fn get_sorted_entries(&self) -> Vec<FPTEntry> {
let mut entries = self.get_entries().clone();
entries.sort_by_key(|e| e.offset());
entries.sort_by_key(super::fpt::FPTEntry::offset);
entries
}

Expand Down Expand Up @@ -125,7 +125,7 @@ impl Partitions {
Partitions::Gen3(res)
}
Partitions::Unknown(p) => {
let res = p.to_vec();
let res = p.clone();
Partitions::Unknown(res)
}
};
Expand All @@ -136,17 +136,17 @@ impl Partitions {
pub fn get_sorted(&self) -> Self {
match self {
Partitions::Gen2(parts) => {
let mut parts = parts.to_vec();
let mut parts = parts.clone();
parts.sort_by_key(|p| p.entry().offset());
Partitions::Gen2(parts)
}
Partitions::Gen3(parts) => {
let mut parts = parts.to_vec();
let mut parts = parts.clone();
parts.sort_by_key(|p| p.entry().offset());
Partitions::Gen3(parts)
}
Partitions::Unknown(parts) => {
let mut parts = parts.to_vec();
let mut parts = parts.clone();
parts.sort_by_key(|p| p.entry().offset());
Partitions::Unknown(parts)
}
Expand All @@ -162,7 +162,7 @@ impl Partitions {
{
return Err(format!("Cannot relocate partition: {e}"));
}
Partitions::Gen2(parts.to_vec())
Partitions::Gen2(parts.clone())
}
Partitions::Gen3(parts) => {
let p = parts.iter_mut().find(|p| p.entry().name() == part_name);
Expand All @@ -171,10 +171,10 @@ impl Partitions {
{
return Err(format!("Cannot relocate partition: {e}"));
}
Partitions::Gen3(parts.to_vec())
Partitions::Gen3(parts.clone())
}
Partitions::Unknown(parts) => {
let parts = parts.to_vec();
let parts = parts.clone();
Partitions::Unknown(parts)
}
};
Expand Down Expand Up @@ -242,7 +242,7 @@ impl Partitions {
&parts.iter().map(|p| p as &dyn Partition).collect(),
&mut data,
),
};
}

Ok(data)
} else {
Expand Down