Fix clippy errors

This commit is contained in:
2025-03-03 15:51:39 +00:00
parent a0f5ce8797
commit 0a5269eeb0
6 changed files with 19 additions and 14 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ impl ChainedPics {
/// conflict with one another, the resulting object will be useless and
/// will likely cause problems for your system.
pub const unsafe fn new(offset1: u8, offset2: u8) -> Self {
ChainedPics {
Self {
pics: [
Pic {
offset: offset1,
@@ -26,7 +26,7 @@ pub struct Locked<T> {
impl<T> Locked<T> {
pub const fn new(inner: T) -> Self {
Locked {
Self {
inner: Mutex::new(inner),
}
}
@@ -144,6 +144,12 @@ pub struct FoundryFallbackAllocator {
head: FallbackListNode,
}
impl Default for FoundryFallbackAllocator {
fn default() -> Self {
Self::new()
}
}
impl FoundryFallbackAllocator {
pub const fn new() -> Self {
Self {
@@ -173,7 +179,7 @@ impl FoundryFallbackAllocator {
let mut current = &mut self.head;
// look for a large enough memory region in linked list
while let Some(ref mut region) = current.next {
if let Ok(alloc_start) = Self::alloc_from_region(&region, size, align) {
if let Ok(alloc_start) = Self::alloc_from_region(region, size, align) {
// region suitable for allocation -> remove node from list
let next = region.next.take();
let ret = Some((current.next.take().unwrap(), alloc_start));
@@ -16,7 +16,7 @@ pub unsafe fn alloc_stack(
size_in_pages: u64,
mapper: &mut impl Mapper<Size4KiB>,
frame_allocator: &mut impl FrameAllocator<Size4KiB>,
) -> Result<StackBounds, mapper::MapToError<Size4KiB>> {
) -> Result<StackBounds, mapper::MapToError<Size4KiB>> { unsafe {
use x86_64::structures::paging::PageTableFlags as Flags;
let guard_page = reserve_stack_memory(size_in_pages + 1);
@@ -35,7 +35,7 @@ pub unsafe fn alloc_stack(
start: stack_start.start_address(),
end: stack_end.start_address(),
})
}
}}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
@@ -45,15 +45,15 @@ pub struct StackBounds {
}
impl StackBounds {
pub fn new(start: VirtAddr, end: VirtAddr) -> Self {
pub const fn new(start: VirtAddr, end: VirtAddr) -> Self {
Self { start, end }
}
pub fn start(&self) -> VirtAddr {
pub const fn start(&self) -> VirtAddr {
self.start
}
pub fn end(&self) -> VirtAddr {
pub const fn end(&self) -> VirtAddr {
self.end
}
}
@@ -16,13 +16,13 @@ pub struct Thread {
pub struct ThreadId(u64);
impl ThreadId {
pub fn as_u64(&self) -> u64 {
pub const fn as_u64(&self) -> u64 {
self.0
}
fn new() -> Self {
use core::sync::atomic::{AtomicU64, Ordering};
static NEXT_THREAD_ID: AtomicU64 = AtomicU64::new(1);
ThreadId(NEXT_THREAD_ID.fetch_add(1, Ordering::Relaxed))
Self(NEXT_THREAD_ID.fetch_add(1, Ordering::Relaxed))
}
}
+3 -3
View File
@@ -15,8 +15,8 @@ pub struct Font {
}
impl Font {
pub const fn new(data: [[u8; 16]; 512]) -> Font {
Font {
pub const fn new(data: [[u8; 16]; 512]) -> Self {
Self {
width: 8,
height: 16,
length: data.len() as u16,
@@ -40,7 +40,7 @@ impl Font {
self.height
}
pub fn default() -> &'static Font {
pub fn default() -> &'static Self {
&FONT_CP850_8X16
}
}
-1
View File
@@ -1,6 +1,5 @@
use crate::serial_print;
use crate::arch::x86_64::drivers::keyboard::{KeyStroke, get_keystroke_async};
use crate::prelude::*;
use crate::resources::font::Font;
use crate::std::application::frame::Frame;
use crate::std::application::render::RenderError;