Skip to content

Commit

Permalink
Merge #176
Browse files Browse the repository at this point in the history
176: check for wrong range size r=burrbull a=Emilgardis



Co-authored-by: Emil Gardström <[email protected]>
  • Loading branch information
bors[bot] and Emilgardis authored Nov 10, 2021
2 parents a08622a + d880c4b commit 417539e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions svd-parser/src/bitrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub enum InvalidBitRange {
ParseError,
MsbLsb,
Empty,
Size,
}

impl Parse for BitRange {
Expand Down Expand Up @@ -83,6 +84,9 @@ impl Parse for BitRange {
return Err(SVDError::InvalidBitRange(InvalidBitRange::Syntax).at(tree.id()));
};

if start > end {
return Err(SVDError::InvalidBitRange(InvalidBitRange::Size).at(tree.id()));
}
Ok(Self {
offset: start,
width: end - start + 1,
Expand Down
1 change: 1 addition & 0 deletions svd-rs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

- Add check for wrong size of `bitRange` width
- Don't clone when serialize
- Add optional entries to `Cpu`
- `AddressBlock` & `Interrupt` now use builders
Expand Down

0 comments on commit 417539e

Please sign in to comment.