Closed
Description
From the Rustinomicon section on exception safety:
In unsafe code, we must be exception safe to the point of not violating memory safety.
We'll call this minimal exception safety.
There are a number of locations in the code that use explicit panics (e.g. unimplemented!
, assert.*!
macros). Sometime, these panic
ing calls are made within safe
functions, which users may call inside an unsafe
context.
riscv
should convert all explicit and implicit panic
ing code into fallible code that returns an Option
or Result
.
For example, Mcounteren::hpm
could be changed from:
/// Supervisor "hpm\[x\]" Enable (bits 3-31)
#[inline]
pub fn hpm(&self, index: usize) -> bool {
assert!((3..32).contains(&index));
self.bits & (1 << index) != 0
}
To the fallible:
/// Supervisor "hpm\[x\]" Enable (bits 3-31)
#[inline]
pub fn hpm(&self, index: usize) -> Option<bool> {
if (3..32).contains(&index) {
Some(self.bits & (1 << index) != 0)
} else {
None
}
}
Any strategy will almost definitely require breaking changes, and a version bump.
Metadata
Metadata
Assignees
Labels
No labels