fix again
This commit is contained in:
parent
a9d5677c57
commit
43e400ef08
|
@ -1,11 +1,4 @@
|
||||||
#[cfg(test)]
|
|
||||||
use std::mem;
|
|
||||||
#[cfg(test)]
|
|
||||||
use std::slice;
|
|
||||||
|
|
||||||
#[cfg(not(test))]
|
|
||||||
use core::mem;
|
use core::mem;
|
||||||
#[cfg(not(test))]
|
|
||||||
use core::slice;
|
use core::slice;
|
||||||
|
|
||||||
use error::Error;
|
use error::Error;
|
||||||
|
@ -52,11 +45,9 @@ impl BlockGroupDescriptor {
|
||||||
return Err(Error::OutOfBounds(end));
|
return Err(Error::OutOfBounds(end));
|
||||||
}
|
}
|
||||||
|
|
||||||
let ptr = unsafe {
|
let ptr = haystack.as_mut_ptr().offset(offset as isize)
|
||||||
haystack.as_mut_ptr().offset(offset as isize)
|
as *mut BlockGroupDescriptor;
|
||||||
as *mut BlockGroupDescriptor
|
let slice = slice::from_raw_parts_mut(ptr, count);
|
||||||
};
|
|
||||||
let slice = unsafe { slice::from_raw_parts_mut(ptr, count) };
|
|
||||||
Ok(slice)
|
Ok(slice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,8 +61,9 @@ mod tests {
|
||||||
let mut buffer = vec![0_u8; 4096];
|
let mut buffer = vec![0_u8; 4096];
|
||||||
let addr = &buffer[2048] as *const _ as usize;
|
let addr = &buffer[2048] as *const _ as usize;
|
||||||
// magic
|
// magic
|
||||||
let table =
|
let table = unsafe {
|
||||||
BlockGroupDescriptor::find_descriptor_table(&mut buffer, 0, 0);
|
BlockGroupDescriptor::find_descriptor_table(&mut buffer, 0, 0)
|
||||||
|
};
|
||||||
assert!(
|
assert!(
|
||||||
table.is_ok(),
|
table.is_ok(),
|
||||||
"Err({:?})",
|
"Err({:?})",
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
#[cfg(test)]
|
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
#[cfg(not(test))]
|
|
||||||
use core::mem;
|
use core::mem;
|
||||||
|
|
||||||
use error::Error;
|
use error::Error;
|
||||||
|
@ -157,7 +153,7 @@ impl Superblock {
|
||||||
return Err(Error::OutOfBounds(end));
|
return Err(Error::OutOfBounds(end));
|
||||||
}
|
}
|
||||||
|
|
||||||
let superblock: &mut Superblock = unsafe {
|
let superblock: &mut Superblock = {
|
||||||
let ptr = haystack.as_mut_ptr().offset(offset as isize)
|
let ptr = haystack.as_mut_ptr().offset(offset as isize)
|
||||||
as *mut Superblock;
|
as *mut Superblock;
|
||||||
ptr.as_mut().unwrap()
|
ptr.as_mut().unwrap()
|
||||||
|
@ -251,7 +247,7 @@ mod tests {
|
||||||
// magic
|
// magic
|
||||||
buffer[1024 + 56] = EXT2_MAGIC as u8;
|
buffer[1024 + 56] = EXT2_MAGIC as u8;
|
||||||
buffer[1024 + 57] = (EXT2_MAGIC >> 8) as u8;
|
buffer[1024 + 57] = (EXT2_MAGIC >> 8) as u8;
|
||||||
let superblock = Superblock::find(&mut buffer, 0);
|
let superblock = unsafe { Superblock::find(&mut buffer, 0) };
|
||||||
assert!(
|
assert!(
|
||||||
superblock.is_ok(),
|
superblock.is_ok(),
|
||||||
"Err({:?})",
|
"Err({:?})",
|
||||||
|
|
Reference in a new issue