refactor: fix clippy warnings

This commit is contained in:
2021-11-30 20:34:17 +02:00
parent d0681eb589
commit a577b2dcc4
16 changed files with 70 additions and 101 deletions
+7 -7
View File
@@ -102,7 +102,7 @@ impl Zone {
unsafe fn free(zone: *mut Self) {
trace_debug!("Zone::free({:p})", zone);
sys_munmap(zone as usize, (&*zone).size + size_of::<Zone>())
sys_munmap(zone as usize, (*zone).size + size_of::<Zone>())
.expect("Failed to unmap heap pages");
}
@@ -165,7 +165,7 @@ unsafe fn alloc_from(list: &mut ZoneList, zone_size: usize, size: usize) -> *mut
if !ptr.is_null() {
return ptr;
}
zone = (&mut *zone).next;
zone = (*zone).next;
}
let zone = match Zone::alloc(zone_size) {
@@ -175,7 +175,7 @@ unsafe fn alloc_from(list: &mut ZoneList, zone_size: usize, size: usize) -> *mut
return null_mut();
}
};
list.add(&mut (&mut *zone).list);
list.add(&mut (*zone).list);
}
}
@@ -232,7 +232,7 @@ unsafe impl GlobalAlloc for Allocator {
if !next.is_null() && next_ref.flags & BLOCK_ALLOC == 0 {
next_ref.flags = 0;
if !next_ref.next.is_null() {
(&mut *(next_ref.next)).prev = block;
(*next_ref.next).prev = block;
}
block_ref.next = next_ref.next;
block_ref.size += (next_ref.size as usize + size_of::<Block>()) as u32;
@@ -241,15 +241,15 @@ unsafe impl GlobalAlloc for Allocator {
if block_ref.prev.is_null() && block_ref.next.is_null() {
let zone = (block as usize - size_of::<Zone>()) as *mut Zone;
assert_eq!((zone as usize) & 0xFFF, 0);
(&mut *zone).list.del();
(*zone).list.del();
Zone::free(zone);
}
}
}
#[alloc_error_handler]
fn alloc_error_handler(_layout: Layout) -> ! {
loop {}
fn alloc_error_handler(layout: Layout) -> ! {
panic!("Allocation failed: {:?}", layout);
}
#[global_allocator]
+1 -1
View File
@@ -10,7 +10,7 @@ pub fn args() -> &'static [&'static str] {
pub(crate) unsafe fn setup_env(arg: &ProgramArgs) {
for i in 0..arg.argc {
let base = core::ptr::read((arg.argv + i * 16 + 0) as *const *const u8);
let base = core::ptr::read((arg.argv + i * 16) as *const *const u8);
let len = core::ptr::read((arg.argv + i * 16 + 8) as *const usize);
let string = core::str::from_utf8(core::slice::from_raw_parts(base, len)).unwrap();
+4 -2
View File
@@ -8,7 +8,8 @@ macro_rules! print {
#[macro_export]
macro_rules! println {
($($args:tt)+) => (print!("{}\n", format_args!($($args)+)))
($($args:tt)+) => (print!("{}\n", format_args!($($args)+)));
() => (print!("\n"));
}
#[macro_export]
@@ -18,7 +19,8 @@ macro_rules! eprint {
#[macro_export]
macro_rules! eprintln {
($($args:tt)+) => (eprint!("{}\n", format_args!($($args)+)))
($($args:tt)+) => (eprint!("{}\n", format_args!($($args)+)));
() => (eprint!("\n"));
}
pub fn _print<T: Write>(out: fn() -> T, args: fmt::Arguments) {