Skip to content

Commit beba529

Browse files
committed
iort: fix some bugs
1 parent 77f84e4 commit beba529

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

acpi/src/iort.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl fmt::Display for Iort {
4545
impl Iort {
4646
pub fn nodes(&self) -> IortNodeIter {
4747
let pointer = unsafe { (self as *const Iort).add(1) as *const u8 };
48-
let remaining_length = self.header.length as u32 - size_of::<Iort>() as u32;
48+
let remaining_length = self.header.length as u32 - core::mem::size_of::<Iort>() as u32;
4949

5050
IortNodeIter {
5151
pointer,
@@ -79,10 +79,11 @@ pub enum IortNode<'a> {
7979
MemoryRange(&'a MemoryRangeNode),
8080
}
8181

82-
impl IortNode {
82+
impl IortNode<'_> {
8383
pub fn id_mapping_array(&self) -> Option<&[IortIdMapping]> {
84-
let id_mapping_num = unsafe {*(self as *const IortNode as *const IortNodeHeader).id_mapping_num};
85-
let id_mapping_array_offset = unsafe {*(self as *const IortNode as *const IortNodeHeader).id_mapping_array_offset};
84+
let node_header = unsafe{ *(self as *const IortNode as *const IortNodeHeader) };
85+
let id_mapping_num = node_header.id_mapping_num;
86+
let id_mapping_array_offset = node_header.id_mapping_array_offset;
8687

8788
if id_mapping_num == 0 {
8889
return None;
@@ -123,7 +124,7 @@ impl<'a> Iterator for IortNodeIter<'a> {
123124
_ => return None,
124125
};
125126

126-
self.pointer = unsafe { self.pointer.add(node_length) };
127+
self.pointer = unsafe { self.pointer.add(node_length as usize) };
127128
self.remaining_length -= node_length as u32;
128129

129130
Some(node)

0 commit comments

Comments
 (0)