From 617c92d01723da0b2733297bfe54008a0a666c3d Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 10 Dec 2015 16:55:54 +0100 Subject: [PATCH] Use a more expressive variable name --- posts/2015-12-09-modifying-page-tables.md | 4 ++-- src/memory/paging/table.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/posts/2015-12-09-modifying-page-tables.md b/posts/2015-12-09-modifying-page-tables.md index eab6e2e8..169802fc 100644 --- a/posts/2015-12-09-modifying-page-tables.md +++ b/posts/2015-12-09-modifying-page-tables.md @@ -296,12 +296,12 @@ To convert the address into references, we add two functions: ```rust pub fn next_table(&self, index: usize) -> Option<&Table> { self.next_table_address(index) - .map(|t| unsafe { &*(t as *const _) }) + .map(|address| unsafe { &*(address as *const _) }) } pub fn next_table_mut(&mut self, index: usize) -> Option<&mut Table> { self.next_table_address(index) - .map(|t| unsafe { &mut *(t as *mut _) }) + .map(|address| unsafe { &mut *(address as *mut _) }) } ``` We convert the address into raw pointers and then convert them into references in `unsafe` blocks. Now we can start at the `P4` constant and use these functions to access the lower tables. And we don't even need `unsafe` blocks to do it! diff --git a/src/memory/paging/table.rs b/src/memory/paging/table.rs index b1a45d06..158a4b2c 100644 --- a/src/memory/paging/table.rs +++ b/src/memory/paging/table.rs @@ -34,12 +34,12 @@ impl Table where L: HierachicalLevel pub fn next_table(&self, index: usize) -> Option<&Table> { self.next_table_address(index) - .map(|t| unsafe { &*(t as *const _) }) + .map(|address| unsafe { &*(address as *const _) }) } pub fn next_table_mut(&mut self, index: usize) -> Option<&mut Table> { self.next_table_address(index) - .map(|t| unsafe { &mut *(t as *mut _) }) + .map(|address| unsafe { &mut *(address as *mut _) }) } pub fn next_table_create(&mut self,