Skip to content
Snippets Groups Projects
Commit c455a80b authored by Eemeli Lehtonen's avatar Eemeli Lehtonen
Browse files

cargo clippy

parent faa1e924
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ pub fn args() -> Arguments { ...@@ -9,7 +9,7 @@ pub fn args() -> Arguments {
// //
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Arguments { pub struct Arguments {
pub log_level: LogLevel, pub log_level: LogLevel,
// log_color: bool, // log_color: bool,
...@@ -24,8 +24,10 @@ impl Arguments { ...@@ -24,8 +24,10 @@ impl Arguments {
pub fn parse(s: &'static str) { pub fn parse(s: &'static str) {
ARGUMENTS.call_once(|| { ARGUMENTS.call_once(|| {
let mut iter = s.split(|c: char| c.is_whitespace() || c == '='); let mut iter = s.split(|c: char| c.is_whitespace() || c == '=');
let mut result = Arguments::default(); let mut result = Arguments {
result.cmdline = s; cmdline: s,
..<_>::default()
};
while let Some(item) = iter.next() { while let Some(item) = iter.next() {
match item { match item {
...@@ -58,14 +60,4 @@ impl Arguments { ...@@ -58,14 +60,4 @@ impl Arguments {
} }
} }
impl Default for Arguments {
fn default() -> Self {
Self {
log_level: LogLevel::default(),
had_unrecognized: false,
cmdline: "",
}
}
}
static ARGUMENTS: Once<Arguments> = Once::new(); static ARGUMENTS: Once<Arguments> = Once::new();
...@@ -14,12 +14,6 @@ ...@@ -14,12 +14,6 @@
// //
use x86_64::{
registers::control::Cr3,
structures::paging::{PageTable, PhysFrame},
VirtAddr,
};
extern crate alloc; extern crate alloc;
// //
......
use crate::{boot, debug, mem::map::Memmap, util::fmt::NumberPostfix}; use crate::{boot, debug};
use x86_64::{ use x86_64::{
registers::control::Cr3, registers::control::Cr3,
structures::paging::{page_table::FrameError, PageTable, PhysFrame, Size2MiB, Size4KiB}, structures::paging::{page_table::FrameError, PageTable, PhysFrame, Size2MiB, Size4KiB},
...@@ -22,10 +22,12 @@ pub fn init() { ...@@ -22,10 +22,12 @@ pub fn init() {
// //
#[allow(unused)]
fn is_higher_half(addr: u64) -> bool { fn is_higher_half(addr: u64) -> bool {
addr >= boot::hhdm_offset() addr >= boot::hhdm_offset()
} }
#[allow(unused)]
fn to_higher_half(addr: PhysAddr) -> VirtAddr { fn to_higher_half(addr: PhysAddr) -> VirtAddr {
let addr = addr.as_u64(); let addr = addr.as_u64();
if is_higher_half(addr) { if is_higher_half(addr) {
...@@ -35,6 +37,7 @@ fn to_higher_half(addr: PhysAddr) -> VirtAddr { ...@@ -35,6 +37,7 @@ fn to_higher_half(addr: PhysAddr) -> VirtAddr {
} }
} }
#[allow(unused)]
fn from_higher_half(addr: VirtAddr) -> PhysAddr { fn from_higher_half(addr: VirtAddr) -> PhysAddr {
let addr = addr.as_u64(); let addr = addr.as_u64();
if is_higher_half(addr) { if is_higher_half(addr) {
...@@ -87,6 +90,7 @@ fn walk_page_tables(addr: VirtAddr) -> Option<PhysAddr> { ...@@ -87,6 +90,7 @@ fn walk_page_tables(addr: VirtAddr) -> Option<PhysAddr> {
Some(frame.start_address() + u64::from(addr.page_offset())) Some(frame.start_address() + u64::from(addr.page_offset()))
} }
#[allow(unused)]
fn debug_phys_addr(addr: PhysAddr) { fn debug_phys_addr(addr: PhysAddr) {
debug!( debug!(
"{:?} {:?} {:?}", "{:?} {:?} {:?}",
......
use super::{map::Memmap, to_higher_half}; use super::{map::Memmap, to_higher_half};
use crate::{ use crate::{
boot, debug, boot, debug,
log::{test_log_level, LogLevel}, mem::bump,
mem::{bump, map::Memtype},
trace, trace,
util::{bitmap::Bitmap, fmt::NumberPostfix}, util::{bitmap::Bitmap, fmt::NumberPostfix},
}; };
use core::{ use core::{
any::type_name,
convert::identity,
fmt, slice, fmt, slice,
sync::atomic::{AtomicU64, AtomicUsize, Ordering}, sync::atomic::{AtomicU64, AtomicUsize, Ordering},
}; };
use spin::{Mutex, Once}; use spin::{Mutex, Once};
use x86_64::{align_down, align_up, PhysAddr, VirtAddr}; use x86_64::{align_up, PhysAddr};
// //
...@@ -38,7 +35,7 @@ pub fn init() { ...@@ -38,7 +35,7 @@ pub fn init() {
// the end of the usable physical memory address space // the end of the usable physical memory address space
let top = boot::memmap() let top = boot::memmap()
.filter(Memmap::is_usable) .filter(Memmap::is_usable)
.map(|Memmap { base, len, ty }| base + len) .map(|Memmap { base, len, ty: _ }| base + len)
.max() .max()
.expect("No memory"); .expect("No memory");
...@@ -61,7 +58,7 @@ pub fn init() { ...@@ -61,7 +58,7 @@ pub fn init() {
for Memmap { for Memmap {
mut base, mut base,
mut len, mut len,
ty, ty: _,
} in boot::memmap().filter(Memmap::is_usable) } in boot::memmap().filter(Memmap::is_usable)
{ {
if let Some(map) = bump::map() && map.base == base { if let Some(map) = bump::map() && map.base == base {
......
...@@ -6,7 +6,7 @@ pub trait EscapeEncoder ...@@ -6,7 +6,7 @@ pub trait EscapeEncoder
where where
Self: Sized, Self: Sized,
{ {
fn with_escape_code<'a>(self, code: &'a str) -> EncodedPart<'a, Self> { fn with_escape_code(self, code: &str) -> EncodedPart<Self> {
EncodedPart { EncodedPart {
code, code,
data: self, data: self,
......
...@@ -7,7 +7,7 @@ pub trait NumberPostfix: Sized + Copy + DivAssign + PartialOrd { ...@@ -7,7 +7,7 @@ pub trait NumberPostfix: Sized + Copy + DivAssign + PartialOrd {
const NUM_1024: Self; const NUM_1024: Self;
fn postfix(mut self) -> NumberPostfixed<Self> { fn postfix(mut self) -> NumberPostfixed<Self> {
const TABLE: [&'static str; 10] = ["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R"]; const TABLE: [&str; 10] = ["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R"];
for scale in TABLE { for scale in TABLE {
if self < Self::NUM_1000 { if self < Self::NUM_1000 {
return NumberPostfixed { n: self, scale }; return NumberPostfixed { n: self, scale };
...@@ -21,8 +21,7 @@ pub trait NumberPostfix: Sized + Copy + DivAssign + PartialOrd { ...@@ -21,8 +21,7 @@ pub trait NumberPostfix: Sized + Copy + DivAssign + PartialOrd {
} }
fn postfix_binary(mut self) -> NumberPostfixed<Self> { fn postfix_binary(mut self) -> NumberPostfixed<Self> {
const TABLE: [&'static str; 10] = const TABLE: [&str; 10] = ["", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi", "Ri"];
["", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi", "Ri"];
for scale in TABLE { for scale in TABLE {
if self < Self::NUM_1024 { if self < Self::NUM_1024 {
return NumberPostfixed { n: self, scale }; return NumberPostfixed { n: self, scale };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment