Skip to content

Commit 7c54dab

Browse files
romancardenasrmsyn
andcommitted
Update riscv-rt/src/lib.rs
Co-authored-by: rmsyn <[email protected]>
1 parent 1dd0250 commit 7c54dab

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

riscv-rt/src/lib.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -527,17 +527,13 @@ pub unsafe extern "C" fn start_trap_rust(trap_frame: *const TrapFrame) {
527527

528528
match xcause::read().cause() {
529529
xcause::Trap::Interrupt(code) => _dispatch_core_interrupt(code),
530-
xcause::Trap::Exception(code) => {
531-
let trap_frame = &*trap_frame;
532-
if code < __EXCEPTIONS.len() {
533-
let h = &__EXCEPTIONS[code];
534-
if let Some(handler) = h {
535-
handler(trap_frame);
536-
} else {
537-
ExceptionHandler(trap_frame);
538-
}
539-
} else {
540-
ExceptionHandler(trap_frame);
530+
xcause::Trap::Exception(code) if code < __EXCEPTIONS.len() => {
531+
match __EXCEPTIONS[code].as_ref() {
532+
Some(handler) => handler(&*trap_frame),
533+
None => ExceptionHandler(&*trap_frame),
534+
}
535+
}
536+
xcause::Trap::Exception(_) => ExceptionHandler(&*trap_frame),
541537
}
542538
}
543539
}

0 commit comments

Comments
 (0)