Skip to content

Commit

Permalink
mm/ptguards: use iterator instead of slice indexing
Browse files Browse the repository at this point in the history
Zip two iterators instead of manually indexing into a slice in
PerCPUPageMappingGuard::create_4k_pages(), as it is more conventional
Rust.

Signed-off-by: Carlos López <[email protected]>
  • Loading branch information
00xc committed Sep 30, 2024
1 parent 977fc9f commit c614650
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions kernel/src/mm/ptguards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ impl PerCPUPageMappingGuard {
let flags = PTEntryFlags::data();

let mut pgtable = this_cpu().get_pgtable();
for (i, addr) in mapping.region().iter_pages(PageSize::Regular).enumerate() {
assert!(pages[i].0.is_aligned(PAGE_SIZE));

pgtable.map_4k(addr, pages[i].0, flags)?;
if pages[i].1 {
pgtable.set_shared_4k(addr)?;
for (vaddr, (paddr, shared)) in mapping
.region()
.iter_pages(PageSize::Regular)
.zip(pages.iter().copied())
{
assert!(paddr.is_page_aligned());
pgtable.map_4k(vaddr, paddr, flags)?;
if shared {
pgtable.set_shared_4k(vaddr)?;
}
}

Expand Down

0 comments on commit c614650

Please sign in to comment.