kernel: more clippy warning fixes

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-08-05 16:59:27 +08:00
parent d7a9b64d82
commit b98e465d12
2 changed files with 9 additions and 9 deletions

View file

@ -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())
});

View file

@ -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| {