Skip to content

Commit

Permalink
FP-style seeking
Browse files Browse the repository at this point in the history
  • Loading branch information
efenniht authored and jeehoonkang committed Sep 11, 2019
1 parent 0cb72ec commit 58848ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion hfo2/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ pub unsafe extern "C" fn api_spci_msg_send(
// at spci_msg_handle_architected_message will make several accesses to
// fields in message_buffer. The memory area message_buffer must be
// exclusively owned by Hf so that TOCTOU issues do not arise.
// TODO(HfO2): Refactor `spci_*` functions, in order to pass references
// TODO(HfO2): Refactor `spci_*` functions, in order to pass references
// to VmInner.
let ret = spci_msg_handle_architected_message(
&ManuallyDrop::new(VmLocked::from_raw(to as *const _ as usize as *mut _)),
Expand Down
18 changes: 9 additions & 9 deletions hfo2/src/fdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ impl FdtTokenizer {
}

unsafe fn iter(&self) -> impl Iterator<Item = *const u8> {
slice::from_raw_parts(self.cur, self.end.offset_from(self.cur) as usize).iter().map(|p| p as *const u8)
slice::from_raw_parts(self.cur, self.end.offset_from(self.cur) as usize)
.iter()
.map(|p| p as *const u8)
}

unsafe fn u32(&mut self) -> Option<u32> {
Expand Down Expand Up @@ -147,14 +149,12 @@ impl FdtTokenizer {
}

unsafe fn str(&mut self) -> Option<*const u8> {
for p in self.iter() {
if *p == 0 {
// Found the end of the string.
let res = self.cur;
self.cur = p.add(1);
self.align();
return Some(res);
}
if let Some(p) = self.iter().find(|p| **p == 0) {
// Found the end of the string.
let res = self.cur;
self.cur = p.add(1);
self.align();
return Some(res);
}

None
Expand Down

0 comments on commit 58848ef

Please sign in to comment.