Skip to content

Commit ac6ab19

Browse files
committed
one more addressOffset check
1 parent b57f782 commit ac6ab19

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

CHANGELOG-rust.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This changelog tracks the Rust `svdtools` project. See
66
## [Unreleased]
77

88
* Allow to modify registers in `_cluster:`
9+
* Add addressOffset check in `collect_in_cluster`
910

1011
## [v0.3.11] 2024-03-06
1112

src/patch/peripheral.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,9 @@ fn collect_in_array(
12841284
.or_else(|| registers[0].properties.size.map(|s| s / 8))
12851285
.unwrap_or_default()
12861286
};
1287+
if dim_increment == 0 {
1288+
return Err(anyhow!("Need to specify dimIncrement"));
1289+
}
12871290
if !check_offsets(&offsets, dim_increment) {
12881291
return Err(anyhow!(
12891292
"{}: registers cannot be collected into {rspec} array. Different addressOffset increments",
@@ -1558,6 +1561,9 @@ fn collect_in_cluster(
15581561
reg.description = Some(desc.into());
15591562
}
15601563
reg.address_offset -= address_offset;
1564+
if reg.address_offset >= dim_increment {
1565+
return Err(anyhow!("Register {} addressOffset={} is out of cluster {cname} dimIncrement = {dim_increment}", &reg.name, reg.address_offset));
1566+
}
15611567
children.push(RegisterCluster::Register(reg));
15621568
}
15631569

0 commit comments

Comments
 (0)