Skip to content

Commit

Permalink
Substitue unwrap calls for passing up None
Browse files Browse the repository at this point in the history
  • Loading branch information
DrChat committed Jun 1, 2021
1 parent 834bd68 commit 1fcbb0d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gdbstub_arch/src/arm/reg/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ impl RegId for ArmCoreRegId {
25 => Self::Cpsr,
_ => return None,
};
Some((reg, Some(NonZeroUsize::new(4).unwrap())))
Some((reg, Some(NonZeroUsize::new(4)?)))
}
}
4 changes: 2 additions & 2 deletions gdbstub_arch/src/mips/reg/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ fn from_raw_id<U>(id: usize) -> Option<(MipsRegId<U>, Option<NonZeroUsize>)> {
76 => MipsRegId::Hi3,
77 => MipsRegId::Lo3,
// `MipsRegId::Dspctl` is the only register that will always be 4 bytes wide
78 => return Some((MipsRegId::Dspctl, Some(NonZeroUsize::new(4).unwrap()))),
78 => return Some((MipsRegId::Dspctl, Some(NonZeroUsize::new(4)?))),
79 => MipsRegId::Restart,
_ => return None,
};

let ptrsize = core::mem::size_of::<U>();
Some((reg, Some(NonZeroUsize::new(ptrsize).unwrap())))
Some((reg, Some(NonZeroUsize::new(ptrsize)?)))
}

impl RegId for MipsRegId<u32> {
Expand Down
2 changes: 1 addition & 1 deletion gdbstub_arch/src/msp430/reg/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl RegId for Msp430RegId {
4..=15 => Self::Gpr((id as u8) - 4),
_ => return None,
};
Some((reg, Some(NonZeroUsize::new(2).unwrap())))
Some((reg, Some(NonZeroUsize::new(2)?)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion gdbstub_arch/src/riscv/reg/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ macro_rules! impl_riscv_reg_id {
_ => return None,
};

Some((id, Some(NonZeroUsize::new(size).unwrap())))
Some((id, Some(NonZeroUsize::new(size)?)))
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions gdbstub_arch/src/x86/reg/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl RegId for X86CoreRegId {
_ => return None,
};

Some((r, Some(NonZeroUsize::new(sz).unwrap())))
Some((r, Some(NonZeroUsize::new(sz)?)))
}
}

Expand Down Expand Up @@ -185,7 +185,7 @@ impl RegId for X86_64CoreRegId {
_ => return None,
};

Some((r, Some(NonZeroUsize::new(sz).unwrap())))
Some((r, Some(NonZeroUsize::new(sz)?)))
}
}

Expand Down

0 comments on commit 1fcbb0d

Please sign in to comment.