Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Don't log error for try_from failure for Register
Browse files Browse the repository at this point in the history
This was caused by a bug within core which shouldn't be sending
temporary registers to the architecture. There's nothing we can do about
this and the guidance is to not print the error message.

Fixes #2
  • Loading branch information
jrozner committed Aug 2, 2024
1 parent f5387f2 commit 4ef3afc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/architecture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,7 @@ impl Architecture for Msp430 {
fn register_from_id(&self, id: u32) -> Option<Self::Register> {
match id.try_into() {
Ok(register) => Some(register),
Err(_) => {
error!("invalid register id {}", id);
None
}
Err(_) => None,
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ impl TryFrom<u32> for Register {
type Error = ();

fn try_from(id: u32) -> Result<Self, Self::Error> {
// TODO: we should return separate errors if the id is between 0x7fff_ffff and 0xffff_ffff
// vs outside of that range. Temporary registers have have the high bit set which we
// shouldn't get, unless there is a bug in core. An id that isn't within that range but we
// don't handle is a bug in the architecture.
match id {
0 => Ok(Self::Pc),
1 => Ok(Self::Sp),
Expand Down

0 comments on commit 4ef3afc

Please sign in to comment.