From b98e465d12b3e17148e378b6a3558079b58179b4 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 5 Aug 2021 16:59:27 +0800 Subject: [PATCH] kernel: more clippy warning fixes Signed-off-by: Sean Cross --- kernel/src/arch/riscv/irq.rs | 10 +++++++--- kernel/src/main.rs | 8 ++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/src/arch/riscv/irq.rs b/kernel/src/arch/riscv/irq.rs index 269f5ed77..85f28f480 100644 --- a/kernel/src/arch/riscv/irq.rs +++ b/kernel/src/arch/riscv/irq.rs @@ -180,11 +180,11 @@ pub extern "C" fn trap_handler( // or returning from a handler or thread. If so, handle the exception // and return right away. match ex { - RiscvException::StorePageFault(pc, addr) | RiscvException::LoadPageFault(pc, addr) => { + RiscvException::StorePageFault(_pc, addr) | RiscvException::LoadPageFault(_pc, addr) => { #[cfg(all(feature = "debug-print", feature = "print-panics"))] print!( "KERNEL({}): RISC-V fault: {} @ {:08x}, addr {:08x} - ", - pid, ex, pc, addr + pid, ex, _pc, addr ); crate::arch::mem::ensure_page_exists_inner(addr) .map(|_new_page| { @@ -214,7 +214,11 @@ pub extern "C" fn trap_handler( ArchProcess::with_current_mut(|p| { // Adjust the program counter by the amount returned by the exception handler let pc_adjust = a0 as isize; - p.current_thread_mut().sepc += 4; + if pc_adjust < 0 { + p.current_thread_mut().sepc -= pc_adjust.abs() as usize; + } else { + p.current_thread_mut().sepc += pc_adjust.abs() as usize; + } crate::arch::syscall::resume(current_pid().get() == 1, p.current_thread()) }); diff --git a/kernel/src/main.rs b/kernel/src/main.rs index 4ad8c1b7e..ac9ef0533 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -47,12 +47,8 @@ fn handle_panic(_arg: &PanicInfo) -> ! { /// # Safety /// /// This is safe to call only to initialize the kernel. -pub unsafe extern "C" fn init( - arg_offset: *const u32, - init_offset: *const u32, - rpt_offset: *mut u32, -) { - args::KernelArguments::init(arg_offset); +pub extern "C" fn init(arg_offset: *const u32, init_offset: *const u32, rpt_offset: *mut u32) { + unsafe { args::KernelArguments::init(arg_offset) }; let args = args::KernelArguments::get(); // Everything needs memory, so the first thing we should do is initialize the memory manager. crate::mem::MemoryManager::with_mut(|mm| {