Skip to content

Commit dac489a

Browse files
committed
tool: fix lint errors
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
1 parent 6d6d560 commit dac489a

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

tool/microkit/src/elf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,14 @@ impl ElfFile {
384384

385385
last_addr = last_addr + (0x10000 - (last_addr % 0x10000));
386386

387-
return ElfSegment {
387+
ElfSegment {
388388
name: Some(segment_name.to_string()),
389389
data: vec![0; size as usize],
390390
phys_addr: last_addr,
391391
virt_addr: last_addr,
392392
loadable: true,
393393
attrs: ElfSegmentAttributes::Read as u32,
394-
};
394+
}
395395
}
396396

397397
pub fn populate_segment(&mut self, segment_name: &str, data: &[u8]) {
@@ -414,6 +414,6 @@ impl ElfFile {
414414
}
415415
}
416416
}
417-
return None;
417+
None
418418
}
419419
}

tool/microkit/src/lib.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ pub struct PGD {
3131
puds: Vec<Option<PUD>>,
3232
}
3333

34+
impl Default for PGD {
35+
fn default() -> Self {
36+
Self::new()
37+
}
38+
}
39+
3440
impl PGD {
3541
pub fn new() -> Self {
3642
PGD {
@@ -40,10 +46,10 @@ impl PGD {
4046

4147
pub fn recurse(&mut self, mut curr_offset: u64, buffer: &mut Vec<u8>) -> u64 {
4248
let mut offset_table: [u64; 512] = [u64::MAX; 512];
43-
for i in 0..512 {
49+
for (i, entry) in offset_table.iter_mut().enumerate() {
4450
if let Some(pud) = &mut self.puds[i] {
4551
curr_offset = pud.recurse(curr_offset, buffer);
46-
offset_table[i] = curr_offset - (512 * 8);
52+
*entry = curr_offset - (512 * 8);
4753
}
4854
}
4955

@@ -85,7 +91,7 @@ impl PGD {
8591
child_size += pud.as_ref().unwrap().get_size();
8692
}
8793
}
88-
return (512 * 8) + child_size;
94+
(512 * 8) + child_size
8995
}
9096
}
9197

@@ -103,10 +109,10 @@ impl PUD {
103109

104110
fn recurse(&mut self, mut curr_offset: u64, buffer: &mut Vec<u8>) -> u64 {
105111
let mut offset_table: [u64; 512] = [u64::MAX; 512];
106-
for i in 0..512 {
112+
for (i, entry) in offset_table.iter_mut().enumerate() {
107113
if let Some(dir) = &mut self.dirs[i] {
108114
curr_offset = dir.recurse(curr_offset, buffer);
109-
offset_table[i] = curr_offset - (512 * 8);
115+
*entry = curr_offset - (512 * 8);
110116
}
111117
}
112118

@@ -134,7 +140,7 @@ impl PUD {
134140
child_size += dir.as_ref().unwrap().get_size();
135141
}
136142
}
137-
return (512 * 8) + child_size;
143+
(512 * 8) + child_size
138144
}
139145
}
140146

@@ -158,17 +164,17 @@ impl DIR {
158164

159165
fn recurse(&mut self, mut curr_offset: u64, buffer: &mut Vec<u8>) -> u64 {
160166
let mut offset_table: [u64; 512] = [u64::MAX; 512];
161-
for i in 0..512 {
167+
for (i, dir_entry) in offset_table.iter_mut().enumerate() {
162168
if let Some(entry) = &mut self.entries[i] {
163169
match entry {
164170
DirEntry::PageTable(x) => {
165171
curr_offset = x.recurse(curr_offset, buffer);
166-
offset_table[i] = curr_offset - (512 * 8);
172+
*dir_entry = curr_offset - (512 * 8);
167173
}
168174
DirEntry::LargePage(x) => {
169175
// curr_offset += 8;
170176
// we mark the top bit to signal to the pd that this is a large page
171-
offset_table[i] = *x | (1 << 63);
177+
*dir_entry = *x | (1 << 63);
172178
}
173179
}
174180
}
@@ -208,14 +214,11 @@ impl DIR {
208214
fn get_size(&self) -> u64 {
209215
let mut child_size = 0;
210216
for pt in &self.entries {
211-
match pt {
212-
Some(DirEntry::PageTable(x)) => {
213-
child_size += x.get_size();
214-
}
215-
_ => {}
217+
if let Some(DirEntry::PageTable(x)) = pt {
218+
child_size += x.get_size();
216219
}
217220
}
218-
return (512 * 8) + child_size;
221+
(512 * 8) + child_size
219222
}
220223
}
221224

@@ -248,7 +251,7 @@ impl PT {
248251
}
249252

250253
fn get_size(&self) -> u64 {
251-
return 512 * 8;
254+
512 * 8
252255
}
253256
}
254257

tool/microkit/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ fn build_system(
840840
// protection domains
841841
let mut pd_elf_size = 0;
842842
for pd_elf in pd_elf_files.iter_mut() {
843-
for r in phys_mem_regions_from_elf(&pd_elf, config.minimum_page_size) {
843+
for r in phys_mem_regions_from_elf(pd_elf, config.minimum_page_size) {
844844
pd_elf_size += r.size();
845845
}
846846
}
@@ -2132,7 +2132,7 @@ fn build_system(
21322132
let new_elf_seg = elf.get_segment(".table_data").unwrap();
21332133

21342134
table_metadata.base_addr = new_elf_seg.virt_addr;
2135-
elf.write_symbol("table_metadata", &table_metadata.as_bytes())?;
2135+
elf.write_symbol("table_metadata", table_metadata.as_bytes())?;
21362136
}
21372137

21382138
let mut badged_irq_caps: HashMap<&ProtectionDomain, Vec<u64>> = HashMap::new();
@@ -3465,7 +3465,7 @@ fn main() -> Result<(), String> {
34653465
cap_address_bits: 64,
34663466
fan_out_limit: json_str_as_u64(&kernel_config_json, "RETYPE_FAN_OUT_LIMIT")?,
34673467
hypervisor,
3468-
microkit_config: MicrokitConfig::from_str(args.config),
3468+
microkit_config: MicrokitConfig::config_from_str(args.config),
34693469
fpu: json_str_as_bool(&kernel_config_json, "HAVE_FPU")?,
34703470
arm_pa_size_bits,
34713471
arm_smc,

tool/microkit/src/sel4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub enum MicrokitConfig {
3939
}
4040

4141
impl MicrokitConfig {
42-
pub fn from_str(string: &str) -> Self {
42+
pub fn config_from_str(string: &str) -> Self {
4343
match string {
4444
"debug" => MicrokitConfig::Debug,
4545
"release" => MicrokitConfig::Release,

0 commit comments

Comments
 (0)