Skip to content

Commit 5b1b56d

Browse files
dimblebyCopilot
authored andcommitted
Tighten upper-bound debug_assert in bitfield_unit accessors
The upper-bound check in get/set/raw_get/raw_set and their const-generic siblings used floor division: `(bit_offset + bit_width) / 8 <= len`. The byte-loop touches indices up to `start_byte + bytes_needed - 1 = ceil((bit_offset + bit_width) / 8) - 1`, so the correct check is `(bit_offset + bit_width + 7) / 8 <= len`. Codegen never produces values that would fail the tighter assert, so this is a hardening of the safety check rather than a runtime fix. Regenerate the matching expectations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0c5b8d3 commit 5b1b56d

43 files changed

Lines changed: 428 additions & 344 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bindgen-tests/tests/expectations/tests/bitfield-32bit-overflow.rs

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/bitfield-large.rs

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/bitfield-linux-32.rs

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/bitfield-template.rs

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)