Skip to content

Commit

Permalink
ref
Browse files Browse the repository at this point in the history
  • Loading branch information
tompro committed Feb 24, 2024
1 parent bb3cb13 commit b0e45d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/kernel/src/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ macro_rules! error_numbers {
};
)*

pub fn strerror_impl(num: NonZeroI32) -> &'static str {
fn strerror_impl(num: NonZeroI32) -> &'static str {
match num {
$( $name => $desc, )*
_ => todo!("strerror {num}", num = num.get()),
Expand Down
12 changes: 6 additions & 6 deletions src/kernel/src/signal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod set;
pub struct Signal(NonZeroI32);

impl Signal {
pub fn new(raw: i32) -> Option<Self> {
pub const fn new(raw: i32) -> Option<Self> {
match raw {
1..=SIG_MAXSIG => Some(Signal(unsafe { NonZeroI32::new_unchecked(raw) })),
_ => None,
Expand All @@ -27,13 +27,13 @@ macro_rules! signals {
($($name:ident($num:expr),)*) => {
$(
#[allow(dead_code)]
pub const $name: Signal = Signal(unsafe {
assert!($num > 0 && $num <= SIG_MAXSIG);
NonZeroI32::new_unchecked($num)
});
pub const $name: Signal = match Signal::new($num) {
Some(sig) => sig,
None => panic!(),
};
)*

pub fn strsignal_impl(sig: Signal) -> Cow<'static, str> {
fn strsignal_impl(sig: Signal) -> Cow<'static, str> {
match sig.0.get() {
$( $num => Cow::Borrowed(stringify!($name)), )*
_ => format!("{sig}", sig = sig.get()).into(),
Expand Down

0 comments on commit b0e45d3

Please sign in to comment.