Skip to content

Commit

Permalink
Merge pull request #417 from hermit-os/clippy
Browse files Browse the repository at this point in the history
fix Rust 1.83 lints
  • Loading branch information
mkroening authored Dec 2, 2024
2 parents 96ed91c + 7dc1540 commit 769dc1e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/arch/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn find_kernel_multiboot(chosen: &FdtNode<'_, '_>) -> Option<&'static [u8]> {

let initrd_start = sptr::from_exposed_addr_mut::<u8>(addr);
// SAFETY: We trust the raw pointer from the firmware
return Some(unsafe { slice::from_raw_parts(initrd_start, len) });
Some(unsafe { slice::from_raw_parts(initrd_start, len) })
}

pub fn find_kernel() -> &'static [u8] {
Expand Down
12 changes: 6 additions & 6 deletions src/arch/x86_64/physicalmem.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use core::num::NonZeroUsize;

use log::debug;
use one_shot_mutex::OneShotMutex;
use x86_64::structures::paging::{FrameAllocator, FrameDeallocator, PageSize, PhysFrame, Size4KiB};

static mut PHYS_ALLOC: Option<PhysAllocInner> = None;
static PHYS_ALLOC: OneShotMutex<Option<PhysAllocInner>> = OneShotMutex::new(None);

struct PhysAllocInner {
next: NonZeroUsize,
Expand All @@ -27,14 +28,13 @@ pub struct PhysAlloc;

impl PhysAlloc {
pub fn init(addr: usize) {
unsafe {
assert!(PHYS_ALLOC.is_none());
PHYS_ALLOC.replace(PhysAllocInner::new(addr.try_into().unwrap()));
}
let mut phys_alloc = PHYS_ALLOC.lock();
assert!(phys_alloc.is_none());
phys_alloc.replace(PhysAllocInner::new(addr.try_into().unwrap()));
}

pub fn allocate(size: usize) -> usize {
unsafe { PHYS_ALLOC.as_mut().unwrap().allocate(size) }
PHYS_ALLOC.lock().as_mut().unwrap().allocate(size)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/fdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ mod uefi {
inner: &'a T,
}

impl<'a, T> fmt::Display for MemoryMapDisplay<'a, T>
impl<T> fmt::Display for MemoryMapDisplay<'_, T>
where
T: MemoryMap,
{
Expand Down Expand Up @@ -169,7 +169,7 @@ mod uefi {
inner: &'a MemoryDescriptor,
}

impl<'a> fmt::Display for MemoryDescriptorDisplay<'a> {
impl fmt::Display for MemoryDescriptorDisplay<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
Expand Down

0 comments on commit 769dc1e

Please sign in to comment.