|
| 1 | +use alloc::vec::Vec; |
| 2 | + |
1 | 3 | use anyhow::{Context, Result, bail, ensure}; |
2 | 4 | use object::{Endianness, Object, ObjectSection}; |
3 | 5 |
|
@@ -154,16 +156,16 @@ pub(super) fn parse_line_info_mdebug( |
154 | 156 | fn assign_lines(sections: &mut [Section], base_address: u64, lines: &[i32]) { |
155 | 157 | let mut address = base_address; |
156 | 158 | for &line in lines { |
157 | | - if line >= 0 { |
158 | | - if let Some(section) = find_code_section(sections, address) { |
159 | | - section.line_info.insert(address, line as u32); |
160 | | - } |
| 159 | + if line >= 0 |
| 160 | + && let Some(section) = find_code_section(sections, address) |
| 161 | + { |
| 162 | + section.line_info.insert(address, line as u32); |
161 | 163 | } |
162 | 164 | address = address.wrapping_add(4); |
163 | 165 | } |
164 | 166 | } |
165 | 167 |
|
166 | | -fn find_code_section<'a>(sections: &'a mut [Section], address: u64) -> Option<&'a mut Section> { |
| 168 | +fn find_code_section(sections: &mut [Section], address: u64) -> Option<&mut Section> { |
167 | 169 | sections.iter_mut().find(|section| { |
168 | 170 | section.kind == SectionKind::Code |
169 | 171 | && address >= section.address |
@@ -195,12 +197,12 @@ fn decode_delta( |
195 | 197 | } |
196 | 198 | } |
197 | 199 |
|
198 | | -fn slice_at<'a>( |
199 | | - data: &'a [u8], |
| 200 | +fn slice_at( |
| 201 | + data: &[u8], |
200 | 202 | offset: u32, |
201 | 203 | size: u32, |
202 | 204 | section_file_offset: Option<usize>, |
203 | | -) -> Result<&'a [u8]> { |
| 205 | +) -> Result<&[u8]> { |
204 | 206 | let size = size as usize; |
205 | 207 | if size == 0 { |
206 | 208 | ensure!( |
@@ -355,7 +357,7 @@ struct SymbolEntry { |
355 | 357 | } |
356 | 358 |
|
357 | 359 | fn parse_symbols(data: &[u8], endianness: Endianness) -> Result<Vec<SymbolEntry>> { |
358 | | - ensure!(data.len() % SYMR_SIZE == 0, "symbol table misaligned"); |
| 360 | + ensure!(data.len().is_multiple_of(SYMR_SIZE), "symbol table misaligned"); |
359 | 361 | let mut symbols = Vec::with_capacity(data.len() / SYMR_SIZE); |
360 | 362 | let mut cursor = 0; |
361 | 363 | while cursor + SYMR_SIZE <= data.len() { |
|
0 commit comments