Skip to content

Commit

Permalink
Merge pull request #266 from rmsyn/fixup/write-constraint-check
Browse files Browse the repository at this point in the history
svd-rs: fix write constraint check
  • Loading branch information
burrbull authored Jul 21, 2024
2 parents f4376aa + 973a46c commit 943f458
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions svd-rs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Add `riscv` element for configuration parameters related to RISC-V targets.
You must use the `unstable-riscv` feature to enable this exeperimental element.
- Add `DataType`
- Fix run-time panic for write constraint check

## [v0.14.8] - 2024-02-13

Expand Down
9 changes: 7 additions & 2 deletions svd-rs/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,13 @@ impl FieldInfo {
}
}

if let Some(WriteConstraint::Range(constraint)) = self.write_constraint {
constraint.check_range(0..2_u64.pow(self.bit_range.width))?;
match self.write_constraint {
// If the bit_range has its maximum width, all values will of
// course fit in so we can skip validation.
Some(WriteConstraint::Range(constraint)) if self.bit_range.width < 64 => {
constraint.check_range(0..2_u64.pow(self.bit_range.width))?;
}
_ => (),
}
}

Expand Down

0 comments on commit 943f458

Please sign in to comment.