Skip to content

Report divisors that don't fit into 16 bits instead of panicking - #85

Merged
phip1611 merged 2 commits into
rust-osdev:mainfrom
phip1611:divisor-errors
Oct 10, 2026
Merged

phip1611 merged 2 commits into
rust-osdev:mainfrom
phip1611:divisor-errors

Conversation

@phip1611

Copy link
Copy Markdown
Member

calc_divisor() panicked for baud rates too low for the 16-bit divisor latch, e.g., in init(). It now returns the new InvalidDivisorError, which also covers non-integer divisors.

  • Breaking: calc_divisor() and InitError::InvalidBaudRate use InvalidDivisorError.
  • Breaking: InitError is #[non_exhaustive].

🤖 Generated with Claude Code

calc_divisor() panicked for baud rates too low for the 16-bit divisor
latch, e.g., when init() is called with such a configuration. Return an
error instead. As NonIntegerDivisorError can't express this, introduce
InvalidDivisorError.
Its InvalidBaudRate payload changes in this release, which is breaking
anyway. Mark it non_exhaustive, so future variants won't be.
@phip1611
phip1611 marked this pull request as ready for review October 10, 2026 18:15
@phip1611
phip1611 added this pull request to the merge queue Oct 10, 2026
Merged via the queue into rust-osdev:main with commit 3d44298 Oct 10, 2026
18 checks passed
@phip1611
phip1611 deleted the divisor-errors branch October 10, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant